Panagiotis Triantafyllou

loyalty profile wip2

......@@ -27,8 +27,8 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener {
// ===========================================================
private ImageView mIvBack;
private RecyclerView mRecyclerCoupons;
private HomeCouponAdapter mAdapterCoupons;
private RecyclerView mRecyclerCoupons ,mRecyclerBurntCoupons;
private HomeCouponAdapter mAdapterCoupons, mAdapterBurntCoupons;
// ===========================================================
// Methods for/from SuperClass/Interfaces
......@@ -41,27 +41,8 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener {
mIvBack = findViewById(R.id.iv_back);
/********* TEST COUPONS DATA **********/
CouponList clist = new CouponList();
try {
clist.add(new Coupon("{\"barcode\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"coupon\": \"123456789\", \"name\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"description\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"image\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\"}"));
clist.add(new Coupon("{\"barcode\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"coupon\": \"12345678910\", \"name\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"description\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"image\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\"}"));
} catch (JSONException e) {
e.printStackTrace();
}
/********* TEST COUPONS DATA **********/
mRecyclerCoupons = findViewById(R.id.rv_loyalty_coupons);
mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
mAdapterCoupons = new HomeCouponAdapter(this, clist);
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(coupon -> {
// startActivity(WarpViewActivity.createIntentFromSessionUUID(this, coupon.getCoupon()));
})
.doOnError(error -> {
})
.subscribe();
mRecyclerBurntCoupons = findViewById(R.id.rv_loyalty_burnt_coupons);
initViews();
}
......@@ -74,7 +55,7 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener {
@Override
public void onClick(View view) {
if (view.getId() == R.id.iv_back) {
finish();
onBackPressed();
}
}
......@@ -83,7 +64,32 @@ public class LoyaltyActivity extends Activity implements View.OnClickListener {
// ===========================================================
private void initViews() {
/********* TEST COUPONS DATA **********/
CouponList clist = new CouponList();
try {
clist.add(new Coupon("{\"barcode\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"coupon\": \"123456789\", \"name\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"description\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"image\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\"}"));
clist.add(new Coupon("{\"barcode\": \"a724e911a71a42408b6ba50ae6c08dbb\", \"coupon\": \"12345678910\", \"name\": \"\\u039a\\u03ac\\u03bd\\u03b5 strike\", \"description\": \"\\u03ba\\u03b1\\u03b9 \\u03ba\\u03ad\\u03c1\\u03b4\\u03b9\\u03c3\\u03b5!\", \"image\": \"https://warply.s3.amazonaws.com/artworks/034fba10ceac4e0f9338bd8e60086292/index.html\"}"));
} catch (JSONException e) {
e.printStackTrace();
}
/********* TEST COUPONS DATA **********/
mIvBack.setOnClickListener(this);
mRecyclerCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
mAdapterCoupons = new HomeCouponAdapter(this, clist);
mRecyclerCoupons.setAdapter(mAdapterCoupons);
mAdapterCoupons.getPositionClicks()
.doOnNext(coupon -> {
// startActivity(WarpViewActivity.createIntentFromSessionUUID(this, coupon.getCoupon()));
})
.doOnError(error -> {
})
.subscribe();
mRecyclerBurntCoupons.setLayoutManager(new LinearLayoutManager(this, LinearLayoutManager.HORIZONTAL, false));
mAdapterBurntCoupons = new HomeCouponAdapter(this, clist, true);
mRecyclerBurntCoupons.setAdapter(mAdapterBurntCoupons);
}
// ===========================================================
......
......@@ -8,6 +8,7 @@ import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
......@@ -24,20 +25,28 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho
private Context mContext;
private CouponList mCoupons;
private final PublishSubject<Coupon> onClickSubject = PublishSubject.create();
private boolean isBurnt = false;
public HomeCouponAdapter(Context mContext, CouponList campaignList) {
this.mContext = mContext;
this.mCoupons = campaignList;
this.isBurnt = false;
}
public HomeCouponAdapter(Context mContext, CouponList campaignList, boolean isBurnt) {
this.mContext = mContext;
this.mCoupons = campaignList;
this.isBurnt = isBurnt;
}
public class HomeCouponViewHolder extends RecyclerView.ViewHolder {
private ImageView ivCouponTitle;
private ImageView ivCouponBackground;
private TextView tvCouponTitle;
public HomeCouponViewHolder(View view) {
super(view);
ivCouponTitle = view.findViewById(R.id.iv_coupon_logo);
tvCouponTitle = view.findViewById(R.id.tv_coupon_subtitle);
ivCouponBackground = view.findViewById(R.id.imageView2);
// tvCouponTitle = view.findViewById(R.id.tv_coupon_subtitle);
}
}
......@@ -63,7 +72,11 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho
@Override
public HomeCouponViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.coupon_layout, parent, false);
View itemView;
if (isBurnt)
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.burnt_coupon_layout, parent, false);
else
itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.coupon_layout, parent, false);
return new HomeCouponViewHolder(itemView);
}
......@@ -89,6 +102,8 @@ public class HomeCouponAdapter extends RecyclerView.Adapter<HomeCouponAdapter.Ho
// holder.tvCouponTitle.setText(couponItem.getName());
if (isBurnt)
holder.ivCouponBackground.setColorFilter(ContextCompat.getColor(mContext, R.color.grey_light2), android.graphics.PorterDuff.Mode.MULTIPLY);
holder.itemView.setOnClickListener(v -> onClickSubject.onNext(couponItem));
}
}
......
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="360dp"
android:layout_height="wrap_content"
android:layout_marginStart="10dp">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/horizontal_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.12" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/horizontal_guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.88" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/vertical_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.94" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/vertical_guideline2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
app:layout_constraintGuide_percent="0.06" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="match_parent"
android:layout_height="250dp"
android:src="@drawable/coupon_wrapper2"
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:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toTopOf="@+id/horizontal_guideline2"
app:layout_constraintEnd_toStartOf="@+id/vertical_guideline"
app:layout_constraintStart_toStartOf="@+id/vertical_guideline2"
app:layout_constraintTop_toTopOf="@+id/horizontal_guideline">
<TextView
android:id="@+id/tv_coupon_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="1"
android:text="Εκπτωτικό κουπόνι -10€"
android:textColor="@color/grey_tr"
android:textSize="18sp"
android:textStyle="bold"
android:layout_marginTop="16dp"
app:layout_constraintEnd_toStartOf="@+id/iv_coupon_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<TextView
android:id="@+id/tv_coupon_subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="24dp"
android:maxLines="2"
android:layout_marginTop="8dp"
android:text="-10€ έκπτωση για το επόμενο γέμισμά σου!"
android:textColor="@color/grey_tr"
android:textFontWeight="600"
android:textSize="16sp"
app:layout_constraintEnd_toStartOf="@+id/iv_coupon_logo"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/tv_coupon_title" />
<ImageView
android:id="@+id/iv_coupon_logo"
android:layout_width="80dp"
android:layout_height="60dp"
android:layout_marginTop="16dp"
android:src="@drawable/ic_shell"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
\ No newline at end of file
......@@ -19,8 +19,8 @@
<de.hdodenhof.circleimageview.CircleImageView
android:id="@+id/iv_profile_photo"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_width="60dp"
android:layout_height="60dp"
android:src="@drawable/profile_photo"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
......@@ -31,8 +31,9 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="2dp"
android:layout_marginTop="6dp"
android:text="@string/cos_profile_name"
android:maxLines="1"
android:textColor="@color/grey"
app:layout_constraintLeft_toRightOf="@+id/iv_profile_photo"
app:layout_constraintTop_toTopOf="@+id/iv_profile_photo" />
......@@ -41,7 +42,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginBottom="6dp"
android:layout_marginBottom="10dp"
android:background="@drawable/shape_cos_gradient"
android:gravity="center"
android:paddingHorizontal="4dp"
......
......@@ -3,7 +3,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="150dp"
android:layout_height="160dp"
android:layout_marginHorizontal="32dp"
android:background="@drawable/shape_cos_gradient2"
android:paddingHorizontal="20dp"
......@@ -64,6 +64,7 @@
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="4dp"
android:background="@drawable/round_border_tr"
android:paddingHorizontal="8dp"
android:paddingVertical="4dp"
......
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="360dp"
android:layout_height="240dp"
android:layout_marginStart="10dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="360dp"
android:layout_height="240dp">
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_horizontal_75_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.75" />
<androidx.constraintlayout.widget.Guideline
android:id="@+id/gl_horizontal_60_guideline"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_percent="0.6" />
<ImageView
android:id="@+id/iv_gift_item_logo"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/shape_cos_transparent_rounded"
android:clipToOutline="true"
android:scaleType="centerCrop"
android:src="@drawable/ic_banner_redeemed_gift"
app:layout_constraintBottom_toTopOf="@+id/gl_horizontal_75_guideline"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<RelativeLayout
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/gl_horizontal_60_guideline">
<LinearLayout
android:id="@+id/ll_loyalty_item1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/white_tr3"
android:paddingHorizontal="16dp"
android:paddingTop="16dp"
android:paddingBottom="4dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="BOX κουπόνι 4€"
android:textColor="@color/grey_tr2"
android:textSize="16sp"
android:textStyle="bold" />
</LinearLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/ll_loyalty_item1"
android:background="@drawable/shape_cos_white_rounded_lower"
android:orientation="vertical"
android:paddingHorizontal="16dp">
<TextView
android:id="@+id/tv_loyalty_item_subtitle"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:maxLines="2"
android:text="4€ έκπτωση για την επόμενη παραγγελία σου!"
android:textColor="@color/grey_tr2"
android:textSize="16sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
</RelativeLayout>
\ No newline at end of file
......@@ -17,4 +17,7 @@
<color name="cos_blue2">#0478BE</color>
<color name="white_tr2">#77FFFFFF</color>
<color name="white_tr3">#E6FFFFFF</color>
<color name="grey_tr">#A3415564</color>
<color name="grey_light2">#F9F9F9</color>
<color name="grey_tr2">#D4415564</color>
</resources>
\ No newline at end of file
......