From 311a794a69da95b1e225dc28858683cc841820f8 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Thu, 17 Dec 2020 11:18:23 +0100 Subject: [PATCH 1/5] removed loader from route list manager --- .../com/a1/nextlocation/recyclerview/RouteListManager.java | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java index 77f4513..d958c24 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java @@ -4,7 +4,7 @@ import com.a1.nextlocation.data.Route; import java.util.List; -public class RouteListManager implements Loader{ +public class RouteListManager { List routes; @@ -19,9 +19,4 @@ public class RouteListManager implements Loader{ public void setRoutes(List routes) { this.routes = routes; } - - @Override - public void load() { - - } } From b52c5556d296d5c83eee08b09dd3594faf57f990 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Thu, 17 Dec 2020 11:50:31 +0100 Subject: [PATCH 2/5] finished loading --- app/src/main/assets/coupons.json | 3 +++ app/src/main/assets/locations.json | 8 ++++++++ app/src/main/assets/routes.json | 3 +++ .../java/com/a1/nextlocation/data/FileIO.java | 8 ++++++-- .../a1/nextlocation/fragments/HomeFragment.java | 5 +++++ .../nextlocation/recyclerview/CouponLoader.java | 13 ++++++------- .../nextlocation/recyclerview/LocationLoader.java | 15 +++++++-------- .../a1/nextlocation/recyclerview/RouteLoader.java | 14 +++++++------- 8 files changed, 45 insertions(+), 24 deletions(-) create mode 100644 app/src/main/assets/coupons.json create mode 100644 app/src/main/assets/locations.json create mode 100644 app/src/main/assets/routes.json diff --git a/app/src/main/assets/coupons.json b/app/src/main/assets/coupons.json new file mode 100644 index 0000000..c44dc44 --- /dev/null +++ b/app/src/main/assets/coupons.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/app/src/main/assets/locations.json b/app/src/main/assets/locations.json new file mode 100644 index 0000000..bebe62d --- /dev/null +++ b/app/src/main/assets/locations.json @@ -0,0 +1,8 @@ +[ + { + "name": "kees kroket", + "coordinates": "2.4654645,6.2342323", + "description": "lekkere patatjes", + "imageUrl": "R.id.yeet" + } +] \ No newline at end of file diff --git a/app/src/main/assets/routes.json b/app/src/main/assets/routes.json new file mode 100644 index 0000000..c44dc44 --- /dev/null +++ b/app/src/main/assets/routes.json @@ -0,0 +1,3 @@ +[ + +] \ No newline at end of file diff --git a/app/src/main/java/com/a1/nextlocation/data/FileIO.java b/app/src/main/java/com/a1/nextlocation/data/FileIO.java index 5672d74..03ad794 100644 --- a/app/src/main/java/com/a1/nextlocation/data/FileIO.java +++ b/app/src/main/java/com/a1/nextlocation/data/FileIO.java @@ -2,6 +2,7 @@ package com.a1.nextlocation.data; import android.content.Context; import android.content.res.AssetManager; +import android.util.Log; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; @@ -14,18 +15,21 @@ import java.nio.file.Files; import java.nio.file.Paths; public class FileIO { + private final String TAG = FileIO.class.getCanonicalName(); - public Class readFileData(Context context, String fileName) { + public T readFileData(Context context, String fileName) { Gson gson = new Gson(); AssetManager am = context.getAssets(); - Class res = null; + T res = null; try { InputStream is = am.open(fileName); InputStreamReader inputStreamReader = new InputStreamReader(is); res = gson.fromJson(inputStreamReader,new TypeToken(){}.getType()); + Log.d(TAG, "readFileData: got object: " + res); } catch (IOException e) { + Log.d(TAG, "readFileData: exception! " + e.getLocalizedMessage()); e.printStackTrace(); } return res; diff --git a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java index 2fda536..326f020 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java @@ -20,6 +20,8 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import com.a1.nextlocation.R; +import com.a1.nextlocation.recyclerview.CouponListManager; +import com.a1.nextlocation.recyclerview.LocationListManager; import org.osmdroid.api.IMapController; import org.osmdroid.config.Configuration; @@ -112,6 +114,9 @@ public class HomeFragment extends Fragment { } + LocationListManager locationListManager = new LocationListManager(requireContext()); + locationListManager.load(); + } private void requestPermissionsIfNecessary(String... permissions) { ArrayList permissionsToRequest = new ArrayList<>(); diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java b/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java index d77a156..f40fd5f 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java @@ -6,21 +6,20 @@ import com.a1.nextlocation.data.Coupon; import com.a1.nextlocation.data.FileIO; import com.a1.nextlocation.data.Location; +import java.util.ArrayList; import java.util.List; public class CouponLoader implements Loader> { private final Context context; + public CouponLoader(Context context) { this.context = context; } + @Override public List load() { - FileIO> fileIO = new FileIO<>(); - try { - return fileIO.readFileData(context,"coupons.json").newInstance(); - } catch (IllegalAccessException | InstantiationException e) { - e.printStackTrace(); - } - return null; + FileIO> fileIO = new FileIO<>(); + ArrayList res = fileIO.readFileData(context, "coupons.json"); + return res == null ? new ArrayList<>() : res; } } diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java index 6a83ccc..fd570bb 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java @@ -5,9 +5,10 @@ import android.content.Context; import com.a1.nextlocation.data.FileIO; import com.a1.nextlocation.data.Location; +import java.util.ArrayList; import java.util.List; -public class LocationLoader implements Loader>{ +public class LocationLoader implements Loader> { private final Context context; public LocationLoader(Context context) { @@ -16,12 +17,10 @@ public class LocationLoader implements Loader>{ @Override public List load() { - FileIO> fileIO = new FileIO<>(); - try { - return fileIO.readFileData(context,"locations.json").newInstance(); - } catch (IllegalAccessException | InstantiationException e) { - e.printStackTrace(); - } - return null; + FileIO> fileIO = new FileIO<>(); + + ArrayList res = fileIO.readFileData(context, "locations.json"); + return res == null ? new ArrayList<>() : res; + } } diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java index 63f46e3..5b5956f 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java @@ -6,10 +6,12 @@ import com.a1.nextlocation.data.FileIO; import com.a1.nextlocation.data.Location; import com.a1.nextlocation.data.Route; +import java.util.ArrayList; import java.util.List; public class RouteLoader implements Loader> { private final Context context; + public RouteLoader(Context context) { this.context = context; } @@ -17,12 +19,10 @@ public class RouteLoader implements Loader> { @Override public List load() { - FileIO> fileIO = new FileIO<>(); - try { - return fileIO.readFileData(context,"routes.json").newInstance(); - } catch (IllegalAccessException | InstantiationException e) { - e.printStackTrace(); - } - return null; + FileIO> fileIO = new FileIO<>(); + + ArrayList res = fileIO.readFileData(context, "routes.json"); + return res == null ? new ArrayList<>() : res; + } } From 17d977bb17377919a81781c2789faddf9f0b6202 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Thu, 17 Dec 2020 13:41:20 +0100 Subject: [PATCH 3/5] fixed loading --- app/src/main/assets/coupons.json | 5 ++++- app/src/main/assets/locations.json | 3 +-- app/src/main/assets/routes.json | 13 ++++++++++++- .../java/com/a1/nextlocation/data/FileIO.java | 19 +++++++++++++++++-- .../nextlocation/fragments/HomeFragment.java | 7 +++++-- .../recyclerview/CouponLoader.java | 11 +++++++++-- .../recyclerview/LocationLoader.java | 8 +++++--- .../recyclerview/RouteLoader.java | 7 ++++--- 8 files changed, 57 insertions(+), 16 deletions(-) diff --git a/app/src/main/assets/coupons.json b/app/src/main/assets/coupons.json index c44dc44..39a85db 100644 --- a/app/src/main/assets/coupons.json +++ b/app/src/main/assets/coupons.json @@ -1,3 +1,6 @@ [ - + { + "code": "2345", + "reward": "fdasfasdf" + } ] \ No newline at end of file diff --git a/app/src/main/assets/locations.json b/app/src/main/assets/locations.json index bebe62d..88cec3e 100644 --- a/app/src/main/assets/locations.json +++ b/app/src/main/assets/locations.json @@ -2,7 +2,6 @@ { "name": "kees kroket", "coordinates": "2.4654645,6.2342323", - "description": "lekkere patatjes", - "imageUrl": "R.id.yeet" + "description": "lekkere patatjes" } ] \ No newline at end of file diff --git a/app/src/main/assets/routes.json b/app/src/main/assets/routes.json index c44dc44..9c84f63 100644 --- a/app/src/main/assets/routes.json +++ b/app/src/main/assets/routes.json @@ -1,3 +1,14 @@ [ - + { + "name": "rondje stad", + "locations": [ + { + "name": "kees kroket", + "coordinates": "2.4654645,6.2342323", + "description": "lekkere patatjes" + } + ], + "totalDistance": 2.3434, + "totalTime": 342342 + } ] \ No newline at end of file diff --git a/app/src/main/java/com/a1/nextlocation/data/FileIO.java b/app/src/main/java/com/a1/nextlocation/data/FileIO.java index 03ad794..a47f76e 100644 --- a/app/src/main/java/com/a1/nextlocation/data/FileIO.java +++ b/app/src/main/java/com/a1/nextlocation/data/FileIO.java @@ -7,10 +7,12 @@ import android.util.Log; import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; +import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.lang.reflect.Type; import java.nio.file.Files; import java.nio.file.Paths; @@ -18,16 +20,29 @@ public class FileIO { private final String TAG = FileIO.class.getCanonicalName(); - public T readFileData(Context context, String fileName) { + public T readFileData(Context context, String fileName, Type typeOf) { Gson gson = new Gson(); AssetManager am = context.getAssets(); T res = null; + StringBuilder sb = new StringBuilder(); try { InputStream is = am.open(fileName); InputStreamReader inputStreamReader = new InputStreamReader(is); - res = gson.fromJson(inputStreamReader,new TypeToken(){}.getType()); + BufferedReader reader = new BufferedReader(inputStreamReader); + String line; + while ((line = reader.readLine())!= null) { + sb.append(line); + } + + + Log.d(TAG, "readFileData: got string: " + sb.toString()); + res = gson.fromJson(sb.toString(),typeOf); Log.d(TAG, "readFileData: got object: " + res); + reader.close(); + inputStreamReader.close(); + is.close(); + } catch (IOException e) { Log.d(TAG, "readFileData: exception! " + e.getLocalizedMessage()); e.printStackTrace(); diff --git a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java index 326f020..0b7a629 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java @@ -20,8 +20,10 @@ import androidx.core.content.ContextCompat; import androidx.fragment.app.Fragment; import com.a1.nextlocation.R; +import com.a1.nextlocation.data.Route; import com.a1.nextlocation.recyclerview.CouponListManager; import com.a1.nextlocation.recyclerview.LocationListManager; +import com.a1.nextlocation.recyclerview.RouteListManager; import org.osmdroid.api.IMapController; import org.osmdroid.config.Configuration; @@ -114,8 +116,9 @@ public class HomeFragment extends Fragment { } - LocationListManager locationListManager = new LocationListManager(requireContext()); - locationListManager.load(); + CouponListManager couponListManager = new CouponListManager(requireContext()); + couponListManager.load(); + Log.d(TAG, "initMap: " + couponListManager.getCoupon(0).getCode()); } private void requestPermissionsIfNecessary(String... permissions) { diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java b/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java index f40fd5f..3cfcf13 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/CouponLoader.java @@ -1,25 +1,32 @@ package com.a1.nextlocation.recyclerview; import android.content.Context; +import android.util.Log; import com.a1.nextlocation.data.Coupon; import com.a1.nextlocation.data.FileIO; 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 CouponLoader implements Loader> { private final Context context; + private final String TAG = CouponLoader.class.getCanonicalName(); public CouponLoader(Context context) { this.context = context; } @Override - public List load() { + public ArrayList load() { FileIO> fileIO = new FileIO<>(); - ArrayList res = fileIO.readFileData(context, "coupons.json"); + ArrayList res = fileIO.readFileData(context, "coupons.json",new TypeToken>(){}.getType()); + Log.d(TAG, "load: " + res); + return res == null ? new ArrayList<>() : res; + } } diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java index fd570bb..f56d8fa 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationLoader.java @@ -4,8 +4,10 @@ import android.content.Context; import com.a1.nextlocation.data.FileIO; 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> { @@ -16,11 +18,11 @@ public class LocationLoader implements Loader> { } @Override - public List load() { + public ArrayList load() { FileIO> fileIO = new FileIO<>(); - ArrayList res = fileIO.readFileData(context, "locations.json"); - return res == null ? new ArrayList<>() : res; + ArrayList res = fileIO.readFileData(context,"locations.json",new TypeToken>(){}.getType()); + return res == null ? new ArrayList<>() : res; } } diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java index 5b5956f..df65664 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteLoader.java @@ -5,8 +5,10 @@ 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> { @@ -17,11 +19,10 @@ public class RouteLoader implements Loader> { } @Override - public List load() { + public ArrayList load() { FileIO> fileIO = new FileIO<>(); - - ArrayList res = fileIO.readFileData(context, "routes.json"); + ArrayList res = fileIO.readFileData(context, "routes.json",new TypeToken>(){}.getType()); return res == null ? new ArrayList<>() : res; } From 74fb4440ed7da165fa0ae9ee0734eba5e70448b7 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Thu, 17 Dec 2020 13:51:45 +0100 Subject: [PATCH 4/5] made listmanagers enums --- app/src/main/assets/locations.json | 5 +++++ app/src/main/java/com/a1/nextlocation/MainActivity.java | 7 +++++++ .../java/com/a1/nextlocation/fragments/HomeFragment.java | 7 +++---- .../a1/nextlocation/recyclerview/CouponListManager.java | 7 +++++-- .../a1/nextlocation/recyclerview/LocationListManager.java | 8 +++++--- .../a1/nextlocation/recyclerview/RouteListManager.java | 8 ++++++-- 6 files changed, 31 insertions(+), 11 deletions(-) diff --git a/app/src/main/assets/locations.json b/app/src/main/assets/locations.json index 88cec3e..3a2a3c2 100644 --- a/app/src/main/assets/locations.json +++ b/app/src/main/assets/locations.json @@ -3,5 +3,10 @@ "name": "kees kroket", "coordinates": "2.4654645,6.2342323", "description": "lekkere patatjes" + }, + { + "name" : "locatie2", + "coordinates": "3.65656,9.564564", + "description": "locatie 2" } ] \ No newline at end of file diff --git a/app/src/main/java/com/a1/nextlocation/MainActivity.java b/app/src/main/java/com/a1/nextlocation/MainActivity.java index ea457cf..983797c 100644 --- a/app/src/main/java/com/a1/nextlocation/MainActivity.java +++ b/app/src/main/java/com/a1/nextlocation/MainActivity.java @@ -13,6 +13,9 @@ import com.a1.nextlocation.fragments.HomeFragment; import com.a1.nextlocation.fragments.RouteFragment; import com.a1.nextlocation.fragments.SettingsFragment; 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; public class MainActivity extends AppCompatActivity { @@ -28,6 +31,10 @@ public class MainActivity extends AppCompatActivity { BottomNavigationView bottomNav = findViewById(R.id.navbar); 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(); } diff --git a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java index 0b7a629..b012d79 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java @@ -100,6 +100,9 @@ public class HomeFragment extends Fragment { // add location manager and set the start point LocationManager locationManager = (LocationManager) requireActivity().getSystemService(Context.LOCATION_SERVICE); + LocationListManager.INSTANCE.load(); + + try { Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER); 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) { ArrayList permissionsToRequest = new ArrayList<>(); diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/CouponListManager.java b/app/src/main/java/com/a1/nextlocation/recyclerview/CouponListManager.java index 72e7c65..b99f153 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/CouponListManager.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/CouponListManager.java @@ -4,15 +4,18 @@ import android.content.Context; import com.a1.nextlocation.data.Coupon; +import java.util.ArrayList; import java.util.List; -public class CouponListManager { +public enum CouponListManager { + INSTANCE; private List couponList; private Context context; - public CouponListManager(Context context){ + public void setContext(Context context) { this.context = context; + this.couponList = new ArrayList<>(); } public List getCouponList() { diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationListManager.java b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationListManager.java index 7ae7c43..9313e36 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/LocationListManager.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/LocationListManager.java @@ -4,16 +4,18 @@ import android.content.Context; import com.a1.nextlocation.data.Location; +import java.util.ArrayList; import java.util.List; -public class LocationListManager { +public enum LocationListManager { + INSTANCE; private List locationList; private Context context; - public LocationListManager(Context context){ + public void setContext(Context context) { this.context = context; - + this.locationList = new ArrayList<>(); } public List getLocationList() { diff --git a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java index b8c4a37..f72fcbe 100644 --- a/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java +++ b/app/src/main/java/com/a1/nextlocation/recyclerview/RouteListManager.java @@ -4,17 +4,21 @@ import android.content.Context; import com.a1.nextlocation.data.Route; +import java.util.ArrayList; import java.util.List; -public class RouteListManager{ +public enum RouteListManager{ + INSTANCE; private List routeList; private Context context; - public RouteListManager(Context context){ + public void setContext(Context context) { this.context = context; + this.routeList = new ArrayList<>(); } + public List getRouteList() { return routeList; } From 95a2e4e849e192ce9fac754a14c1dc7f3d646ec8 Mon Sep 17 00:00:00 2001 From: Sem van der Hoeven Date: Thu, 17 Dec 2020 13:53:00 +0100 Subject: [PATCH 5/5] made list managers load on mainactivity oncreate --- app/src/main/java/com/a1/nextlocation/MainActivity.java | 3 +++ .../main/java/com/a1/nextlocation/fragments/HomeFragment.java | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/a1/nextlocation/MainActivity.java b/app/src/main/java/com/a1/nextlocation/MainActivity.java index 983797c..9ba6645 100644 --- a/app/src/main/java/com/a1/nextlocation/MainActivity.java +++ b/app/src/main/java/com/a1/nextlocation/MainActivity.java @@ -32,8 +32,11 @@ public class MainActivity extends AppCompatActivity { bottomNav.setOnNavigationItemSelectedListener(navListener); LocationListManager.INSTANCE.setContext(this); + LocationListManager.INSTANCE.load(); CouponListManager.INSTANCE.setContext(this); + CouponListManager.INSTANCE.load(); RouteListManager.INSTANCE.setContext(this); + RouteListManager.INSTANCE.load(); getSupportFragmentManager().beginTransaction().replace(R.id.fragment_layout, new HomeFragment()).commit(); } diff --git a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java index b012d79..d6a06b4 100644 --- a/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java +++ b/app/src/main/java/com/a1/nextlocation/fragments/HomeFragment.java @@ -100,8 +100,6 @@ public class HomeFragment extends Fragment { // add location manager and set the start point LocationManager locationManager = (LocationManager) requireActivity().getSystemService(Context.LOCATION_SERVICE); - LocationListManager.INSTANCE.load(); - try { Location location = locationManager.getLastKnownLocation(LocationManager.GPS_PROVIDER);