Skip to content

Instantly share code, notes, and snippets.

@jezinka
Last active August 9, 2018 16:53
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/a64c692986687c7a1969e82738268eb3 to your computer and use it in GitHub Desktop.
Save jezinka/a64c692986687c7a1969e82738268eb3 to your computer and use it in GitHub Desktop.
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