@Override public void onPullUpToRefresh() { final int count = mAdapter.getCount(); final ParcelableStatus status = count > 0 ? mAdapter.getItem(count - 1) : null; if (status != null) { getStatuses(new long[] {status.account_id}, new long[] {status.status_id}, null); } }
@Override public final void onLoadFinished( final Loader<SynchronizedStateSavedList<ParcelableStatus, Long>> loader, final SynchronizedStateSavedList<ParcelableStatus, Long> data) { super.onLoadFinished(loader, data); if (!isLoaderUsed()) return; mAdapter.setData(data); onDataLoaded(loader, mAdapter); onRefreshComplete(); setProgressBarIndeterminateVisibility(false); }
public final void deleteStatus(final long status_id) { if (status_id <= 0 || mData == null) return; final ArrayList<ParcelableStatus> data_to_remove = new ArrayList<ParcelableStatus>(); for (final ParcelableStatus status : mData) { if (status.status_id == status_id || status.retweet_id > 0 && status.retweet_id == status_id) { data_to_remove.add(status); } } mData.removeAll(data_to_remove); mAdapter.setData(mData); }
public void onDataLoaded( final Loader<SynchronizedStateSavedList<ParcelableStatus, Long>> loader, final ParcelableStatusesAdapter adapter) { if (loader instanceof ParcelableStatusesLoader) { final Long last_viewed_id = ((ParcelableStatusesLoader) loader).getLastViewedId(); if (last_viewed_id != null && mPreferences.getBoolean(PREFERENCE_KEY_REMEMBER_POSITION, true)) { final int position = adapter.findItemPositionByStatusId(last_viewed_id); if (position > -1 && position < mListView.getCount()) { mListView.setSelection(position); } } } }
@Override public void onActivityCreated(final Bundle savedInstanceState) { if (savedInstanceState != null) { final List<ParcelableStatus> saved = savedInstanceState.getParcelableArrayList(INTENT_KEY_DATA); if (saved != null) { mData = new SynchronizedStateSavedList<ParcelableStatus, Long>(saved); } } mAdapter = new ParcelableStatusesAdapter(getActivity()); mAdapter.setData(mData); super.onActivityCreated(savedInstanceState); mListView = getListView(); mPreferences = getSharedPreferences(); }
@Override final long[] getOldestStatusIds() { final int last_idx = mAdapter.getCount() - 1; final long last_id = last_idx >= 0 ? mAdapter.getItem(last_idx).status_id : -1; return last_id > 0 ? new long[] {last_id} : null; }
@Override final long[] getNewestStatusIds() { final long last_id = mAdapter.getCount() > 0 ? mAdapter.getItem(0).status_id : -1; return last_id > 0 ? new long[] {last_id} : null; }