title: Refreshing livedata with Retrofit request response
body: <p>I have a simple app, which shows a list of movies. When a user clicks a button it should refresh the list, which means to go to Retrofit again and fetch the new list.
  The problem is, that this refresh doesn't work. It only fetches the list once, when I open the app. </p>
  
  <pre><code>public class MoviesViewModel extends AndroidViewModel {
      private MutableLiveData&lt;Resource&lt;List&lt;Movie&gt;&gt;&gt; mLastdMovieListObservable;
      private Repository mRepository;
  
      public MoviesViewModel(Application application) {
          super(application);
          mRepository = new Repository();
      }
  
      public LiveData&lt;Resource&lt;List&lt;Movie&gt;&gt;&gt; getMovieListLiveData() {
          if (mLastdMovieListObservable == null) {
              mLastdMovieListObservable = mRepository.getMovieList();
          }
          return mLastdMovieListObservable;
      }
  }
  </code></pre>
  
  <p>and the Repository :</p>
  
  <pre><code>public MutableLiveData&lt;Resource&lt;List&lt;Movie&gt;&gt;&gt; getMovieList() {
      final MutableLiveData&lt;Resource&lt;List&lt;Movie&gt;&gt;&gt; data = new MutableLiveData&lt;&gt;();
      data.setValue(Resource.loading(null));
  
      mInterface.getMovies(.....).enqueue(new Callback&lt;MovieListResponse&gt;() {
          @Override
          public void onResponse(Call&lt;MovieListResponse&gt; call, Response&lt;MovieListResponse&gt; response) {
              if (response.isSuccessful()) {
                  data.postValue(Resource.success(response.body().getResult()));
              } else {
                  data.postValue(Resource.error(response.message(), null));
              }
          }
          @Override
          public void onFailure(Call&lt;MovieListResponse&gt; call, Throwable t) {
              data.postValue(Resource.error(t.getMessage(), null));
          }
      });
  
      return data;
  }   
  </code></pre>
  
  <p>Then in the fragment it's just :</p>
  
  <pre><code>mMoviesViewModel.getMovieListLiveData().observe(this, moviesResource -&gt; {
      if (moviesResource.status == Status.SUCCESS) {
         .....
         .....
  </code></pre>
  
  <p>then the button click part, when I need to fetch the list again, I'm not sure how to implement it. 
  Anything I tried didn't work. the Repository returned the data as null right away. </p>