示例#1
0
 public void executeCallToMoviesApi() {
   SharedPreferences sharedPreferences =
       PreferenceManager.getDefaultSharedPreferences(getActivity());
   String orderStr =
       sharedPreferences.getString(
           getString(R.string.pref_order_key), getString(R.string.pref_order_default));
   if (orderStr.equals(getString(R.string.pref_popularity))) {
     mMoviesPresenter.loadMoviesFromApi(Constants.MOVIES_BY_POPULARITY);
   }
   if (orderStr.equals(getString(R.string.pref_rate))) {
     mMoviesPresenter.loadMoviesFromApi(Constants.MOVIES_BY_RATE);
   }
 }
示例#2
0
 @Override
 public void onCreate(@Nullable Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   setHasOptionsMenu(true);
   mMoviesPresenter = new MoviesPresenter();
   mMoviesPresenter.setView(this);
   spm = new SharedPreferenceManager(getActivity());
 }
示例#3
0
  @Override
  public void onViewCreated(View view, @Nullable Bundle savedInstanceState) {
    super.onViewCreated(view, savedInstanceState);
    ButterKnife.bind(this, view);
    setUpToolBar();
    setUpGridView();
    if (savedInstanceState != null) {
      mRotation = true;
      ArrayList<Response.Movie> tempList = new ArrayList<Response.Movie>();
      tempList = savedInstanceState.getParcelableArrayList("mListMovies");
      renderMovies(tempList);

    } else {
      if (!mFavorite) {
        executeCallToMoviesApi();
      } else {
        mMoviesPresenter.onLoadFavorites();
      }
    }
  }
示例#4
0
 @Override
 public void onDestroy() {
   mMoviesPresenter.detachView();
   super.onDestroy();
 }