android.support.v4.view.NestedScrollingParentHelper Java Examples

The following examples show how to use android.support.v4.view.NestedScrollingParentHelper. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ELinkageScrollLayout.java    From ELinkageScroll with Apache License 2.0 6 votes vote down vote up
public ELinkageScrollLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mParentHelper = new NestedScrollingParentHelper(this);
    mScroller = new Scroller(getContext());
    mLocScroller = new Scroller(getContext());
    mVelocityScroller = new Scroller(getContext());
    mPosIndicator = new PosIndicator(false);
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mMaximumVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = viewConfiguration.getScaledMinimumFlingVelocity();
    mPosIndicator.setTouchSlop(viewConfiguration.getScaledTouchSlop());

    // 确保联动容器调用onDraw()方法
    setWillNotDraw(false);
    // enable vertical scrollbar
    setVerticalScrollBarEnabled(true);
}
 
Example #2
Source File: WXSwipeLayout.java    From ucar-weex-core with Apache License 2.0 6 votes vote down vote up
private void initAttrs(Context context, AttributeSet attrs) {

    if (getChildCount() > 1) {
      throw new RuntimeException("WXSwipeLayout should not have more than one child");
    }

    parentHelper = new NestedScrollingParentHelper(this);

    if (isInEditMode() && attrs == null) {
      return;
    }

    mRefreshViewBgColor = Color.TRANSPARENT;
    mProgressBgColor = Color.TRANSPARENT;
    mProgressColor = Color.RED;
  }
 
Example #3
Source File: AbsRefreshLayout.java    From NestRefreshLayout with MIT License 6 votes vote down vote up
/**
 * @param context
 * @param attrs
 * @param defStyleAttr
 */
private void init(Context context, AttributeSet attrs, int defStyleAttr) {
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    mScroller = new Scroller(context, new DecelerateInterpolator());
    TypedArray a = context.obtainStyledAttributes(attrs,
            R.styleable.AbsRefreshLayout, defStyleAttr, 0);
    final int N = a.getIndexCount();
    int resFooter = R.layout.layout_loadmore;
    for (int i = 0; i < N; i++) {
        int attr = a.getIndex(i);
        if (attr == R.styleable.AbsRefreshLayout_footerNestLayout) {
            resFooter = a.getResourceId(attr, resFooter);
            break;
        }
    }
    a.recycle();
    /**
     * Convert values in dp to values in px;
     */
    setFooterView(inflate(context, resFooter, null));
}
 
Example #4
Source File: NestedScrollView.java    From letv with Apache License 2.0 6 votes vote down vote up
public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.mTempRect = new Rect();
    this.mIsLayoutDirty = true;
    this.mIsLaidOut = false;
    this.mChildToScrollTo = null;
    this.mIsBeingDragged = false;
    this.mSmoothScrollingEnabled = true;
    this.mActivePointerId = -1;
    this.mScrollOffset = new int[2];
    this.mScrollConsumed = new int[2];
    initScrollView();
    TypedArray a = context.obtainStyledAttributes(attrs, SCROLLVIEW_STYLEABLE, defStyleAttr, 0);
    setFillViewport(a.getBoolean(0, false));
    a.recycle();
    this.mParentHelper = new NestedScrollingParentHelper(this);
    this.mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE);
}
 
Example #5
Source File: AbsRefreshLayout.java    From NestRefreshLayout with MIT License 6 votes vote down vote up
/**
 */
@SuppressWarnings("deprecation")
public AbsRefreshLayout(View listView) {
    this(listView.getContext());
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    mTargetView = listView;
    ViewGroup group = (ViewGroup) mTargetView.getParent();
    if (group != null) {
        LayoutParams params = mTargetView.getLayoutParams();
        int index = group.indexOfChild(listView);
        group.removeView(listView);
        group.addView(this, index, params);
    }
    mTargetView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.MATCH_PARENT));
    super.addView(mTargetView);
}
 
Example #6
Source File: WXSwipeLayout.java    From weex-uikit with MIT License 6 votes vote down vote up
private void initAttrs(Context context, AttributeSet attrs) {

    if (getChildCount() > 1) {
      throw new RuntimeException("WXSwipeLayout should not have more than one child");
    }

    parentHelper = new NestedScrollingParentHelper(this);

    if (isInEditMode() && attrs == null) {
      return;
    }

    mRefreshViewBgColor = Color.TRANSPARENT;
    mProgressBgColor = Color.TRANSPARENT;
    mProgressColor = Color.RED;
  }
 
