Skip to content

Instantly share code, notes, and snippets.

@jezinka

jezinka/MainActivity.java Secret

Last active Aug 9, 2018
Embed
What would you like to do?
send
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>() {
@Override
public void onResponse(@NonNull Call<JsonObject> call, @NonNull Response<JsonObject> response) {
JsonObject body = response.body();
if (body != null) {
List<Sensor> sensors = createSensorsFromJsonObject(body);
adapter.updateResults(sensors);
}
}
@Override
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