From 9ca3b12d71de5f61e4c71a70a89946ea12a28e2d Mon Sep 17 00:00:00 2001 From: sebas Date: Mon, 4 Jan 2021 11:06:04 +0100 Subject: [PATCH] Added code to CouponFragment --- .../fragments/CouponFragment.java | 33 ++++++++++++++++--- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java index 22302bb..b31f5f2 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/CouponFragment.java @@ -3,24 +3,49 @@ package com.a1.nextlocation.fragments; import android.os.Bundle; import androidx.fragment.app.Fragment; +import androidx.fragment.app.FragmentActivity; +import androidx.recyclerview.widget.LinearLayoutManager; +import androidx.recyclerview.widget.RecyclerView; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import com.a1.nextlocation.R; +import com.a1.nextlocation.data.Coupon; +import com.a1.nextlocation.recyclerview.CouponAdapter; +import com.a1.nextlocation.recyclerview.CouponListManager; + +import java.util.List; public class CouponFragment extends Fragment { + private RecyclerView couponRecyclerView; + private RecyclerView.LayoutManager layoutManager; + private List couponList; + private CouponAdapter couponAdapter; + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override - public View onCreateView(LayoutInflater inflater, ViewGroup container, - Bundle savedInstanceState) { - // Inflate the layout for this fragment - return inflater.inflate(R.layout.fragment_coupon, container, false); + public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { + View view = inflater.inflate(R.layout.fragment_coupon, container, false); + + this.couponRecyclerView = view.findViewById(R.id.routeRecyclerView); + this.couponRecyclerView.setHasFixedSize(true); + this.layoutManager = new LinearLayoutManager(this.getContext()); + + CouponListManager.INSTANCE.setContext(this.getContext()); + CouponListManager.INSTANCE.load(); + this.couponList = CouponListManager.INSTANCE.getCouponList(); + + this.couponAdapter = new CouponAdapter(this.getContext(), this.couponList); + + this.couponRecyclerView.setLayoutManager(this.layoutManager); + this.couponRecyclerView.setAdapter(this.couponAdapter); + return view; } } \ No newline at end of file