Example #7
Source File: WXSwipeLayout.java    From weex with Apache License 2.0 6 votes vote down vote up
private void initAttrs(Context context, AttributeSet attrs) {

    if (getChildCount() > 1) {
      throw new RuntimeException("WXSwipeLayout should not have more than one child");
    }

    parentHelper = new NestedScrollingParentHelper(this);

    loadingViewHeight = dipToPx(context, REFRESH_VIEW_HEIGHT);
    refreshViewFlowHeight = loadingViewHeight * (float)1.5;

    if (isInEditMode() && attrs == null) {
      return;
    }

    mRefreshViewBgColor = Color.TRANSPARENT;
    mProgressBgColor = Color.TRANSPARENT;
    mProgressColor = Color.RED;
  }
 
Example #8
Source File: PullHeaderLayout.java    From FlyRefresh with MIT License 5 votes vote down vote up
public PullHeaderLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    int headerHeight = DEFAULT_HEIGHT;
    int headerExpandHeight = DEFAULT_EXPAND;
    int headerShrinkHeight = DEFAULT_SHRINK;

    if (attrs != null) {
        TypedArray arr = context.obtainStyledAttributes(attrs, R.styleable.PullHeaderLayout);
        headerHeight = arr.getDimensionPixelOffset(R.styleable.PullHeaderLayout_phl_header_height,
                DEFAULT_HEIGHT);
        headerExpandHeight = arr.getDimensionPixelOffset(R.styleable.PullHeaderLayout_phl_header_expand_height,
                DEFAULT_EXPAND);
        headerShrinkHeight = arr.getDimensionPixelOffset(R.styleable.PullHeaderLayout_phl_header_shrink_height,
                DEFAULT_SHRINK);

        mHeaderId = arr.getResourceId(R.styleable.PullHeaderLayout_phl_header, mHeaderId);
        mContentId = arr.getResourceId(R.styleable.PullHeaderLayout_phl_content, mContentId);

        mActionDrawable = arr.getDrawable(R.styleable.PullHeaderLayout_phl_action);

        arr.recycle();
    }

    mHeaderController = new HeaderController(headerHeight, headerExpandHeight, headerShrinkHeight);

    final ViewConfiguration conf = ViewConfiguration.get(getContext());

    mParentHelper = new NestedScrollingParentHelper(this);
    mChildHelper = new NestedScrollingChildHelper(this);

    setNestedScrollingEnabled(true);

    init();
}
 
Example #9
Source File: NestedFrameLayout.java    From ELinkageScroll with Apache License 2.0 5 votes vote down vote up
public NestedFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mChildHelper = new NestedScrollingChildHelper(this);
    mParentHelper = new NestedScrollingParentHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example #10
Source File: HeadViewFrameLayout.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
public HeadViewFrameLayout(Context context, AttributeSet attrs,
                           int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example #11
Source File: HeaderRefreshLayout.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
public HeaderRefreshLayout(Context context, AttributeSet attrs,
                           int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    header = new TouchCircleView(getContext());
    header.addLoadingListener(this);
    float density = context.getResources().getDisplayMetrics().density;
    addView(header, new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, (int) (density * 120)));
}
 
Example #12
Source File: QRefreshLayout.java    From RefreshLayout with Apache License 2.0 5 votes vote down vote up
private void initAttrs(Context context, AttributeSet attrs) {
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.QRefreshLayout);
    float resistance = typedArray.getFloat(R.styleable.QRefreshLayout_resistance, 0.65f);
    setResistance(resistance);
    typedArray.recycle();
    mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();
    mNestedChildHelper = new NestedScrollingChildHelper(this);
    mNestedParentHelper = new NestedScrollingParentHelper(this);
    mParentOffsetInWindow = new int[2];
}
 
Example #13
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 5 votes vote down vote up
/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(
            android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mCircleDiameter = (int) (CIRCLE_DIAMETER * metrics.density);

    createProgressView();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    // the absolute offset has to take into account that the circle starts at an offset
    mSpinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density);
    mTotalDragDistance = mSpinnerOffsetEnd;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);

    mOriginalOffsetTop = mCurrentTargetOffsetTop = -mCircleDiameter;
    moveToStart(1.0f);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();
}
 
Example #14
Source File: ISwipeRefreshLayout.java    From AndroidUiKit with Apache License 2.0 5 votes vote down vote up
/**
 * Constructor that is called when inflating ISwipeRefreshLayout from XML.
 *
 * @param context
 * @param attrs
 */
public ISwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();

    mMediumAnimationDuration = getResources().getInteger(
            android.R.integer.config_mediumAnimTime);

    setWillNotDraw(false);
    mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mRefreshViewHeight = (int) (DEFAULT_HEADER_HEIGHT * metrics.density);
    HEADER_VIEW_MIN_HEIGHT = mRefreshViewHeight;
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    mTotalDragDistance = (int) (DEFAULT_HEADER_TARGET * metrics.density);
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

    mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    a.recycle();

    //add default refreshview
    setRefreshHeaderView(new ClassicIRefreshHeaderView(getContext()));
}
 
