I'm making a network request inside a Repository class in my Android app. I'm doing this for learning purposes, so I'm trying to understand, without using RXJava, how would I update the UI all the way from my Repository?
The trail of calls goes like so MainActivity -> Presenter -> Interactor -> Repository -> Network
And here is my code in the repository
WeatherRepository {
WeatherNetwork network = new WeatherNetwork();
public CurrentWeather getCurrentWeather(float lat, float lng) {
network.getDailyWeather(lat, lng, new Callback() {
@Override
public void onFailure(Request request, IOException e) {
}
@Override
public void onResponse(Response response) throws IOException {
try{
String jsonData = response.body().string();
if (response.isSuccessful()) {
CurrentWeather currentWeather = getCurrentWeatherData(jsonData);
}
} catch(JSONException e) {
Log.d("DWPresen" + " JSONEXCEPTION", e.getMessage());
} catch(IOException e){
Log.d("DWPresent" + " IOEXCEPTION", e.getMessage());
}
}
});
}
}