use of de.bahnhoefe.deutschlands.bahnhofsfotos.rsapi.RSAPIClient in project RSAndroidApp by RailwayStations.
the class BaseApplication method onCreate.
@Override
public void onCreate() {
super.onCreate();
dbAdapter = new DbAdapter(this);
dbAdapter.open();
preferences = getSharedPreferences(PREF_FILE, MODE_PRIVATE);
// migrate photo owner preference to boolean
final Object photoOwner = preferences.getAll().get(getString(R.string.PHOTO_OWNER));
if (photoOwner instanceof String && "YES".equals(photoOwner)) {
setPhotoOwner(true);
}
rsapiClient = new RSAPIClient(getApiUrl(), getEmail(), getPassword());
}
use of de.bahnhoefe.deutschlands.bahnhofsfotos.rsapi.RSAPIClient in project RSAndroidApp by RailwayStations.
the class HighScoreActivity method loadHighScore.
private void loadHighScore(final BaseApplication baseApplication, final Country selectedCountry) {
final RSAPIClient rsapi = baseApplication.getRsapiClient();
final Call<HighScore> highScoreCall = selectedCountry.getCode().isEmpty() ? rsapi.getHighScore() : rsapi.getHighScore(selectedCountry.getCode());
highScoreCall.enqueue(new Callback<>() {
@Override
public void onResponse(@NonNull final Call<HighScore> call, @NonNull final Response<HighScore> response) {
if (response.isSuccessful()) {
adapter = new HighScoreAdapter(HighScoreActivity.this, response.body().getItems());
binding.highscoreList.setAdapter(adapter);
binding.highscoreList.setOnItemClickListener((adapter, v, position, arg3) -> {
final HighScoreItem highScoreItem = (HighScoreItem) adapter.getItemAtPosition(position);
final StationFilter stationFilter = baseApplication.getStationFilter();
stationFilter.setNickname(highScoreItem.getName());
baseApplication.setStationFilter(stationFilter);
final Intent intent = new Intent(HighScoreActivity.this, MapsActivity.class);
startActivity(intent);
});
}
}
@Override
public void onFailure(@NonNull final Call<HighScore> call, @NonNull final Throwable t) {
Log.e(TAG, "Error loading highscore", t);
Toast.makeText(getBaseContext(), getString(R.string.error_loading_highscore) + t.getMessage(), Toast.LENGTH_LONG).show();
}
});
}
Aggregations