Panagiotis Triantafyllou

redesign supermarket part4

......@@ -40,17 +40,13 @@ import ly.warp.sdk.utils.managers.WarplyManager;
import ly.warp.sdk.views.adapters.ExpiredCouponAdapter;
import ly.warp.sdk.views.adapters.SharedCouponAdapter;
public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnClickListener {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private ImageView mIvBack;
private TextView mTvCouponsValueAll, mTvSharedEmpty, mTvExpiredEmpty;
private RecyclerView mRvExpiredCoupons, mRvSharedCoupons;
......@@ -67,13 +63,11 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_loyalty_market_analysis);
mSecondsHandler = new Handler();
mIvBack = findViewById(R.id.iv_loyalty_analysis_close);
mTvCouponsValueAll = findViewById(R.id.tv_expired_coupons_title);
mRvExpiredCoupons = findViewById(R.id.rv_expired_coupons);
......@@ -86,7 +80,6 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
mTvExpiredEmpty = findViewById(R.id.tv_expired_empty);
mLlShowMoreExpired = findViewById(R.id.ll_show_more_expired);
mLlShowMoreShared = findViewById(R.id.ll_show_more_shared);
if (WarplyManagerHelper.getMarketCoupons() != null && WarplyManagerHelper.getMarketCoupons().size() > 0) {
for (UnifiedCoupon unicoupon : WarplyManagerHelper.getMarketCoupons()) {
if (unicoupon.getCoupons() != null && unicoupon.getCoupons().size() > 0) {
......@@ -99,14 +92,13 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
}
}
}
initViews();
}
@Override
public void onResume() {
super.onResume();
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "LoyaltyHistoryScreen");
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "LoyaltyMarketHistoryScreen");
mTimer = 0;
mSecondsHandler.post(new Runnable() {
@Override
......@@ -115,9 +107,7 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
mSecondsHandler.postDelayed(this, 1000);
}
});
mSharedCoupons.clear();
new Thread(() -> {
if (!Thread.currentThread().isInterrupted()) {
WarplyManager.getSharingHistory(new WarplySharingHistoryRequest()
......@@ -138,7 +128,6 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
super.onPause();
if (mSecondsHandler != null) {
mSecondsHandler.removeCallbacksAndMessages(null);
LoyaltySDKFirebaseEventModel analyticsEvent = new LoyaltySDKFirebaseEventModel();
analyticsEvent.setEventName("time_spent_on_loyalty_sdk");
analyticsEvent.setParameter("name", "GiftsCalculator");
......@@ -157,25 +146,22 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("LoyaltyHistoryScreen")
.concat(":")
.concat("TabExpired"));
mLlExpiredTab.setBackgroundResource(R.drawable.bottom_border_light_blue);
mLlExpiredTab.setBackgroundResource(R.drawable.bottom_border_gradient2);
TextView expiredTab = findViewById(R.id.tv_expired_tab);
expiredTab.setTextColor(ContextCompat.getColor(this, R.color.cos_light_black));
expiredTab.setTextColor(ContextCompat.getColor(this, R.color.cos_cyan4));
CalligraphyTypefaceSpan typefaceBoldSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf"));
SpannableStringBuilder sBuilderExpired = new SpannableStringBuilder();
sBuilderExpired.append(getString(R.string.cos_redeemed_coupons_tab));
sBuilderExpired.setSpan(typefaceBoldSpan, 0, getString(R.string.cos_redeemed_coupons_tab).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
expiredTab.setText(sBuilderExpired, TextView.BufferType.SPANNABLE);
mLlSharedTab.setBackgroundResource(R.drawable.bottom_border_transparent);
TextView sharedTab = findViewById(R.id.tv_shared_tab);
sharedTab.setTextColor(ContextCompat.getColor(this, R.color.cos_gray2));
sharedTab.setTextColor(ContextCompat.getColor(this, R.color.cos_dark_grey));
CalligraphyTypefaceSpan typefaceRegularSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-SemiBold.ttf"));
SpannableStringBuilder sBuilderShared = new SpannableStringBuilder();
sBuilderShared.append(getString(R.string.cos_shared_gifts_tab));
sBuilderShared.setSpan(typefaceRegularSpan, 0, getString(R.string.cos_shared_gifts_tab).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sharedTab.setText(sBuilderShared, TextView.BufferType.SPANNABLE);
mRlSharedView.setVisibility(View.GONE);
mRlExpiredView.setVisibility(View.VISIBLE);
return;
......@@ -184,25 +170,22 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("LoyaltyHistoryScreen")
.concat(":")
.concat("TabShared"));
mLlSharedTab.setBackgroundResource(R.drawable.bottom_border_light_blue);
mLlSharedTab.setBackgroundResource(R.drawable.bottom_border_gradient2);
TextView sharedTab = findViewById(R.id.tv_shared_tab);
sharedTab.setTextColor(ContextCompat.getColor(this, R.color.cos_light_black));
sharedTab.setTextColor(ContextCompat.getColor(this, R.color.cos_cyan4));
CalligraphyTypefaceSpan typefaceBoldSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf"));
SpannableStringBuilder sBuilderShared = new SpannableStringBuilder();
sBuilderShared.append(getString(R.string.cos_shared_gifts_tab));
sBuilderShared.setSpan(typefaceBoldSpan, 0, getString(R.string.cos_shared_gifts_tab).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sharedTab.setText(sBuilderShared, TextView.BufferType.SPANNABLE);
mLlExpiredTab.setBackgroundResource(R.drawable.bottom_border_transparent);
TextView expiredTab = findViewById(R.id.tv_expired_tab);
expiredTab.setTextColor(ContextCompat.getColor(this, R.color.cos_gray2));
expiredTab.setTextColor(ContextCompat.getColor(this, R.color.cos_dark_grey));
CalligraphyTypefaceSpan typefaceRegularSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-SemiBold.ttf"));
SpannableStringBuilder sBuilderExpired = new SpannableStringBuilder();
sBuilderExpired.append(getString(R.string.cos_redeemed_coupons_tab));
sBuilderExpired.setSpan(typefaceRegularSpan, 0, getString(R.string.cos_redeemed_coupons_tab).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
expiredTab.setText(sBuilderExpired, TextView.BufferType.SPANNABLE);
mRlExpiredView.setVisibility(View.GONE);
mRlSharedView.setVisibility(View.VISIBLE);
return;
......@@ -230,66 +213,45 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
// ===========================================================
// Methods
// ===========================================================
private void initViews() {
mIvBack.setOnClickListener(this);
mLlExpiredTab.setOnClickListener(this);
mLlSharedTab.setOnClickListener(this);
mLlShowMoreExpired.setOnClickListener(this);
mLlShowMoreShared.setOnClickListener(this);
mLlExpiredTab.setBackgroundResource(R.drawable.bottom_border_light_blue);
mLlExpiredTab.setBackgroundResource(R.drawable.bottom_border_gradient2);
TextView expiredTab = findViewById(R.id.tv_expired_tab);
expiredTab.setTextColor(ContextCompat.getColor(this, R.color.cos_light_black));
expiredTab.setTextColor(ContextCompat.getColor(this, R.color.cos_cyan4));
CalligraphyTypefaceSpan typefaceBoldExpiredSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf"));
SpannableStringBuilder sBuilderExpired = new SpannableStringBuilder();
sBuilderExpired.append(getString(R.string.cos_redeemed_coupons_tab));
sBuilderExpired.setSpan(typefaceBoldExpiredSpan, 0, getString(R.string.cos_redeemed_coupons_tab).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
expiredTab.setText(sBuilderExpired, TextView.BufferType.SPANNABLE);
mLlSharedTab.setBackgroundResource(R.drawable.bottom_border_transparent);
TextView sharedTab = findViewById(R.id.tv_shared_tab);
sharedTab.setTextColor(ContextCompat.getColor(this, R.color.cos_gray2));
sharedTab.setTextColor(ContextCompat.getColor(this, R.color.cos_dark_grey));
CalligraphyTypefaceSpan typefaceRegularSharedSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-SemiBold.ttf"));
SpannableStringBuilder sBuilderShared = new SpannableStringBuilder();
sBuilderShared.append(getString(R.string.cos_shared_gifts_tab));
sBuilderShared.setSpan(typefaceRegularSharedSpan, 0, getString(R.string.cos_shared_gifts_tab).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sharedTab.setText(sBuilderShared, TextView.BufferType.SPANNABLE);
String badgeValue = String.format("%.02f", countValue);
SpannableStringBuilder sBuilder = new SpannableStringBuilder();
sBuilder
.append(getString(R.string.cos_wallet_text3))
.append(String.format(getString(R.string.cos_value), badgeValue))
.append(getString(R.string.cos_wallet_text4))
.append(String.format(getString(R.string.cos_value2), String.valueOf(mExpiredMarketCoupons.size())))
.append(getString(R.string.cos_wallet_text5));
CalligraphyTypefaceSpan typefaceRegularSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Regular.ttf"));
CalligraphyTypefaceSpan typefaceRegularSpan2 = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Regular.ttf"));
CalligraphyTypefaceSpan typefaceRegularSpan3 = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Regular.ttf"));
sBuilder.append(String.format(getString(R.string.cos_supermarket_history), badgeValue, String.valueOf(mExpiredMarketCoupons.size())));
CalligraphyTypefaceSpan typefaceBoldSpan = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf"));
CalligraphyTypefaceSpan typefaceBoldSpan2 = new CalligraphyTypefaceSpan(TypefaceUtils.load(getAssets(), "fonts/PeridotPE-Bold.ttf"));
sBuilder.setSpan(typefaceRegularSpan, 0, getString(R.string.cos_wallet_text3).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sBuilder.setSpan(typefaceBoldSpan, getString(R.string.cos_wallet_text3).length(), getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sBuilder.setSpan(typefaceRegularSpan2, getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1, getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1 + getString(R.string.cos_wallet_text4).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sBuilder.setSpan(typefaceBoldSpan2, getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1 + getString(R.string.cos_wallet_text4).length(), getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1 + getString(R.string.cos_wallet_text4).length() + String.valueOf(mExpiredMarketCoupons.size()).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sBuilder.setSpan(typefaceRegularSpan3, getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1 + getString(R.string.cos_wallet_text4).length() + String.valueOf(mExpiredMarketCoupons.size()).length(), getString(R.string.cos_wallet_text3).length() + String.valueOf(countValue).length() + 1 + getString(R.string.cos_wallet_text4).length() + String.valueOf(mExpiredMarketCoupons.size()).length() + getString(R.string.cos_wallet_text5).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sBuilder.setSpan(typefaceBoldSpan, 26, 26 + badgeValue.length() + 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
sBuilder.setSpan(typefaceBoldSpan2, 26 + badgeValue.length() + 1 + 18, 26 + badgeValue.length() + 1 + 18 + String.valueOf(mExpiredMarketCoupons.size()).length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
mTvCouponsValueAll.setText(sBuilder, TextView.BufferType.SPANNABLE);
if (mExpiredMarketCoupons != null && mExpiredMarketCoupons.size() > 0) {
if (mExpiredMarketCoupons.size() > 3) {
ArrayList<Coupon> tempList = new ArrayList<>(mExpiredMarketCoupons.subList(0, 3));
mRvExpiredCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mAdapterExpiredCoupons = new ExpiredCouponAdapter(this, tempList, true);
mRvExpiredCoupons.setAdapter(mAdapterExpiredCoupons);
mLlShowMoreExpired.setVisibility(View.VISIBLE);
return;
}
mRvExpiredCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mAdapterExpiredCoupons = new ExpiredCouponAdapter(this, mExpiredMarketCoupons, true);
mRvExpiredCoupons.setAdapter(mAdapterExpiredCoupons);
......@@ -301,7 +263,6 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
private CallbackReceiver<SharingList> mSharingHistoryCallback = new CallbackReceiver<SharingList>() {
@Override
public void onSuccess(SharingList result) {
......@@ -321,19 +282,16 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
}
}
}
runOnUiThread(() -> {
if (mSharedCoupons != null && mSharedCoupons.size() > 0) {
if (mSharedCoupons.size() > 3) {
ArrayList<SharingCoupon> tempList = new ArrayList<>(mSharedCoupons.subList(0, 3));
mRvSharedCoupons.setLayoutManager(new LinearLayoutManager(LoyaltyMarketAnalysisActivity.this, LinearLayoutManager.VERTICAL, false));
mAdapterSharedCoupons = new SharedCouponAdapter(LoyaltyMarketAnalysisActivity.this, tempList);
mRvSharedCoupons.setAdapter(mAdapterSharedCoupons);
mLlShowMoreShared.setVisibility(View.VISIBLE);
return;
}
mRvSharedCoupons.setLayoutManager(new LinearLayoutManager(LoyaltyMarketAnalysisActivity.this, LinearLayoutManager.VERTICAL, false));
mAdapterSharedCoupons = new SharedCouponAdapter(LoyaltyMarketAnalysisActivity.this, mSharedCoupons);
mRvSharedCoupons.setAdapter(mAdapterSharedCoupons);
......@@ -348,4 +306,4 @@ public class LoyaltyMarketAnalysisActivity extends Activity implements View.OnCl
WarpUtils.log("SHARED_COUPONS_ERROR " + String.valueOf(errorCode));
}
};
}
}
\ No newline at end of file
......
......@@ -274,7 +274,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
return;
}
if (view.getId() == R.id.cl_market_inner) {
if (countValue > 0) {
// if (countValue > 0) {
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("LoyaltyWalletScreen")
.concat(":")
.concat("MarketBanner"));
......@@ -284,7 +284,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
EventBus.getDefault().post(new WarplyEventBusManager(analyticsEvent));
Intent intent = new Intent(LoyaltyWallet.this, LoyaltyMarketAnalysisActivity.class);
startActivity(intent);
}
// }
return;
}
if (view.getId() == R.id.cl_mygifts) {
......@@ -391,7 +391,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
if (mUnifiedCoupons != null && mUnifiedCoupons.size() > 0) {
ArrayList<UnifiedCoupon> unilist = new ArrayList<UnifiedCoupon>();
for (UnifiedCoupon unicpn : mUnifiedCoupons) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date newDate = new Date();
try {
newDate = simpleDateFormat.parse(unicpn.getCreated());
......@@ -644,7 +644,7 @@ public class LoyaltyWallet extends Activity implements View.OnClickListener, Vie
mUnifiedCouponsAll = result;
ArrayList<UnifiedCoupon> cpnlist = new ArrayList<UnifiedCoupon>();
for (UnifiedCoupon cpn : result) {
if (cpn.getStatus().equals("active")) {
if (cpn.getStatus().trim().equals("active")) {
cpnlist.add(cpn);
}
}
......
......@@ -95,7 +95,7 @@ public class MarketCouponAdapter extends RecyclerView.Adapter<MarketCouponAdapte
for (Coupon item : couponItem.getCoupons()) {
if (item.getStatus() == 1) {
count++;
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date newDate = new Date();
try {
newDate = simpleDateFormat.parse(item.getExpiration());
......@@ -110,7 +110,7 @@ public class MarketCouponAdapter extends RecyclerView.Adapter<MarketCouponAdapte
Collections.sort(couponList, (coupon1, coupon2) -> coupon1.getExpirationDate().compareTo(coupon2.getExpirationDate()));
if (couponList != null && couponList.size() > 0) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date newDate = new Date();
try {
newDate = simpleDateFormat.parse(couponList.get(0).getExpiration());
......
......@@ -93,6 +93,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="3"
android:ellipsize="end"
android:textColor="@color/cos_light_black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -87,6 +87,7 @@
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="3"
android:ellipsize="end"
android:textColor="@color/cos_light_black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -91,6 +91,7 @@
android:layout_marginStart="8dp"
android:layout_marginEnd="16dp"
android:maxLines="3"
android:ellipsize="end"
android:textColor="@color/cos_light_black"
android:textSize="12sp"
app:layout_constraintBottom_toBottomOf="parent"
......
......@@ -169,6 +169,7 @@
<string name="cos_coupon_date_limit2">%1$s</string>
<string name="cos_for_you_all">Μέχρι τώρα έχεις κερδίσει&#160;%1$s€&#160;στο For You!</string>
<string name="cos_supermarket_win">Έχεις κερδίσει&#160;%1$s€&#160;με τα\nSuperMarket Deals!</string>
<string name="cos_supermarket_history">Μέχρι τώρα έχεις κερδίσει %1$s€ σε προσφορές από %2$s κουπόνια!</string>
<string-array name="coupons_array">
<item>Κουπόνια</item>
......