Merge branch 'RecyclerView' into develop
This commit is contained in:
@@ -1,8 +1,61 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class CouponAdapter {
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
class CouponViewHolder {
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.a1.nextlocation.data.Coupon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponViewHolder> {
|
||||
|
||||
private Context appContext;
|
||||
private List<Coupon> couponList;
|
||||
private OnItemClickListener clickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int clickedPosition);
|
||||
}
|
||||
|
||||
class CouponViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
|
||||
public CouponViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
clickListener.onItemClick(getAdapterPosition());
|
||||
}
|
||||
}
|
||||
|
||||
public CouponAdapter(Context context, List<Coupon> coupon, OnItemClickListener listener){
|
||||
appContext = context;
|
||||
couponList = coupon;
|
||||
clickListener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public CouponViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull CouponViewHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return couponList.size();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,23 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
import com.a1.nextlocation.data.Coupon;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class CouponListManager {
|
||||
|
||||
private List<Coupon> coupon;
|
||||
|
||||
public CouponListManager(){
|
||||
|
||||
}
|
||||
|
||||
public List<Coupon> getCoupon() {
|
||||
return coupon;
|
||||
}
|
||||
|
||||
public void setCoupon(List<Coupon> location) {
|
||||
this.coupon = coupon;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class CouponLoader {
|
||||
public class CouponLoader implements Loader{
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public interface Loader {
|
||||
void load();
|
||||
}
|
||||
@@ -1,8 +1,70 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class LocationAdapter {
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
class LocationViewHolder {
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.a1.nextlocation.R;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.LocationViewHolder> {
|
||||
|
||||
private Context appContext;
|
||||
private List<Location> locationList;
|
||||
private CouponAdapter.OnItemClickListener clickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int clickedPosition);
|
||||
}
|
||||
|
||||
class LocationViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
|
||||
private TextView locationName;
|
||||
|
||||
public LocationViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
this.locationName = itemView.findViewById(R.id.location_name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
clickListener.onItemClick(getAdapterPosition());
|
||||
}
|
||||
|
||||
public void setTextViewText(String text){
|
||||
locationName.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public LocationAdapter(Context context, List<Location> location, CouponAdapter.OnItemClickListener listener){
|
||||
this.appContext = context;
|
||||
this.locationList = location;
|
||||
this.clickListener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public LocationAdapter.LocationViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
View itemView = LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_location, parent, false);
|
||||
LocationViewHolder viewHolder = new LocationViewHolder(itemView);
|
||||
return viewHolder;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull LocationAdapter.LocationViewHolder holder, int position) {
|
||||
Location location = locationList.get(position);
|
||||
holder.setTextViewText(location.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return locationList.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,22 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
import com.a1.nextlocation.data.Location;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class LocationListManager {
|
||||
|
||||
private List<Location> location;
|
||||
|
||||
public LocationListManager(){
|
||||
|
||||
}
|
||||
|
||||
public List<Location> getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
public void setLocation(List<Location> location) {
|
||||
this.location = location;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class LocationLoader {
|
||||
public class LocationLoader implements Loader{
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,8 +1,57 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class RouteAdapter {
|
||||
import android.content.Context;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
class RouteViewHolder {
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.a1.nextlocation.data.Route;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RouteAdapter extends RecyclerView.Adapter<RouteAdapter.RouteViewHolder>{
|
||||
|
||||
private Context appContext;
|
||||
private List<Route> routeList;
|
||||
private CouponAdapter.OnItemClickListener clickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int clickedPosition);
|
||||
}
|
||||
|
||||
class RouteViewHolder extends RecyclerView.ViewHolder implements View.OnClickListener {
|
||||
|
||||
public RouteViewHolder(@NonNull View itemView) {
|
||||
super(itemView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
clickListener.onItemClick(getAdapterPosition());
|
||||
}
|
||||
}
|
||||
|
||||
public RouteAdapter(Context context, List<Route> route, CouponAdapter.OnItemClickListener listener){
|
||||
appContext = context;
|
||||
routeList = route;
|
||||
clickListener = listener;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
@Override
|
||||
public RouteAdapter.RouteViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBindViewHolder(@NonNull RouteAdapter.RouteViewHolder holder, int position) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getItemCount() {
|
||||
return routeList.size();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,27 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class RouteListManager {
|
||||
import com.a1.nextlocation.data.Route;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RouteListManager implements Loader{
|
||||
|
||||
List<Route> routes;
|
||||
|
||||
public RouteListManager(){
|
||||
|
||||
}
|
||||
|
||||
public List<Route> getRoutes() {
|
||||
return routes;
|
||||
}
|
||||
|
||||
public void setRoutes(List<Route> routes) {
|
||||
this.routes = routes;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,4 +1,8 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
public class RouteLoader {
|
||||
public class RouteLoader implements Loader {
|
||||
@Override
|
||||
public void load() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user