Skip to content

Commit

Permalink
Remove unused stuff from WeatherPagerAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
woheller69 committed Jul 22, 2022
1 parent 9b4608f commit c2062e1
Showing 1 changed file with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,9 @@ public class WeatherPagerAdapter extends FragmentStateAdapter implements IUpdate
private Context mContext;

private PFASQLiteHelper database;
long lastUpdateTime;

private List<CityToWatch> cities;
private List<CurrentWeatherData> currentWeathers;


private static int[] mDataSetTypes = {OVERVIEW, DETAILS, DAY, WEEK, CHART}; //TODO Make dynamic from Settings
private static int[] errorDataSetTypes = {ERROR};
Expand All @@ -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();
}

Expand Down Expand Up @@ -90,21 +89,10 @@ public static void refreshSingleData(Context context, Boolean asap, int cityId)
enqueueWork(context, UpdateDataService.class, 0, intent);
}

private CurrentWeatherData findWeatherFromID(List<CurrentWeatherData> 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
Expand Down

0 comments on commit c2062e1

Please sign in to comment.