Example #15
Source File: BottomSheet.java    From BottomSheet with Apache License 2.0 4 votes vote down vote up
public ContainerView(Context context) {
    super(context);
    nestedScrollingParentHelper = new NestedScrollingParentHelper(this);
}
 
Example #16
Source File: SHSwipeRefreshLayout.java    From SHSwipeRefreshLayout with MIT License 4 votes vote down vote up
private void initAttrs(Context context, AttributeSet attrs) {

        if (getChildCount() > 1) {
            throw new RuntimeException("WXSwipeLayout should not have more than one child");
        }

        parentHelper = new NestedScrollingParentHelper(this);

        guidanceViewHeight = dipToPx(context, GUIDANCE_VIEW_HEIGHT);
        guidanceViewFlowHeight = guidanceViewHeight * (float)1.5;

        if (isInEditMode() && attrs == null) {
            return;
        }

        int resId;
        TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SHSwipeRefreshLayout);
        Resources resources = context.getResources();

        //Indicator背景颜色
        resId = ta.getResourceId(R.styleable.SHSwipeRefreshLayout_guidance_view_bg_color, -1);
        if (resId == -1) {
            mGuidanceViewBgColor = ta.getColor(R.styleable.SHSwipeRefreshLayout_guidance_view_bg_color,
                    Color.WHITE);
        } else {
            mGuidanceViewBgColor = resources.getColor(resId);
        }

        //加载文字颜色
        resId = ta.getResourceId(R.styleable.SHSwipeRefreshLayout_guidance_text_color, -1);
        if (resId == -1) {
            mGuidanceViewTextColor = ta.getColor(R.styleable.SHSwipeRefreshLayout_guidance_text_color,
                    Color.BLACK);
        } else {
            mGuidanceViewTextColor = resources.getColor(resId);
        }

        //进度条背景颜色
        resId = ta.getResourceId(R.styleable.SHSwipeRefreshLayout_progress_bg_color, -1);
        if (resId == -1) {
            mProgressBgColor = ta.getColor(R.styleable.SHSwipeRefreshLayout_progress_bg_color,
                    Color.WHITE);
        } else {
            mProgressBgColor = resources.getColor(resId);
        }

        //进度条颜色
        resId = ta.getResourceId(R.styleable.SHSwipeRefreshLayout_progress_bar_color, -1);
        if (resId == -1) {
            mProgressColor = ta.getColor(R.styleable.SHSwipeRefreshLayout_progress_bar_color,
                    Color.RED);
        } else {
            mProgressColor = resources.getColor(resId);
        }

        //下拉刷新文字描述
        resId = ta.getResourceId(R.styleable.SHSwipeRefreshLayout_refresh_text, -1);
        if (resId == -1) {
            mRefreshDefaulText = ta.getString(R.styleable.SHSwipeRefreshLayout_refresh_text);
        } else {
            mRefreshDefaulText = resources.getString(resId);
        }

        //上拉加载文字描述
        resId = ta.getResourceId(R.styleable.SHSwipeRefreshLayout_load_text, -1);
        if (resId == -1) {
            mLoadDefaulText = ta.getString(R.styleable.SHSwipeRefreshLayout_load_text);
        } else {
            mLoadDefaulText = resources.getString(resId);
        }
    }
 
Example #17
Source File: MyFrameLayout.java    From AndroidUI with MIT License 4 votes vote down vote up
private void init(Context context)
{
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
}
 
Example #18
Source File: EventResolver.java    From PullRefreshView with Apache License 2.0 4 votes vote down vote up
public EventResolver(FlingLayout.FlingLayoutContext flingLayoutContext) {
    this.c = flingLayoutContext;
    mParentHelper = new NestedScrollingParentHelper(c.getFlingLayout());
    mChildHelper = new NestedScrollingChildHelper(c.getFlingLayout());
}
 
Example #19
Source File: SliderBox.java    From PullRefreshView with Apache License 2.0 4 votes vote down vote up
private void init() {
    mParentHelper = new NestedScrollingParentHelper(this);
    mChildHelper = new NestedScrollingChildHelper(this);
}
 
Example #20
Source File: BottomSheet.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ContainerView(Context context)
{
    super(context);
    nestedScrollingParentHelper = new NestedScrollingParentHelper(this);
}
 
