public Cursor getCursor(int pagerPos) { EntryView view = mEntryViews.get(pagerPos); if (view != null) { return (Cursor) view.getTag(); } return null; }
public void onResume() { if (mEntriesIds != null) { EntryView view = mEntryViews.get(mCurrentPagerPos); if (view != null) { view.onResume(); } } }
public float getScrollPercentage() { EntryView view = mEntryViews.get(mCurrentPagerPos); if (view != null) { return view.getScrollPercentage(); } return 0; }
@Override public Object instantiateItem(ViewGroup container, int position) { EntryView view = new EntryView(getActivity()); mEntryViews.put(position, view); container.addView(view); view.setListener(EntryFragment.this); getLoaderManager().restartLoader(position, null, EntryFragment.this); return view; }
public void setUpdatedCursor(int pagerPos, Cursor newCursor) { EntryView view = mEntryViews.get(pagerPos); if (view != null) { Cursor previousUpdatedOne = (Cursor) view.getTag(R.id.updated_cursor); if (previousUpdatedOne != null) { previousUpdatedOne.close(); } view.setTag(newCursor); view.setTag(R.id.updated_cursor, newCursor); } }
public void displayEntry(int pagerPos, Cursor newCursor, boolean forceUpdate) { EntryView view = mEntryViews.get(pagerPos); if (view != null) { if (newCursor == null) { newCursor = (Cursor) view.getTag(); // get the old one } if (newCursor != null && newCursor.moveToFirst()) { String contentText = newCursor.getString(mMobilizedHtmlPos); if (contentText == null || (forceUpdate && !mPreferFullText)) { mPreferFullText = false; contentText = newCursor.getString(mAbstractPos); } else { mPreferFullText = true; } if (contentText == null) { contentText = ""; } String author = newCursor.getString(mAuthorPos); long timestamp = newCursor.getLong(mDatePos); String link = newCursor.getString(mLinkPos); String title = newCursor.getString(mTitlePos); String enclosure = newCursor.getString(mEnclosurePos); // Set the saved scroll position (not saved by the view itself due to the ViewPager) if (mScrollPercentage != 0 && pagerPos == mCurrentPagerPos) { view.setScrollPercentage(mScrollPercentage); mScrollPercentage = 0; } view.setHtml( mEntriesIds[pagerPos], title, link, contentText, enclosure, author, timestamp, mPreferFullText); view.setTag(newCursor); if (pagerPos == mCurrentPagerPos) { refreshUI(newCursor); } } } }