coupons working
This commit is contained in:
@@ -1,6 +1,10 @@
|
||||
[
|
||||
{
|
||||
"code": "2345",
|
||||
"reward": "fdasfasdf"
|
||||
"code": "KROKET10",
|
||||
"reward": "Gratis 2e kroket bij Kees Kroket™"
|
||||
},
|
||||
{
|
||||
"code": "654",
|
||||
"reward": ",juygly"
|
||||
}
|
||||
]
|
||||
@@ -4,6 +4,7 @@ import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
@@ -25,9 +26,22 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
|
||||
|
||||
class CouponViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
private TextView couponCode;
|
||||
private TextView couponReward;
|
||||
|
||||
public CouponViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
public void setTextViewCode(String text){
|
||||
this.couponCode = itemView.findViewById(R.id.coupon_code);
|
||||
this.couponCode.setText(text);
|
||||
}
|
||||
|
||||
public void setTextViewReward(String text){
|
||||
this.couponReward = itemView.findViewById(R.id.coupon_waarde);
|
||||
this.couponReward.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public CouponAdapter(Context context, List<Coupon> coupon){
|
||||
@@ -38,13 +52,15 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
|
||||
@NonNull
|
||||
@Override
|
||||
public CouponViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_coupon, parent, false);
|
||||
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.coupon_item, parent, false);
|
||||
return new CouponViewHolder(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CouponViewHolder holder, int position) {
|
||||
|
||||
Coupon coupon = couponList.get(position);
|
||||
holder.setTextViewCode(coupon.getCode());
|
||||
holder.setTextViewReward(coupon.getReward());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,24 +1,26 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
<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="match_parent">
|
||||
android:layout_height="wrap_content">
|
||||
|
||||
<androidx.constraintlayout.widget.ConstraintLayout
|
||||
android:id="@+id/Box1"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="70dp"
|
||||
android:layout_marginHorizontal="20dp"
|
||||
android:layout_marginTop="21dp"
|
||||
android:layout_marginTop="16dp"
|
||||
android:layout_marginBottom="16dp"
|
||||
android:background="@color/secondaryColour"
|
||||
app:layout_constraintBottom_toTopOf="@id/Box2"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
|
||||
app:layout_constraintBottom_toBottomOf="parent"
|
||||
app:layout_constraintEnd_toEndOf="parent"
|
||||
app:layout_constraintHorizontal_bias="0.4"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
app:layout_constraintTop_toTopOf="parent">
|
||||
|
||||
<TextView
|
||||
android:id="@+id/coupon_code"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
android:text="Code"
|
||||
@@ -40,8 +42,10 @@
|
||||
app:layout_constraintTop_toTopOf="parent" />
|
||||
|
||||
<TextView
|
||||
android:layout_width="wrap_content"
|
||||
android:id="@+id/coupon_waarde"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginStart="200dp"
|
||||
android:text="Waarde"
|
||||
android:textColor="@color/black"
|
||||
android:textSize="20sp"
|
||||
|
||||
Reference in New Issue
Block a user