Example #21
Source File: SmartRefreshLayout.java    From CollapsingRefresh with Apache License 2.0 4 votes vote down vote up
private void initView(Context context, AttributeSet attrs) {
	setClipToPadding(false);

	mScreenHeightPixels = context.getResources().getDisplayMetrics().heightPixels;
	mReboundInterpolator = new ViscousFluidInterpolator();
	mTouchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop();

	mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);
	mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);

	DensityUtil density = new DensityUtil();
	TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.SmartRefreshLayout);

	ViewCompat.setNestedScrollingEnabled(this, ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableNestedScrolling, false));
	mDragRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlDragRate, mDragRate);
	mHeaderMaxDragRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlHeaderMaxDragRate, mHeaderMaxDragRate);
	mFooterMaxDragRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlFooterMaxDragRate, mFooterMaxDragRate);
	mEnableRefresh = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableRefresh, mEnableRefresh);
	mReboundDuration = ta.getInt(R.styleable.SmartRefreshLayout_srlReboundDuration, mReboundDuration);
	mEnableLoadmore = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableLoadmore, mEnableLoadmore);
	mHeaderHeight = ta.getDimensionPixelOffset(R.styleable.SmartRefreshLayout_srlHeaderHeight, density.dip2px(100));
	mFooterHeight = ta.getDimensionPixelOffset(R.styleable.SmartRefreshLayout_srlFooterHeight, density.dip2px(60));
	mDisableContentWhenRefresh = ta.getBoolean(R.styleable.SmartRefreshLayout_srlDisableContentWhenRefresh, mDisableContentWhenRefresh);
	mDisableContentWhenLoading = ta.getBoolean(R.styleable.SmartRefreshLayout_srlDisableContentWhenLoading, mDisableContentWhenLoading);
	mEnableHeaderTranslationContent = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableHeaderTranslationContent, mEnableHeaderTranslationContent);
	mEnableFooterTranslationContent = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableFooterTranslationContent, mEnableFooterTranslationContent);
	mEnablePreviewInEditMode = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnablePreviewInEditMode, mEnablePreviewInEditMode);
	mEnableAutoLoadmore = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableAutoLoadmore, mEnableAutoLoadmore);
	mEnableOverScrollBounce = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableAutoLoadmore, mEnableOverScrollBounce);
	mEnablePureScrollMode = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnablePureScrollMode, mEnablePureScrollMode);
	mEnableScrollContentWhenLoaded = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableScrollContentWhenLoaded, mEnableScrollContentWhenLoaded);
	mFixedHeaderViewId = ta.getResourceId(R.styleable.SmartRefreshLayout_srlFixedHeaderViewId, View.NO_ID);
	mFixedFooterViewId = ta.getResourceId(R.styleable.SmartRefreshLayout_srlFixedFooterViewId, View.NO_ID);

	mManualLoadmore = ta.hasValue(R.styleable.SmartRefreshLayout_srlEnableLoadmore);
	mManualNestedScrolling = ta.hasValue(R.styleable.SmartRefreshLayout_srlEnableNestedScrolling);
	mHeaderHeightStatus = ta.hasValue(R.styleable.SmartRefreshLayout_srlHeaderHeight) ? DimensionStatus.XmlLayoutUnNotify : mHeaderHeightStatus;
	mFooterHeightStatus = ta.hasValue(R.styleable.SmartRefreshLayout_srlFooterHeight) ? DimensionStatus.XmlLayoutUnNotify : mFooterHeightStatus;

	mFooterExtendHeight = (int) Math.max((mFooterHeight * (mHeaderMaxDragRate - 1)), 0);
	mHeaderExtendHeight = (int) Math.max((mHeaderHeight * (mHeaderMaxDragRate - 1)), 0);

	int accentColor = ta.getColor(R.styleable.SmartRefreshLayout_srlAccentColor, 0);
	int primaryColor = ta.getColor(R.styleable.SmartRefreshLayout_srlPrimaryColor, 0);
	if (primaryColor != 0) {
		if (accentColor != 0) {
			mPrimaryColors = new int[]{primaryColor, accentColor};
		} else {
			mPrimaryColors = new int[]{primaryColor};
		}
	}

	ta.recycle();

}
 
Example #22
Source File: NestedScrollView.java    From MyBlogDemo with Apache License 2.0 4 votes vote down vote up
public NestedScrollView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    initScrollView();

    final TypedArray a = context.obtainStyledAttributes(
            attrs, SCROLLVIEW_STYLEABLE, defStyleAttr, 0);

    setFillViewport(a.getBoolean(0, false));

    a.recycle();

    mParentHelper = new NestedScrollingParentHelper(this);
    mChildHelper = new NestedScrollingChildHelper(this);

    // ...because why else would you be using this widget?
    setNestedScrollingEnabled(true);

    ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE);
}
 
Example #23
Source File: BottomSheet.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public ContainerView(Context context)
{
    super(context);
    nestedScrollingParentHelper = new NestedScrollingParentHelper(this);
}