Skip to content

Instantly share code, notes, and snippets.

Last active Aug 9, 2018
What would you like to do?
private void sendQueryForData() {
final Context mContext = this;
WeatherService weatherService = WeatherService.retrofit.create(WeatherService.class);
final Call<JsonObject> call = weatherService.loadData();
call.enqueue(new Callback<JsonObject>() {
public void onResponse(@NonNull Call<JsonObject> call, @NonNull Response<JsonObject> response) {
JsonObject body = response.body();
if (body != null) {
List<Sensor> sensors = createSensorsFromJsonObject(body);
public void onFailure(@NonNull Call<JsonObject> call, @NonNull Throwable t) {
Log.e("LOAD_DATA", 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