This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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