made listmanagers enums
This commit is contained in:
@@ -3,5 +3,10 @@
|
|||||||
"name": "kees kroket",
|
"name": "kees kroket",
|
||||||
"coordinates": "2.4654645,6.2342323",
|
"coordinates": "2.4654645,6.2342323",
|
||||||
"description": "lekkere patatjes"
|
"description": "lekkere patatjes"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name" : "locatie2",
|
||||||
|
"coordinates": "3.65656,9.564564",
|
||||||
|
"description": "locatie 2"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@@ -13,6 +13,9 @@ import com.a1.nextlocation.fragments.HomeFragment;
|
|||||||
import com.a1.nextlocation.fragments.RouteFragment;
|
import com.a1.nextlocation.fragments.RouteFragment;
|
||||||
import com.a1.nextlocation.fragments.SettingsFragment;
|
import com.a1.nextlocation.fragments.SettingsFragment;
|
||||||
import com.a1.nextlocation.fragments.StatisticFragment;
|
import com.a1.nextlocation.fragments.StatisticFragment;
|
||||||
|
import com.a1.nextlocation.recyclerview.CouponListManager;
|
||||||
|
import com.a1.nextlocation.recyclerview.LocationListManager;
|
||||||
|
import com.a1.nextlocation.recyclerview.RouteListManager;
|
||||||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||||
|
|
||||||
public class MainActivity extends AppCompatActivity {
|
public class MainActivity extends AppCompatActivity {
|
||||||
@@ -28,6 +31,10 @@ public class MainActivity extends AppCompatActivity {
|
|||||||
BottomNavigationView bottomNav = findViewById(R.id.navbar);
|
BottomNavigationView bottomNav = findViewById(R.id.navbar);
|
||||||
bottomNav.setOnNavigationItemSelectedListener(navListener);
|
bottomNav.setOnNavigationItemSelectedListener(navListener);
|
||||||
|
|
||||||
|
LocationListManager.INSTANCE.setContext(this);
|
||||||
|
CouponListManager.INSTANCE.setContext(this);
|
||||||
|
RouteListManager.INSTANCE.setContext(this);
|
||||||
|
|
||||||
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).commit();
|
getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -100,6 +100,9 @@ public class HomeFragment extends Fragment {
|
|||||||
// add location manager and set the start point
|
// add location manager and set the start point
|
||||||
LocationManager locationManager = (LocationManager) requireActivity().getSystemService(Context.LOCATION_SERVICE);
|
LocationManager locationManager = (LocationManager) requireActivity().getSystemService(Context.LOCATION_SERVICE);
|
||||||
|
|
||||||
|
LocationListManager.INSTANCE.load();
|
||||||
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);
|
||||||
GeoPoint startPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
|
GeoPoint startPoint = new GeoPoint(location.getLatitude(), location.getLongitude());
|
||||||
@@ -116,10 +119,6 @@ public class HomeFragment extends Fragment {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CouponListManager couponListManager = new CouponListManager(requireContext());
|
|
||||||
couponListManager.load();
|
|
||||||
Log.d(TAG, "initMap: " + couponListManager.getCoupon(0).getCode());
|
|
||||||
|
|
||||||
}
|
}
|
||||||
private void requestPermissionsIfNecessary(String... permissions) {
|
private void requestPermissionsIfNecessary(String... permissions) {
|
||||||
ArrayList<String> permissionsToRequest = new ArrayList<>();
|
ArrayList<String> permissionsToRequest = new ArrayList<>();
|
||||||
|
|||||||
@@ -4,15 +4,18 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.a1.nextlocation.data.Coupon;
|
import com.a1.nextlocation.data.Coupon;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class CouponListManager {
|
public enum CouponListManager {
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
private List<Coupon> couponList;
|
private List<Coupon> couponList;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public CouponListManager(Context context){
|
public void setContext(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.couponList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Coupon> getCouponList() {
|
public List<Coupon> getCouponList() {
|
||||||
|
|||||||
@@ -4,16 +4,18 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.a1.nextlocation.data.Location;
|
import com.a1.nextlocation.data.Location;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class LocationListManager {
|
public enum LocationListManager {
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
private List<Location> locationList;
|
private List<Location> locationList;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public LocationListManager(Context context){
|
public void setContext(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.locationList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Location> getLocationList() {
|
public List<Location> getLocationList() {
|
||||||
|
|||||||
@@ -4,17 +4,21 @@ import android.content.Context;
|
|||||||
|
|
||||||
import com.a1.nextlocation.data.Route;
|
import com.a1.nextlocation.data.Route;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class RouteListManager{
|
public enum RouteListManager{
|
||||||
|
INSTANCE;
|
||||||
|
|
||||||
private List<Route> routeList;
|
private List<Route> routeList;
|
||||||
private Context context;
|
private Context context;
|
||||||
|
|
||||||
public RouteListManager(Context context){
|
public void setContext(Context context) {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
|
this.routeList = new ArrayList<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public List<Route> getRouteList() {
|
public List<Route> getRouteList() {
|
||||||
return routeList;
|
return routeList;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user