title: How to structure my app using MVP with rxjava and retrofit to get data out of Observables?
body: <p>So I'll try to keep this question as to-the-point as possible, but it will involve code snippets that traverse an entire codepath.</p>
  
  <p>For context, I am fairly new and completely self-taught for Android dev, so please notify me of any clear misunderstandings/poor organization throughout. The main focus of the question is bug I am experiencing now, which is that, after a network request, the variable that was supposed to be set as a result of that network request is null, because the code moved forward before the network request completed.</p>
  
  <p>Here is my activity method. It is supposed to populate the <code>mFriends</code> variable with the result of <code>mUserPresenter.getUserList()</code>, which is (unfortunately) <code>null</code>:</p>
  
  <pre><code>/**
   * Grabs a list of friends, populates list with UserAdapter
   */
  @Override
  public void onResume(){
      super.onResume();
      mUserPresenter = new UserPresenter();
      mFriends = mUserPresenter.getUserList();
      if (mGridView.getAdapter() == null) {
          UserAdapter adapter = new UserAdapter(getActivity(), mFriends);
          mGridView.setAdapter(adapter);
      }
      else{
          ((UserAdapter)mGridView.getAdapter()).refill(mFriends);
      }
  
  }
  </code></pre>
  
  <p>Here is how I am structuring my <code>UserPresenter</code> method <code>getUserList</code>:</p>
  
  <pre><code>public List&lt;User&gt; getUserList()
  {
      ApiService.get_friends(this);
      return mUserList;
  }
  </code></pre>
  
  <p>The real magic happens in the <code>ApiService</code> class:</p>
  
  <pre><code>public static void get_friends(final UserPresenter userPresenter){
      ApiEndpointInterface apiService = prepareService();
      apiService.get_friends().
          observeOn(AndroidSchedulers.mainThread())
          .subscribe(
              new Action1&lt;List&lt;User&gt;&gt;()
              {
                 @Override
                 public void call(List&lt;User&gt; users) {
                    userPresenter.setList(users);
                 }
              }
          );
  }
  </code></pre>
  
  <p>My thinking was, that by calling <code>userPresenter.setList(users)</code> in <code>ApiService</code>, that would set <code>mUserList</code> to the response from the api request. However, instead, <code>mUserList == null</code> at the time that <code>getUserList</code> responds.</p>
  
  <p>Any ideas of how I can structure this?</p>