private void reQueryLocal() { try { String tag = getArguments().getString(K.KEY_TAG.name()); Cursor cursor = mActivity .getContentResolver() .query( SchemaPosts.CONTENT_URI, null, SchemaPosts.COLUMN_SRC_SEARCH + "=?", new String[] {tag}, BaseColumns._ID + " DESC"); if (cursor.getCount() > 0) { int beforeIdx = mLayoutManager.findFirstVisibleItemPosition(); mViewAdapter.changeCursor(cursor); mViewAdapter.notifyDataSetChanged(); } else { cursor.close(); } } catch (Exception e) { // muted; } }
private void setupRecyclerView() { mRecyclerView.setLayoutManager(mLayoutManager); mRecyclerView.setHasFixedSize(true); String tag = getArguments().getString(K.KEY_TAG.name()); Cursor cursor = mActivity .getContentResolver() .query( SchemaPosts.CONTENT_URI, null, SchemaPosts.COLUMN_SRC_SEARCH + "=?", new String[] {tag}, BaseColumns._ID + " DESC"); if (cursor.moveToFirst()) { mViewAdapter = new PostCursorRecyclerViewAdapter(mActivity, cursor); } else { if (cursor != null && !cursor.isClosed()) { cursor.close(); } mViewAdapter = new PostCursorRecyclerViewAdapter(mActivity, null); } mViewAdapter.setHasStableIds(Boolean.TRUE); mRecyclerView.setAdapter(mViewAdapter); // scroll listerer on recycle view mRecyclerViewScrollListener = new EndlessRecyclerOnScrollListener( mLayoutManager, AppConstants.KV.LOAD_MORE.getIntValue()) { @Override public void onLoadMore(RecyclerView rv, int current_page) { mHandler.post( new Runnable() { @Override public void run() { callForRemotePosts(Boolean.TRUE); } }); } }; reInitializeScrollListener(mRecyclerView); // STYLE :: DIVIDER mRecyclerView.addItemDecoration(new SimpleDividerItemDecoration(mActivity)); }