Panagiotis Triantafyllou

sm deals active list screen

...@@ -65,6 +65,12 @@ ...@@ -65,6 +65,12 @@
65 android:screenOrientation="portrait" 65 android:screenOrientation="portrait"
66 android:theme="@style/SDKAppTheme" /> 66 android:theme="@style/SDKAppTheme" />
67 67
68 + <activity
69 + android:name="ly.warp.sdk.activities.ActiveUnifiedCouponsActivity"
70 + android:exported="false"
71 + android:screenOrientation="portrait"
72 + android:theme="@style/SDKAppTheme" />
73 +
68 <!-- android:screenOrientation="portrait"--> 74 <!-- android:screenOrientation="portrait"-->
69 <!-- <activity--> 75 <!-- <activity-->
70 <!-- android:name="ly.warp.sdk.activities.TelematicsActivity"--> 76 <!-- android:name="ly.warp.sdk.activities.TelematicsActivity"-->
......
1 +package ly.warp.sdk.activities;
2 +
3 +import android.app.Activity;
4 +import android.content.Context;
5 +import android.content.Intent;
6 +import android.os.Bundle;
7 +import android.view.View;
8 +import android.widget.ImageView;
9 +import android.widget.TextView;
10 +
11 +import androidx.recyclerview.widget.LinearLayoutManager;
12 +import androidx.recyclerview.widget.RecyclerView;
13 +
14 +import java.io.Serializable;
15 +import java.text.ParseException;
16 +import java.text.SimpleDateFormat;
17 +import java.util.ArrayList;
18 +import java.util.Collections;
19 +import java.util.Date;
20 +
21 +import io.github.inflationx.viewpump.ViewPumpContextWrapper;
22 +import ly.warp.sdk.R;
23 +import ly.warp.sdk.io.models.UnifiedCoupon;
24 +import ly.warp.sdk.utils.WarplyManagerHelper;
25 +import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
26 +import ly.warp.sdk.views.adapters.MarketCouponAdapter;
27 +
28 +
29 +public class ActiveUnifiedCouponsActivity extends Activity implements View.OnClickListener {
30 +
31 + // ===========================================================
32 + // Constants
33 + // ===========================================================
34 +
35 + // ===========================================================
36 + // Fields
37 + // ===========================================================
38 +
39 + private ImageView mIvBack;
40 + private RecyclerView mRecyclerUnifiedCoupons;
41 + private MarketCouponAdapter mAdapterUnifiedCoupons;
42 + private TextView mTvEmptyUnifiedCoupons;
43 + private boolean mUnifiedPressed = false;
44 +
45 + // ===========================================================
46 + // Methods for/from SuperClass/Interfaces
47 + // ===========================================================
48 +
49 + @Override
50 + public void onCreate(Bundle savedInstanceState) {
51 + super.onCreate(savedInstanceState);
52 + setContentView(R.layout.activity_active_unified_coupons);
53 +
54 + mIvBack = findViewById(R.id.iv_coupons_close);
55 + mTvEmptyUnifiedCoupons = findViewById(R.id.tv_no_unified_coupons);
56 + mRecyclerUnifiedCoupons = findViewById(R.id.rv_active_unified_coupons);
57 +
58 + initViews();
59 + }
60 +
61 + @Override
62 + public void onResume() {
63 + super.onResume();
64 + WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ActiveUnifiedCouponsScreen");
65 + mUnifiedPressed = false;
66 + filterItems();
67 + }
68 +
69 + @Override
70 + public void onClick(View view) {
71 + if (view.getId() == R.id.iv_coupons_close) {
72 + onBackPressed();
73 + }
74 + }
75 +
76 + @Override
77 + protected void attachBaseContext(Context newBase) {
78 + super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
79 + }
80 +
81 + // ===========================================================
82 + // Methods
83 + // ===========================================================
84 +
85 + private void initViews() {
86 + mIvBack.setOnClickListener(this);
87 + }
88 +
89 + private void filterItems() {
90 + if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0) {
91 + ArrayList<UnifiedCoupon> unilist = new ArrayList<UnifiedCoupon>();
92 + for (UnifiedCoupon unicpn : WarplyManagerHelper.getMarketCouponsList()) {
93 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
94 + Date newDate = new Date();
95 + try {
96 + newDate = simpleDateFormat.parse(unicpn.getCreated());
97 + } catch (ParseException e) {
98 + e.printStackTrace();
99 + }
100 + unicpn.setExpirationDate(newDate);
101 + unilist.add(unicpn);
102 + }
103 +
104 + Collections.sort(unilist, (coupon1, coupon2) -> coupon2.getExpirationDate().compareTo(coupon1.getExpirationDate()));
105 +
106 + mRecyclerUnifiedCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
107 + mAdapterUnifiedCoupons = new MarketCouponAdapter(this, unilist);
108 + mRecyclerUnifiedCoupons.setAdapter(mAdapterUnifiedCoupons);
109 + mAdapterUnifiedCoupons.getPositionClicks()
110 + .doOnNext(coupon -> {
111 + if (!mUnifiedPressed) {
112 + mUnifiedPressed = true;
113 + WarplyAnalyticsManager.logTrackersEvent(this, "click", ("UnifiedCoupon").concat(":").concat(coupon.getBarcode()));
114 + Intent intent = new Intent(ActiveUnifiedCouponsActivity.this, UnifiedCouponInfoActivity.class);
115 + intent.putExtra("coupon", (Serializable) coupon);
116 + startActivity(intent);
117 + }
118 +// startActivityForResult(intent, 1002);
119 + })
120 + .doOnError(error -> {
121 + })
122 + .subscribe();
123 + } else {
124 + mTvEmptyUnifiedCoupons.setVisibility(View.GONE);
125 + }
126 + }
127 +
128 + // ===========================================================
129 + // Inner and Anonymous Classes
130 + // ===========================================================
131 +
132 +}
...@@ -18,33 +18,33 @@ ...@@ -18,33 +18,33 @@
18 android:layout_width="48dp" 18 android:layout_width="48dp"
19 android:layout_height="48dp" 19 android:layout_height="48dp"
20 android:layout_marginStart="16dp" 20 android:layout_marginStart="16dp"
21 - android:src="@drawable/ic_back"
22 android:scaleType="centerInside" 21 android:scaleType="centerInside"
22 + android:src="@drawable/ic_back"
23 app:layout_constraintBottom_toBottomOf="parent" 23 app:layout_constraintBottom_toBottomOf="parent"
24 app:layout_constraintStart_toStartOf="parent" 24 app:layout_constraintStart_toStartOf="parent"
25 app:layout_constraintTop_toTopOf="parent" /> 25 app:layout_constraintTop_toTopOf="parent" />
26 26
27 <TextView 27 <TextView
28 android:id="@+id/textView3" 28 android:id="@+id/textView3"
29 + fontPath="fonts/BTCosmo-Bold.ttf"
29 android:layout_width="wrap_content" 30 android:layout_width="wrap_content"
30 android:layout_height="wrap_content" 31 android:layout_height="wrap_content"
31 android:gravity="center" 32 android:gravity="center"
32 android:text="@string/cos_active_all_coupons" 33 android:text="@string/cos_active_all_coupons"
33 android:textColor="@color/cos_light_black" 34 android:textColor="@color/cos_light_black"
34 android:textSize="19sp" 35 android:textSize="19sp"
35 - fontPath="fonts/BTCosmo-Bold.ttf"
36 app:layout_constraintBottom_toBottomOf="parent" 36 app:layout_constraintBottom_toBottomOf="parent"
37 app:layout_constraintEnd_toEndOf="parent" 37 app:layout_constraintEnd_toEndOf="parent"
38 app:layout_constraintStart_toStartOf="parent" 38 app:layout_constraintStart_toStartOf="parent"
39 app:layout_constraintTop_toTopOf="parent" /> 39 app:layout_constraintTop_toTopOf="parent" />
40 </androidx.constraintlayout.widget.ConstraintLayout> 40 </androidx.constraintlayout.widget.ConstraintLayout>
41 41
42 -<!-- android:background="@drawable/shape_cos_loyalty"--> 42 + <!-- android:background="@drawable/shape_cos_loyalty"-->
43 <RelativeLayout 43 <RelativeLayout
44 android:layout_width="match_parent" 44 android:layout_width="match_parent"
45 android:layout_height="match_parent" 45 android:layout_height="match_parent"
46 - android:orientation="vertical" 46 + android:background="@color/cos_light_grey3"
47 - android:background="@color/cos_light_grey3"> 47 + android:orientation="vertical">
48 48
49 <androidx.recyclerview.widget.RecyclerView 49 <androidx.recyclerview.widget.RecyclerView
50 android:id="@+id/rv_active_coupons" 50 android:id="@+id/rv_active_coupons"
...@@ -53,20 +53,19 @@ ...@@ -53,20 +53,19 @@
53 android:clipToPadding="false" 53 android:clipToPadding="false"
54 android:orientation="vertical" 54 android:orientation="vertical"
55 android:overScrollMode="never" 55 android:overScrollMode="never"
56 - android:scrollbars="none" 56 + android:paddingVertical="16dp"
57 - android:paddingVertical="16dp" /> 57 + android:scrollbars="none" />
58 - </RelativeLayout>
59 58
60 <TextView 59 <TextView
61 - fontPath="fonts/PeridotPE-Regular.ttf"
62 android:id="@+id/tv_no_coupons" 60 android:id="@+id/tv_no_coupons"
63 - android:layout_gravity="center_horizontal" 61 + fontPath="fonts/PeridotPE-Regular.ttf"
64 android:layout_width="wrap_content" 62 android:layout_width="wrap_content"
65 android:layout_height="wrap_content" 63 android:layout_height="wrap_content"
66 android:layout_centerInParent="true" 64 android:layout_centerInParent="true"
65 + android:layout_gravity="center"
67 android:text="@string/cos_no_active_coupons" 66 android:text="@string/cos_no_active_coupons"
68 android:textColor="@color/cos_light_black" 67 android:textColor="@color/cos_light_black"
69 android:textSize="16sp" 68 android:textSize="16sp"
70 - android:layout_marginTop="40dp"
71 android:visibility="gone" /> 69 android:visibility="gone" />
70 + </RelativeLayout>
72 </LinearLayout> 71 </LinearLayout>
...\ No newline at end of file ...\ No newline at end of file
......
1 +<?xml version="1.0" encoding="utf-8"?>
2 +<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
3 + xmlns:app="http://schemas.android.com/apk/res-auto"
4 + android:id="@+id/cl_bill_payment"
5 + android:layout_width="match_parent"
6 + android:layout_height="match_parent"
7 + android:background="@color/cos_light_grey3"
8 + android:orientation="vertical">
9 +
10 + <androidx.constraintlayout.widget.ConstraintLayout
11 + android:id="@+id/cl_bill_header"
12 + android:layout_width="match_parent"
13 + android:layout_height="64dp"
14 + android:background="@color/white">
15 +
16 + <ImageView
17 + android:id="@+id/iv_coupons_close"
18 + android:layout_width="48dp"
19 + android:layout_height="48dp"
20 + android:layout_marginStart="16dp"
21 + android:scaleType="centerInside"
22 + android:src="@drawable/ic_back"
23 + app:layout_constraintBottom_toBottomOf="parent"
24 + app:layout_constraintStart_toStartOf="parent"
25 + app:layout_constraintTop_toTopOf="parent" />
26 +
27 + <TextView
28 + android:id="@+id/textView3"
29 + fontPath="fonts/BTCosmo-Bold.ttf"
30 + android:layout_width="wrap_content"
31 + android:layout_height="wrap_content"
32 + android:gravity="center"
33 + android:text="@string/cos_market_title"
34 + android:textColor="@color/cos_light_black"
35 + android:textSize="19sp"
36 + app:layout_constraintBottom_toBottomOf="parent"
37 + app:layout_constraintEnd_toEndOf="parent"
38 + app:layout_constraintStart_toStartOf="parent"
39 + app:layout_constraintTop_toTopOf="parent" />
40 + </androidx.constraintlayout.widget.ConstraintLayout>
41 +
42 + <!-- android:background="@drawable/shape_cos_loyalty"-->
43 + <RelativeLayout
44 + android:layout_width="match_parent"
45 + android:layout_height="match_parent"
46 + android:background="@color/cos_light_grey3"
47 + android:orientation="vertical">
48 +
49 + <androidx.recyclerview.widget.RecyclerView
50 + android:id="@+id/rv_active_unified_coupons"
51 + android:layout_width="match_parent"
52 + android:layout_height="wrap_content"
53 + android:clipToPadding="false"
54 + android:orientation="vertical"
55 + android:overScrollMode="never"
56 + android:paddingVertical="16dp"
57 + android:scrollbars="none" />
58 +
59 + <TextView
60 + android:id="@+id/tv_no_unified_coupons"
61 + fontPath="fonts/PeridotPE-Regular.ttf"
62 + android:layout_width="wrap_content"
63 + android:layout_height="wrap_content"
64 + android:layout_centerInParent="true"
65 + android:layout_gravity="center"
66 + android:text="@string/cos_no_active_coupons"
67 + android:textColor="@color/cos_light_black"
68 + android:textSize="16sp"
69 + android:visibility="gone" />
70 + </RelativeLayout>
71 +</LinearLayout>
...\ No newline at end of file ...\ No newline at end of file