private void resetUILoadingState() { Object _state = mRecyclerView.getTag(); // prevent unnecessary traffic if (_state != null && (_state instanceof Utils.State)) { ((Utils.State) _state).setPendingLoadMore(false); } else { Utils.State state = new Utils.State(); state.setPendingLoadMore(false); _state = state; } mRecyclerView.setTag(_state); reInitializeScrollListener(mRecyclerView); }
private void callForRemotePosts(boolean isPaginating) { String tag = getArguments().getString(K.KEY_TAG.name()); // construct context from preferences if any? Bundle iArgs = new Bundle(); if (isPaginating) { Object _state = mRecyclerView.getTag(); // prevent unnecessary traffic if (_state != null && (_state instanceof Utils.State)) { if (((Utils.State) _state).isPendingLoadMore()) { return; } } Utils.State state = new Utils.State(); state.setPendingLoadMore(true); mRecyclerView.setTag(state); // Utils.PreferencesManager pref = Utils.PreferencesManager.getInstance(); // Map<String, String> entries = // pref.getValueAsMap(AppConstants.API.PREF_POSTS_LIST_USER.getValue()); // for (Map.Entry<String, String> e : entries.entrySet()) { // iArgs.putString(e.getKey(), e.getValue()); // } } // context iArgs.putString(KEY_BY.getValue(), KEY_POSTS_SEARCH.getValue()); iArgs.putString(KEY_KEY.getValue(), tag); // call for intent Intent mServiceIntent = new Intent(mActivity, PostsPullService.class); mServiceIntent.putExtras(iArgs); mActivity.startService(mServiceIntent); }