From c2062e15560e8370a8c326ac88810449e64fb75f Mon Sep 17 00:00:00 2001 From: woheller69 Date: Fri, 22 Jul 2022 07:11:48 +0200 Subject: [PATCH] Remove unused stuff from WeatherPagerAdapter --- .../ui/viewPager/WeatherPagerAdapter.java | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java b/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java index d1e3da3..0d1edb2 100644 --- a/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java +++ b/app/src/main/java/org/woheller69/weather/ui/viewPager/WeatherPagerAdapter.java @@ -39,10 +39,9 @@ public class WeatherPagerAdapter extends FragmentStateAdapter implements IUpdate private Context mContext; private PFASQLiteHelper database; - long lastUpdateTime; private List cities; - private List currentWeathers; + private static int[] mDataSetTypes = {OVERVIEW, DETAILS, DAY, WEEK, CHART}; //TODO Make dynamic from Settings private static int[] errorDataSetTypes = {ERROR}; @@ -51,7 +50,7 @@ public WeatherPagerAdapter(Context context, @NonNull FragmentManager supportFrag super(supportFragmentManager,lifecycle); this.mContext = context; this.database = PFASQLiteHelper.getInstance(context); - this.currentWeathers = database.getAllCurrentWeathers(); + loadCities(); } @@ -90,21 +89,10 @@ public static void refreshSingleData(Context context, Boolean asap, int cityId) enqueueWork(context, UpdateDataService.class, 0, intent); } - private CurrentWeatherData findWeatherFromID(List currentWeathers, int ID) { - for (CurrentWeatherData weather : currentWeathers) { - if (weather.getCity_id() == ID) return weather; - } - return null; - } @Override public void processNewCurrentWeatherData(CurrentWeatherData data) { - lastUpdateTime = data.getTimestamp(); - int id = data.getCity_id(); - CurrentWeatherData old = findWeatherFromID(currentWeathers, id); - if (old != null) currentWeathers.remove(old); - currentWeathers.add(data); - notifyDataSetChanged(); + } @Override