Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jezinka
Created February 17, 2019 09:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jezinka/c97df0b2239662750d056e552948bfdd to your computer and use it in GitHub Desktop.
Save jezinka/c97df0b2239662750d056e552948bfdd to your computer and use it in GitHub Desktop.
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