Skip to content

Instantly share code, notes, and snippets.

@jezinka

jezinka/MainActivity.java Secret

Created Feb 17, 2019
Embed
What would you like to do?
private void sendQueryForData() {
final Context mContext = this;
WeatherService weatherService = WeatherService.retrofit.create(WeatherService.class);
final Call<List<Sensor>> call = weatherService.loadData();
call.enqueue(new Callback<List<Sensor>>() {
@Override
public void onResponse(@NonNull Call<List<Sensor>> call, @NonNull Response<List<Sensor>> response) {
List<Sensor> sensors = response.body();
if (sensors != null) {
Timber.i("Server response with: %s", sensors);
adapter.updateResults(sensors);
notificationService.checkSensorsState(sensors, mContext);
}
swipeRefreshLayout.setRefreshing(false);
}
@Override
public void onFailure(@NonNull Call<List<Sensor>> call, @NonNull Throwable t) {
swipeRefreshLayout.setRefreshing(false);
Timber.e(t.getLocalizedMessage());
Toast.makeText(mContext, R.string.connection_error, Toast.LENGTH_LONG).show();
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment