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); } }
@Override public void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setHasOptionsMenu(true); mMoviesPresenter = new MoviesPresenter(); mMoviesPresenter.setView(this); spm = new SharedPreferenceManager(getActivity()); }
@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(); } } }
@Override public void onDestroy() { mMoviesPresenter.detachView(); super.onDestroy(); }