Panagiotis Triantafyllou

sm deals active list screen

......@@ -65,6 +65,12 @@
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<activity
android:name="ly.warp.sdk.activities.ActiveUnifiedCouponsActivity"
android:exported="false"
android:screenOrientation="portrait"
android:theme="@style/SDKAppTheme" />
<!-- android:screenOrientation="portrait"-->
<!-- <activity-->
<!-- android:name="ly.warp.sdk.activities.TelematicsActivity"-->
......
package ly.warp.sdk.activities;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Date;
import io.github.inflationx.viewpump.ViewPumpContextWrapper;
import ly.warp.sdk.R;
import ly.warp.sdk.io.models.UnifiedCoupon;
import ly.warp.sdk.utils.WarplyManagerHelper;
import ly.warp.sdk.utils.managers.WarplyAnalyticsManager;
import ly.warp.sdk.views.adapters.MarketCouponAdapter;
public class ActiveUnifiedCouponsActivity extends Activity implements View.OnClickListener {
// ===========================================================
// Constants
// ===========================================================
// ===========================================================
// Fields
// ===========================================================
private ImageView mIvBack;
private RecyclerView mRecyclerUnifiedCoupons;
private MarketCouponAdapter mAdapterUnifiedCoupons;
private TextView mTvEmptyUnifiedCoupons;
private boolean mUnifiedPressed = false;
// ===========================================================
// Methods for/from SuperClass/Interfaces
// ===========================================================
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_active_unified_coupons);
mIvBack = findViewById(R.id.iv_coupons_close);
mTvEmptyUnifiedCoupons = findViewById(R.id.tv_no_unified_coupons);
mRecyclerUnifiedCoupons = findViewById(R.id.rv_active_unified_coupons);
initViews();
}
@Override
public void onResume() {
super.onResume();
WarplyAnalyticsManager.logTrackersEvent(this, "screen", "ActiveUnifiedCouponsScreen");
mUnifiedPressed = false;
filterItems();
}
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_coupons_close) {
onBackPressed();
}
}
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(ViewPumpContextWrapper.wrap(newBase));
}
// ===========================================================
// Methods
// ===========================================================
private void initViews() {
mIvBack.setOnClickListener(this);
}
private void filterItems() {
if (WarplyManagerHelper.getMarketCouponsList() != null && WarplyManagerHelper.getMarketCouponsList().size() > 0) {
ArrayList<UnifiedCoupon> unilist = new ArrayList<UnifiedCoupon>();
for (UnifiedCoupon unicpn : WarplyManagerHelper.getMarketCouponsList()) {
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss");
Date newDate = new Date();
try {
newDate = simpleDateFormat.parse(unicpn.getCreated());
} catch (ParseException e) {
e.printStackTrace();
}
unicpn.setExpirationDate(newDate);
unilist.add(unicpn);
}
Collections.sort(unilist, (coupon1, coupon2) -> coupon2.getExpirationDate().compareTo(coupon1.getExpirationDate()));
mRecyclerUnifiedCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.VERTICAL, false));
mAdapterUnifiedCoupons = new MarketCouponAdapter(this, unilist);
mRecyclerUnifiedCoupons.setAdapter(mAdapterUnifiedCoupons);
mAdapterUnifiedCoupons.getPositionClicks()
.doOnNext(coupon -> {
if (!mUnifiedPressed) {
mUnifiedPressed = true;
WarplyAnalyticsManager.logTrackersEvent(this, "click", ("UnifiedCoupon").concat(":").concat(coupon.getBarcode()));
Intent intent = new Intent(ActiveUnifiedCouponsActivity.this, UnifiedCouponInfoActivity.class);
intent.putExtra("coupon", (Serializable) coupon);
startActivity(intent);
}
// startActivityForResult(intent, 1002);
})
.doOnError(error -> {
})
.subscribe();
} else {
mTvEmptyUnifiedCoupons.setVisibility(View.GONE);
}
}
// ===========================================================
// Inner and Anonymous Classes
// ===========================================================
}
......@@ -18,33 +18,33 @@
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:src="@drawable/ic_back"
android:scaleType="centerInside"
android:src="@drawable/ic_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
fontPath="fonts/BTCosmo-Bold.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/cos_active_all_coupons"
android:textColor="@color/cos_light_black"
android:textSize="19sp"
fontPath="fonts/BTCosmo-Bold.ttf"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- android:background="@drawable/shape_cos_loyalty"-->
<!-- android:background="@drawable/shape_cos_loyalty"-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@color/cos_light_grey3">
android:background="@color/cos_light_grey3"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_active_coupons"
......@@ -53,20 +53,19 @@
android:clipToPadding="false"
android:orientation="vertical"
android:overScrollMode="never"
android:scrollbars="none"
android:paddingVertical="16dp" />
</RelativeLayout>
android:paddingVertical="16dp"
android:scrollbars="none" />
<TextView
fontPath="fonts/PeridotPE-Regular.ttf"
android:id="@+id/tv_no_coupons"
android:layout_gravity="center_horizontal"
fontPath="fonts/PeridotPE-Regular.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:text="@string/cos_no_active_coupons"
android:textColor="@color/cos_light_black"
android:textSize="16sp"
android:layout_marginTop="40dp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file
......
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/cl_bill_payment"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cos_light_grey3"
android:orientation="vertical">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/cl_bill_header"
android:layout_width="match_parent"
android:layout_height="64dp"
android:background="@color/white">
<ImageView
android:id="@+id/iv_coupons_close"
android:layout_width="48dp"
android:layout_height="48dp"
android:layout_marginStart="16dp"
android:scaleType="centerInside"
android:src="@drawable/ic_back"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/textView3"
fontPath="fonts/BTCosmo-Bold.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:text="@string/cos_market_title"
android:textColor="@color/cos_light_black"
android:textSize="19sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
<!-- android:background="@drawable/shape_cos_loyalty"-->
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/cos_light_grey3"
android:orientation="vertical">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/rv_active_unified_coupons"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipToPadding="false"
android:orientation="vertical"
android:overScrollMode="never"
android:paddingVertical="16dp"
android:scrollbars="none" />
<TextView
android:id="@+id/tv_no_unified_coupons"
fontPath="fonts/PeridotPE-Regular.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_gravity="center"
android:text="@string/cos_no_active_coupons"
android:textColor="@color/cos_light_black"
android:textSize="16sp"
android:visibility="gone" />
</RelativeLayout>
</LinearLayout>
\ No newline at end of file