title: How can I update Activity/Fragment UI from Retrofit onResponse()?
body: <p>I want to use Retrofit 2.1.0 for my next Android project. I would like to use Design Pattern and therefore create separate classes for every REST call i.e  </p>
  
  <p>IBalanceService.java  </p>
  
  <pre><code>public Interface IBalanceService{
    @GET("users/{username}")
    void getUser(@Path("username") String username, Callback&lt;User&gt; cb);
  }  
  </code></pre>
  
  <p>BalanceRestClient.java  </p>
  
  <pre><code>public class BalanceRestClient{  
  
    String username = "Makarov";  
  
    Retrofit retrofit = new Retrofit.Builder()
                                 .baseUrl("http://hovermind.com")
                                 .addConverterFactory(GsonConverterFactory.create())
                                 .addCallAdapterFactory(rxAdapter)
                                 .build();  
  
    IBalanceService bs = retrofit.create(IBalanceService.class);
  
  
    Call&lt;User&gt; call = apiService.getUser(username);
    call.enqueue(new Callback&lt;User&gt;() {  
  
        @Override
        public void onResponse(Call&lt;User&gt; call, Response&lt;User&gt; response) {
  
            User user = response.body();  
  
            // update Activity/Fragment from here  
  
        }
  
        @Override
        public void onFailure(Call&lt;User&gt; call, Throwable t) {
          // Log error here since request failed
        }  
  
     });
  }
  </code></pre>
  
  <p>BalanceActivity.java  </p>
  
  <pre><code>public BalanceActivity extends Activity{
  
     // BalanceRestClient will update some UI elements 
  }  
  </code></pre>
  
  <p>How can I update UI in my Activity/fragment from onResponse()?  </p>
  
  <blockquote>
    <p>Additional Info:<br>
    min SDK : 19<br>
    target SDK : 23<br>
    Retrofit 2.1.0 with OkHttp and gson</p>
  </blockquote>