@Override public void onRefresh(PullToRefreshBase<ListView> refreshView) { if (PullToRefreshBase.Mode.PULL_FROM_START == refreshView.getCurrentMode()) { new RefreshMyFreeTask(MyFreeActivity.this, true) .executeOnExecutor(FinanceStocksApp.poor); } else if (PullToRefreshBase.Mode.PULL_FROM_END == refreshView.getCurrentMode()) { new LoadMyFreeTask(MyFreeActivity.this, true).executeOnExecutor(FinanceStocksApp.poor); } }
@Override public void onPullDownToRefresh(PullToRefreshBase refreshView) { String nowTime = DateUtils.formatDateTime( getActivity(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(nowTime); // nowTimeTV.setText(nowTime); String pathURL = URLs.JIJIANGKAISHI + "&" + URLs.PG_CUR + "=" + 1 + "&" + URLs.PG_SIZE + "=" + PAGE_SIZE_NUM; new RequestDataThreadForJJKS(pathURL).start(); // ToastUtil.showToast(getActivity(), "2222222222222" + nowTime); }
@Override public void onPullDownToRefresh(final PullToRefreshBase<ListView> refreshView) { // 获取消息 refreshView.postDelayed( new Runnable() { @Override public void run() { ListView mlist = lvPTR.getRefreshableView(); int preSum = mlist.getCount(); MessageEntity messageEntity = adapter.getTopMsgEntity(); if (messageEntity != null) { List<MessageEntity> historyMsgInfo = imService.getMessageManager().loadHistoryMsg(messageEntity, historyTimes); if (historyMsgInfo.size() > 0) { historyTimes++; adapter.loadHistoryList(historyMsgInfo); } } int afterSum = mlist.getCount(); mlist.setSelection(afterSum - preSum); /** 展示位置为这次消息的最末尾 */ // mlist.setSelection(size); // 展示顶部 // if (!(mlist).isStackFromBottom()) { // mlist.setStackFromBottom(true); // } // mlist.setStackFromBottom(false); refreshView.onRefreshComplete(); } }, 200); }
protected void onRefreshing(boolean doScroll) { super.onRefreshing(doScroll); if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } }
@Override protected void onScrollChanged(int l, int t, int oldl, int oldt) { super.onScrollChanged(l, t, oldl, oldt); if (null != mEmptyView && !mScrollEmptyView) { mEmptyView.scrollTo(-l, -t); } }
@Override protected void setRefreshingInternal(boolean doScroll) { super.setRefreshingInternal(doScroll); if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } }
@Override protected void onReset() { super.onReset(); if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } }
@Override protected void updateUIForMode() { super.updateUIForMode(); // Check Indicator Views consistent with new Mode if (getShowIndicatorInternal()) { addIndicatorViews(); } }
@Override public void onRefresh(PullToRefreshBase refreshView) { if (refreshView.isShownHeader()) { String nowTime = DateUtils.formatDateTime( getActivity(), System.currentTimeMillis(), DateUtils.FORMAT_SHOW_TIME | DateUtils.FORMAT_SHOW_DATE | DateUtils.FORMAT_ABBREV_ALL); refreshView.getLoadingLayoutProxy().setLastUpdatedLabel(nowTime); String pathURL = URLs.TEMAIZHONG + "&" + URLs.PG_CUR + "=" + 1 + "&" + URLs.PG_SIZE + "=" + PAGE_SIZE_NUM; new RequestDataThreadForTMZ(pathURL).start(); } else if (refreshView.isShownFooter()) { tmz_Cur_Num += 1; String pathURL = URLs.TEMAIZHONG + "&" + URLs.PG_CUR + "=" + tmz_Cur_Num + "&" + URLs.PG_SIZE + "=" + PAGE_SIZE_NUM; new RequestDataThreadForTMZ(pathURL).start(); } }
@Override protected void onReleaseToRefresh() { super.onReleaseToRefresh(); if (getShowIndicatorInternal()) { switch (getCurrentMode()) { case PULL_UP_TO_REFRESH: mIndicatorIvBottom.releaseToRefresh(); break; case PULL_DOWN_TO_REFRESH: mIndicatorIvTop.releaseToRefresh(); break; } } }
@Override void onPullToRefresh() { super.onPullToRefresh(); if (getShowIndicatorInternal()) { switch (getCurrentMode()) { case PULL_UP_TO_REFRESH: mIndicatorIvBottom.pullToRefresh(); break; case PULL_DOWN_TO_REFRESH: mIndicatorIvTop.pullToRefresh(); break; } } }
@Override protected void onReleaseToRefresh() { super.onReleaseToRefresh(); // if (getShowIndicatorInternal()) { // switch (getCurrentMode()) { // case PULL_FROM_END: // mIndicatorIvBottom.releaseToRefresh(); // break; // case PULL_FROM_START: // mIndicatorIvTop.releaseToRefresh(); // break; // default: // // NO-OP // break; // } // } }
@Override protected void onPullToRefresh() { super.onPullToRefresh(); if (getShowIndicatorInternal()) { switch (getCurrentMode()) { case PULL_FROM_END: // mIndicatorIvBottom.pullToRefresh(); break; case PULL_FROM_START: // mIndicatorIvTop.pullToRefresh(); break; default: // NO-OP break; } } }
@Override public synchronized boolean getNewItemsFromServer( Progress progress, PullToRefreshBase<?> refreshView, TaskHost priorityHost) { if (!isTaskCanExec(mBaseGetControllerDataTask)) { if (progress != null) { progress.finishProgress(); } if (progress == null && refreshView != null) { refreshView.onRefreshComplete(); } return false; } final Account tmp = getAccountAttached(); mBaseGetControllerDataTask = createGetDataTask(); mBaseGetControllerDataTask.setProgress(progress); mBaseGetControllerDataTask.setRefreshView(refreshView); mBaseGetControllerDataTask.setPriorityHost(priorityHost); mBaseGetControllerDataTask.setProcessNewItemsTaskHost( new ProcessNewItemsTaskHost<NotifyMessage>() { @Override public void onPostExecuteCacheChanged(List<NotifyMessage> list) { super.onPostExecuteCacheChanged(list); if (tmp != null) { getCache().deleteAll(); for (NotifyMessage notifyMsg : list) { notifyMsg.invalidate(); } asyncFlushCacheItem(list); getCache().clear(); if (!ListUtils.isEmpty(list)) { getCache().addAll(list); } cacheChanged(); } else { Log.w(getClass().getSimpleName(), ">>>#获取消息通知列表为空"); } markAllMessage(); } }); mBaseGetControllerDataTask.execute(); return true; }
@Override protected void onPtrRestoreInstanceState(Bundle savedInstanceState) { super.onPtrRestoreInstanceState(savedInstanceState); mRefreshableView.restoreState(savedInstanceState); }
@Override protected void onPtrSaveInstanceState(Bundle saveState) { super.onPtrSaveInstanceState(saveState); mRefreshableView.saveState(saveState); }
@Override public void onRefresh(PullToRefreshBase<WebView> refreshView) { refreshView.getRefreshableView().reload(); }
/** * Helper method for Overscrolling that encapsulates all of the necessary function. This is the * advanced version of the call. * * @param view - PullToRefreshView that is calling this. * @param deltaX - Change in X in pixels, passed through from from overScrollBy call * @param scrollX - Current X scroll value in pixels before applying deltaY, passed through from * from overScrollBy call * @param deltaY - Change in Y in pixels, passed through from from overScrollBy call * @param scrollY - Current Y scroll value in pixels before applying deltaY, passed through from * from overScrollBy call * @param scrollRange - Scroll Range of the View, specifically needed for ScrollView * @param fuzzyThreshold - Threshold for which the values how fuzzy we should treat the other * values. Needed for WebView as it doesn't always scroll back to it's edge. 0 = no fuzziness. * @param scaleFactor - Scale Factor for overscroll amount * @param isTouchEvent - true if this scroll operation is the result of a touch event, passed * through from from overScrollBy call */ public static void overScrollBy( final PullToRefreshBase<?> view, final int deltaX, final int scrollX, final int deltaY, final int scrollY, final int scrollRange, final int fuzzyThreshold, final float scaleFactor, final boolean isTouchEvent) { final int deltaValue, currentScrollValue, scrollValue; switch (view.getPullToRefreshScrollDirection()) { case PullToRefreshBase.HORIZONTAL_SCROLL: deltaValue = deltaX; scrollValue = scrollX; currentScrollValue = view.getScrollX(); break; case PullToRefreshBase.VERTICAL_SCROLL: default: deltaValue = deltaY; scrollValue = scrollY; currentScrollValue = view.getScrollY(); break; } // Check that OverScroll is enabled if (view.isPullToRefreshOverScrollEnabled()) { final Mode mode = view.getMode(); // Check that Pull-to-Refresh is enabled, and the event isn't from // touch if (mode.permitsPullToRefresh() && !isTouchEvent && deltaValue != 0) { final int newScrollValue = (deltaValue + scrollValue); if (PullToRefreshBase.DEBUG) { Log.d( LOG_TAG, "OverScroll. DeltaX: " + deltaX + ", ScrollX: " + scrollX + ", DeltaY: " + deltaY + ", ScrollY: " + scrollY + ", NewY: " + newScrollValue + ", ScrollRange: " + scrollRange + ", CurrentScroll: " + currentScrollValue); } if (newScrollValue < (0 - fuzzyThreshold)) { // Check the mode supports the overscroll direction, and // then move scroll if (mode.showHeaderLoadingLayout()) { view.setHeaderScroll((int) (scaleFactor * (currentScrollValue + newScrollValue))); } } else if (newScrollValue > (scrollRange + fuzzyThreshold)) { // Check the mode supports the overscroll direction, and // then move scroll if (mode.showFooterLoadingLayout()) { view.setHeaderScroll( (int) (scaleFactor * (currentScrollValue + newScrollValue - scrollRange))); } } else if (Math.abs(newScrollValue) <= fuzzyThreshold || Math.abs(newScrollValue - scrollRange) <= fuzzyThreshold) { // Means we've stopped overscrolling, so scroll back to 0 view.smoothScrollToLonger(0); } } } }