ctrl alt L
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.view.LayoutInflater;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -16,8 +16,8 @@ import java.util.List;
|
||||
|
||||
public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponViewHolder> {
|
||||
|
||||
private Context appContext;
|
||||
private List<Coupon> couponList;
|
||||
private final Context appContext;
|
||||
private final List<Coupon> couponList;
|
||||
private OnItemClickListener clickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
@@ -35,9 +35,10 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
|
||||
|
||||
/**
|
||||
* Sets the text of the coupon
|
||||
*
|
||||
* @param text the text that will be set
|
||||
*/
|
||||
public void setTextViewName(String text){
|
||||
public void setTextViewName(String text) {
|
||||
TextView couponReward = itemView.findViewById(R.id.coupon_name);
|
||||
couponReward.setText(text);
|
||||
}
|
||||
@@ -48,7 +49,7 @@ public class CouponAdapter extends RecyclerView.Adapter<CouponAdapter.CouponView
|
||||
}
|
||||
}
|
||||
|
||||
public CouponAdapter(Context context, List<Coupon> coupon, OnItemClickListener listener){
|
||||
public CouponAdapter(Context context, List<Coupon> coupon, OnItemClickListener listener) {
|
||||
this.appContext = context;
|
||||
this.couponList = coupon;
|
||||
this.clickListener = listener;
|
||||
|
||||
@@ -25,7 +25,7 @@ public enum CouponListManager {
|
||||
/**
|
||||
* prepares the list for the adapter
|
||||
*/
|
||||
public void load(){
|
||||
public void load() {
|
||||
CouponLoader couponLoader = new CouponLoader(this.context);
|
||||
this.couponList = couponLoader.load();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class CouponLoader implements Loader<List<Coupon>> {
|
||||
|
||||
/**
|
||||
* Loads the Arraylist of coupons out of the JSON
|
||||
*
|
||||
* @return Arraylist of coupons
|
||||
*/
|
||||
@Override
|
||||
@@ -32,7 +33,8 @@ public class CouponLoader implements Loader<List<Coupon>> {
|
||||
if (!selectedLanguage.equals("en")) {
|
||||
fileName += "-" + selectedLanguage;
|
||||
}
|
||||
ArrayList<Coupon> res = fileIO.readFileData(context, fileName + ".json", new TypeToken<ArrayList<Coupon>>(){}.getType());
|
||||
ArrayList<Coupon> res = fileIO.readFileData(context, fileName + ".json", new TypeToken<ArrayList<Coupon>>() {
|
||||
}.getType());
|
||||
Log.d(TAG, "load: " + res);
|
||||
|
||||
return res == null ? new ArrayList<>() : res;
|
||||
|
||||
@@ -17,9 +17,9 @@ import java.util.List;
|
||||
|
||||
public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.LocationViewHolder> {
|
||||
|
||||
private Context appContext;
|
||||
private List<Location> locationList;
|
||||
private OnItemClickListener clickListener;
|
||||
private final Context appContext;
|
||||
private final List<Location> locationList;
|
||||
private final OnItemClickListener clickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int clickedPosition);
|
||||
@@ -44,18 +44,20 @@ public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.Locati
|
||||
|
||||
/**
|
||||
* Sets the text of the location name
|
||||
*
|
||||
* @param text the text that will be set
|
||||
*/
|
||||
public void setTextViewText(String text){
|
||||
public void setTextViewText(String text) {
|
||||
this.locationName = itemView.findViewById(R.id.location_name);
|
||||
this.locationName.setText(text);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the image of the locatoin
|
||||
*
|
||||
* @param text the text of the image filename
|
||||
*/
|
||||
public void setImageViewImage(String text){
|
||||
public void setImageViewImage(String text) {
|
||||
this.locationImage = itemView.findViewById(R.id.location_image);
|
||||
Context context = locationImage.getContext();
|
||||
int id = context.getResources().getIdentifier(text, "drawable", context.getPackageName());
|
||||
@@ -63,7 +65,7 @@ public class LocationAdapter extends RecyclerView.Adapter<LocationAdapter.Locati
|
||||
}
|
||||
}
|
||||
|
||||
public LocationAdapter(Context context, List<Location> location, OnItemClickListener listener){
|
||||
public LocationAdapter(Context context, List<Location> location, OnItemClickListener listener) {
|
||||
this.appContext = context;
|
||||
this.locationList = location;
|
||||
this.clickListener = listener;
|
||||
|
||||
@@ -4,8 +4,6 @@ import android.content.Context;
|
||||
|
||||
import com.a1.nextlocation.data.Location;
|
||||
|
||||
import org.osmdroid.util.GeoPoint;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.a1.nextlocation.data.Location;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class LocationLoader implements Loader<List<Location>> {
|
||||
@@ -19,6 +18,7 @@ public class LocationLoader implements Loader<List<Location>> {
|
||||
|
||||
/**
|
||||
* loads the array list from a JSON file
|
||||
*
|
||||
* @return array list with locations
|
||||
*/
|
||||
@Override
|
||||
@@ -32,7 +32,8 @@ public class LocationLoader implements Loader<List<Location>> {
|
||||
fileName += "-" + selectedLanguage;
|
||||
}
|
||||
|
||||
ArrayList<Location> res = fileIO.readFileData(context,fileName + ".json",new TypeToken<ArrayList<Location>>(){}.getType());
|
||||
ArrayList<Location> res = fileIO.readFileData(context, fileName + ".json", new TypeToken<ArrayList<Location>>() {
|
||||
}.getType());
|
||||
|
||||
return res == null ? new ArrayList<>() : res;
|
||||
}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package com.a1.nextlocation.recyclerview;
|
||||
|
||||
import android.content.Context;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
@@ -11,16 +10,15 @@ import androidx.annotation.NonNull;
|
||||
import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.a1.nextlocation.R;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
import com.a1.nextlocation.data.Route;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class RouteAdapter extends RecyclerView.Adapter<RouteAdapter.RouteViewHolder>{
|
||||
public class RouteAdapter extends RecyclerView.Adapter<RouteAdapter.RouteViewHolder> {
|
||||
|
||||
private Context appContext;
|
||||
private List<Route> routeList;
|
||||
private CouponAdapter.OnItemClickListener clickListener;
|
||||
private final Context appContext;
|
||||
private final List<Route> routeList;
|
||||
private final CouponAdapter.OnItemClickListener clickListener;
|
||||
|
||||
public interface OnItemClickListener {
|
||||
void onItemClick(int clickedPosition);
|
||||
@@ -43,15 +41,16 @@ public class RouteAdapter extends RecyclerView.Adapter<RouteAdapter.RouteViewHol
|
||||
|
||||
/**
|
||||
* sets the text of the route name
|
||||
*
|
||||
* @param text the text that will be set
|
||||
*/
|
||||
public void setTextViewText(String text){
|
||||
public void setTextViewText(String text) {
|
||||
this.routeName = itemView.findViewById(R.id.route_name);
|
||||
this.routeName.setText(text);
|
||||
}
|
||||
}
|
||||
|
||||
public RouteAdapter(Context context, List<Route> route, CouponAdapter.OnItemClickListener listener){
|
||||
public RouteAdapter(Context context, List<Route> route, CouponAdapter.OnItemClickListener listener) {
|
||||
appContext = context;
|
||||
routeList = route;
|
||||
clickListener = listener;
|
||||
|
||||
@@ -7,7 +7,7 @@ import com.a1.nextlocation.data.Route;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public enum RouteListManager{
|
||||
public enum RouteListManager {
|
||||
INSTANCE;
|
||||
|
||||
private List<Route> routeList;
|
||||
|
||||
@@ -3,12 +3,10 @@ package com.a1.nextlocation.recyclerview;
|
||||
import android.content.Context;
|
||||
|
||||
import com.a1.nextlocation.data.FileIO;
|
||||
import com.a1.nextlocation.data.Location;
|
||||
import com.a1.nextlocation.data.Route;
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
public class RouteLoader implements Loader<List<Route>> {
|
||||
@@ -20,6 +18,7 @@ public class RouteLoader implements Loader<List<Route>> {
|
||||
|
||||
/**
|
||||
* loads an array list from a JSON
|
||||
*
|
||||
* @return an array list with routes
|
||||
*/
|
||||
@Override
|
||||
@@ -34,7 +33,8 @@ public class RouteLoader implements Loader<List<Route>> {
|
||||
fileName += "-" + selectedLanguage;
|
||||
}
|
||||
|
||||
ArrayList<Route> res = fileIO.readFileData(context, fileName + ".json",new TypeToken<ArrayList<Route>>(){}.getType());
|
||||
ArrayList<Route> res = fileIO.readFileData(context, fileName + ".json", new TypeToken<ArrayList<Route>>() {
|
||||
}.getType());
|
||||
return res == null ? new ArrayList<>() : res;
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user