/** * Sets whether an indicator graphic should be displayed when the View is in * a state where a Pull-to-Refresh can happen. An example of this state is * when the Adapter View is scrolled to the top and the mode is set to * {@link Mode#PULL_FROM_START} * * @param showIndicator - true if the indicators should be shown. */ public void setShowIndicator(boolean showIndicator) { mShowIndicator = showIndicator; if (getShowIndicatorInternal()) { // If we're set to Show Indicator, add/update them addIndicatorViews(); } else { // If not, then remove then removeIndicatorViews(); } }
private void removeIndicatorViews() { if (null != mIndicatorIvTop) { getRefreshableViewWrapper().removeView(mIndicatorIvTop); mIndicatorIvTop = null; } if (null != mIndicatorIvBottom) { getRefreshableViewWrapper().removeView(mIndicatorIvBottom); mIndicatorIvBottom = null; } }
@Override protected void onReset() { super.onReset(); if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } }
private void addIndicatorViews() { Mode mode = getMode(); FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); if (mode.showHeaderLoadingLayout() && null == mIndicatorIvTop) { // If the mode can pull down, and we don't have one set already mIndicatorIvTop = new IndicatorLayout(getContext(), Mode.PULL_FROM_START); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.TOP | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvTop, params); } else if (!mode.showHeaderLoadingLayout() && null != mIndicatorIvTop) { // If we can't pull down, but have a View then remove it refreshableViewWrapper.removeView(mIndicatorIvTop); mIndicatorIvTop = null; } if (mode.showFooterLoadingLayout() && null == mIndicatorIvBottom) { // If the mode can pull down, and we don't have one set already mIndicatorIvBottom = new IndicatorLayout(getContext(), Mode.PULL_FROM_END); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.BOTTOM | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvBottom, params); } else if (!mode.showFooterLoadingLayout() && null != mIndicatorIvBottom) { // If we can't pull down, but have a View then remove it refreshableViewWrapper.removeView(mIndicatorIvBottom); mIndicatorIvBottom = null; } }
@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; } } }
FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams()); if (null != lp) { refreshableViewWrapper.addView(newEmptyView, lp);
@Override protected LoadingLayoutProxy createLoadingLayoutProxy(final boolean includeStart, final boolean includeEnd) { LoadingLayoutProxy proxy = super.createLoadingLayoutProxy(includeStart, includeEnd); if (mListViewExtrasEnabled) { final Mode mode = getMode(); if (includeStart && mode.showHeaderLoadingLayout()) { proxy.addLayout(mHeaderLoadingView); } if (includeEnd && mode.showFooterLoadingLayout()) { proxy.addLayout(mFooterLoadingView); } } return proxy; }
@Override protected void handleStyledAttributes(TypedArray a) { super.handleStyledAttributes(a); mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true); if (mListViewExtrasEnabled) { final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL); // Create Loading Views ready for use later FrameLayout frame = new FrameLayout(getContext()); mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a); mHeaderLoadingView.setVisibility(View.GONE); frame.addView(mHeaderLoadingView, lp); mRefreshableView.addHeaderView(frame, null, false); mLvFooterLoadingFrame = new FrameLayout(getContext()); mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a); mFooterLoadingView.setVisibility(View.GONE); mLvFooterLoadingFrame.addView(mFooterLoadingView, lp); /** * If the value for Scrolling While Refreshing hasn't been * explicitly set via XML, enable Scrolling While Refreshing. */ if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) { setScrollingWhileRefreshingEnabled(true); } } }
private void addIndicatorViews() { Mode mode = getMode(); FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); if (mode.showHeaderLoadingLayout() && null == mIndicatorIvTop) { // If the mode can pull down, and we don't have one set already mIndicatorIvTop = new IndicatorLayout(getContext(), Mode.PULL_FROM_START); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.TOP | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvTop, params); } else if (!mode.showHeaderLoadingLayout() && null != mIndicatorIvTop) { // If we can't pull down, but have a View then remove it refreshableViewWrapper.removeView(mIndicatorIvTop); mIndicatorIvTop = null; } if (mode.showFooterLoadingLayout() && null == mIndicatorIvBottom) { // If the mode can pull down, and we don't have one set already mIndicatorIvBottom = new IndicatorLayout(getContext(), Mode.PULL_FROM_END); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.BOTTOM | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvBottom, params); } else if (!mode.showFooterLoadingLayout() && null != mIndicatorIvBottom) { // If we can't pull down, but have a View then remove it refreshableViewWrapper.removeView(mIndicatorIvBottom); mIndicatorIvBottom = null; } }
@Override protected void onReset() { super.onReset(); if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } }
@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; } } }
FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams()); if (null != lp) { refreshableViewWrapper.addView(newEmptyView, lp);
@Override protected LoadingLayoutProxy createLoadingLayoutProxy(final boolean includeStart, final boolean includeEnd) { LoadingLayoutProxy proxy = super.createLoadingLayoutProxy(includeStart, includeEnd); if (mListViewExtrasEnabled) { final Mode mode = getMode(); if (includeStart && mode.showHeaderLoadingLayout()) { proxy.addLayout(mHeaderLoadingView); } if (includeEnd && mode.showFooterLoadingLayout()) { proxy.addLayout(mFooterLoadingView); } } return proxy; }
@Override protected void handleStyledAttributes(TypedArray a) { super.handleStyledAttributes(a); mListViewExtrasEnabled = a.getBoolean(R.styleable.PullToRefresh_ptrListViewExtrasEnabled, true); if (mListViewExtrasEnabled) { final FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(FrameLayout.LayoutParams.MATCH_PARENT, FrameLayout.LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL); // Create Loading Views ready for use later FrameLayout frame = new FrameLayout(getContext()); mHeaderLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_START, a); mHeaderLoadingView.setVisibility(View.GONE); frame.addView(mHeaderLoadingView, lp); mRefreshableView.addHeaderView(frame, null, false); mLvFooterLoadingFrame = new FrameLayout(getContext()); mFooterLoadingView = createLoadingLayout(getContext(), Mode.PULL_FROM_END, a); mFooterLoadingView.setVisibility(View.GONE); mLvFooterLoadingFrame.addView(mFooterLoadingView, lp); /** * If the value for Scrolling While Refreshing hasn't been * explicitly set via XML, enable Scrolling While Refreshing. */ if (!a.hasValue(R.styleable.PullToRefresh_ptrScrollingWhileRefreshingEnabled)) { setScrollingWhileRefreshingEnabled(true); } } }
/** * Sets whether an indicator graphic should be displayed when the View is in * a state where a Pull-to-Refresh can happen. An example of this state is * when the Adapter View is scrolled to the top and the mode is set to * {@link Mode#PULL_FROM_START} * * @param showIndicator - true if the indicators should be shown. */ public void setShowIndicator(boolean showIndicator) { mShowIndicator = showIndicator; if (getShowIndicatorInternal()) { // If we're set to Show Indicator, add/update them addIndicatorViews(); } else { // If not, then remove then removeIndicatorViews(); } }
private void addIndicatorViews() { Mode mode = getMode(); FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); if (mode.showHeaderLoadingLayout() && null == mIndicatorIvTop) { // If the mode can pull down, and we don't have one set already mIndicatorIvTop = new IndicatorLayout(getContext(), Mode.PULL_FROM_START); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.TOP | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvTop, params); } else if (!mode.showHeaderLoadingLayout() && null != mIndicatorIvTop) { // If we can't pull down, but have a View then remove it refreshableViewWrapper.removeView(mIndicatorIvTop); mIndicatorIvTop = null; } if (mode.showFooterLoadingLayout() && null == mIndicatorIvBottom) { // If the mode can pull down, and we don't have one set already mIndicatorIvBottom = new IndicatorLayout(getContext(), Mode.PULL_FROM_END); FrameLayout.LayoutParams params = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.WRAP_CONTENT); params.rightMargin = getResources().getDimensionPixelSize(R.dimen.indicator_right_padding); params.gravity = Gravity.BOTTOM | Gravity.RIGHT; refreshableViewWrapper.addView(mIndicatorIvBottom, params); } else if (!mode.showFooterLoadingLayout() && null != mIndicatorIvBottom) { // If we can't pull down, but have a View then remove it refreshableViewWrapper.removeView(mIndicatorIvBottom); mIndicatorIvBottom = null; } }
protected void onRefreshing(boolean doScroll) { super.onRefreshing(doScroll); if (getShowIndicatorInternal()) { updateIndicatorViewsVisibility(); } }
@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; } } }
FrameLayout refreshableViewWrapper = getRefreshableViewWrapper(); FrameLayout.LayoutParams lp = convertEmptyViewLayoutParams(newEmptyView.getLayoutParams()); if (null != lp) { refreshableViewWrapper.addView(newEmptyView, lp);
private void removeIndicatorViews() { if (null != mIndicatorIvTop) { getRefreshableViewWrapper().removeView(mIndicatorIvTop); mIndicatorIvTop = null; } if (null != mIndicatorIvBottom) { getRefreshableViewWrapper().removeView(mIndicatorIvBottom); mIndicatorIvBottom = null; } }