android.support.v4.view.NestedScrollingChildHelper Java Examples

The following examples show how to use android.support.v4.view.NestedScrollingChildHelper. 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: 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 #2
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 #3
Source File: NestedWebView.java    From rexxar-android with MIT License 6 votes vote down vote up
public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    final ViewConfiguration configuration = ViewConfiguration.get(getContext());
    mTouchSlop = configuration.getScaledTouchSlop();

    WebSettings webSettings = getSettings();
    webSettings.setJavaScriptEnabled(true);
    // 通过注入方法,优化横滑体验
    addJavascriptInterface(new NestScrollHelper(), "Android_NestScrollHelper");
    // 不过渡滑动
    setOverScrollMode(OVER_SCROLL_NEVER);
    mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
    mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
    mScroller = new OverScroller(getContext());
}
 
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: LWebView.java    From ELinkageScroll with Apache License 2.0 5 votes vote down vote up
public LWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    mScroller = new Scroller(getContext());
    mChildHelper = new NestedScrollingChildHelper(this);
    mPosIndicator = new PosIndicator(false);
    ViewConfiguration viewConfiguration = ViewConfiguration.get(context);
    mPosIndicator.setTouchSlop(viewConfiguration.getScaledTouchSlop());
    DENSITY = context.getResources().getDisplayMetrics().density;
    mMaximumVelocity = viewConfiguration.getScaledMaximumFlingVelocity();
    mMinimumVelocity = viewConfiguration.getScaledMinimumFlingVelocity();

    setNestedScrollingEnabled(true);
}
 
Example #6
Source File: NestedWebView.java    From Slide with GNU General Public License v3.0 5 votes vote down vote up
public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    setOverScrollMode(WebView.OVER_SCROLL_NEVER);
    initScrollView();
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example #7
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 #8
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 #9
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 #10
Source File: NestedWebView.java    From Elephant with Apache License 2.0 5 votes vote down vote up
private void init() {
        this.mChildHelper = new NestedScrollingChildHelper(this);
        setNestedScrollingEnabled(true);
        ViewConfiguration configuration = ViewConfiguration.get(getContext());
        this.mMinimumVelocity = configuration.getScaledMinimumFlingVelocity();
        this.mMaximumVelocity = configuration.getScaledMaximumFlingVelocity();
        this.mTouchSlop = configuration.getScaledTouchSlop();
        this.directionDetector = new DirectionDetector();
        this.density = getScale();
        setOverScrollMode(View.OVER_SCROLL_NEVER);
        this.settings = getSettings();
//        addJavascriptInterface(new JSGetContentHeight(), "InjectedObject");
        Log.i(TAG, "max -- min Velocity = " + this.mMaximumVelocity + " -- " + this.mMinimumVelocity + " touchSlop = " + this.mTouchSlop);
    }
 
Example #11
Source File: WXScrollView.java    From weex with Apache License 2.0 5 votes vote down vote up
private void init() {
  setWillNotDraw(false);
  startScrollerTask();
  setOverScrollMode(View.OVER_SCROLL_NEVER);
  childHelper = new NestedScrollingChildHelper(this);
  childHelper.setNestedScrollingEnabled(true);
}
 
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: NestedWebView.java    From ForPDA with GNU General Public License v3.0 5 votes vote down vote up
public NestedWebView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    final ViewConfiguration vc = ViewConfiguration.get(context);
    mTouchSlop = vc.getScaledTouchSlop();
}
 
Example #14
Source File: TwinklingRefreshLayout.java    From TwinklingRefreshLayout with Apache License 2.0 5 votes vote down vote up
public TwinklingRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwinklingRefreshLayout, defStyleAttr, 0);
    try {
        mMaxHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_head_height, (int) DensityUtil.dp2px(context, 120));
        mHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_head_height, (int) DensityUtil.dp2px(context, 80));
        mMaxBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_bottom_height, (int) DensityUtil.dp2px(context, 120));
        mBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_bottom_height, (int) DensityUtil.dp2px(context, 60));
        mOverScrollHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_overscroll_height, (int) mHeadHeight);
        enableRefresh = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_refresh, true);
        enableLoadmore = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_loadmore, true);
        isPureScrollModeOn = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_pureScrollMode_on, false);
        isOverScrollTopShow = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_overscroll_top_show, true);
        isOverScrollBottomShow = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_overscroll_bottom_show, true);
        enableOverScroll = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_overscroll, true);
        floatRefresh = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_floatRefresh, false);
        autoLoadMore = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_autoLoadMore, false);
        enableKeepIView = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_keepIView, true);
        showRefreshingWhenOverScroll = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_showRefreshingWhenOverScroll, true);
        showLoadingWhenOverScroll = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_showLoadingWhenOverScroll, true);
    } finally {
        a.recycle();
    }

    cp = new CoContext();

    addHeader();
    addFooter();

    setFloatRefresh(floatRefresh);
    setAutoLoadMore(autoLoadMore);
    setEnableRefresh(enableRefresh);
    setEnableLoadmore(enableLoadmore);

    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example #15
Source File: WXScrollView.java    From weex-uikit with MIT License 5 votes vote down vote up
private void init() {
  setWillNotDraw(false);
  startScrollerTask();
  setOverScrollMode(View.OVER_SCROLL_NEVER);
  childHelper = new NestedScrollingChildHelper(this);
  childHelper.setNestedScrollingEnabled(true);
}
 
Example #16
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 #17
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 #18
Source File: NestedScrollCoordinatorLayout.java    From NestedScrollCoordinatorLayout with Apache License 2.0 5 votes vote down vote up
private void i() {
    helper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
    // Add a dummy view that will receive inner touch events.
    View dummyView = new View(getContext());
    dummyBehavior = new DummyBehavior();
    // I *think* this is needed for dummyView to be identified as "topmost" and receive events
    // before any other view.
    ViewCompat.setElevation(dummyView, ViewCompat.getElevation(this));
    // Make sure it does not fit windows, or it will consume insets before the AppBarLayout.
    dummyView.setFitsSystemWindows(false);
    LayoutParams params = new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);
    params.setBehavior(dummyBehavior);
    addView(dummyView, params);
}
 
Example #19
Source File: TwinklingRefreshLayout.java    From AgentWebX5 with Apache License 2.0 5 votes vote down vote up
public TwinklingRefreshLayout(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.TwinklingRefreshLayout, defStyleAttr, 0);
    try {
        mMaxHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_head_height, (int) DensityUtil.dp2px(context, 120));
        mHeadHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_head_height, (int) DensityUtil.dp2px(context, 80));
        mMaxBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_max_bottom_height, (int) DensityUtil.dp2px(context, 120));
        mBottomHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_bottom_height, (int) DensityUtil.dp2px(context, 60));
        mOverScrollHeight = a.getDimensionPixelSize(R.styleable.TwinklingRefreshLayout_tr_overscroll_height, (int) mHeadHeight);
        enableRefresh = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_refresh, true);
        enableLoadmore = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_loadmore, true);
        isPureScrollModeOn = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_pureScrollMode_on, false);
        isOverScrollTopShow = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_overscroll_top_show, true);
        isOverScrollBottomShow = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_overscroll_bottom_show, true);
        enableOverScroll = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_overscroll, true);
        floatRefresh = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_floatRefresh, false);
        autoLoadMore = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_autoLoadMore, false);
        enableKeepIView = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_enable_keepIView, true);
        showRefreshingWhenOverScroll = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_showRefreshingWhenOverScroll, true);
        showLoadingWhenOverScroll = a.getBoolean(R.styleable.TwinklingRefreshLayout_tr_showLoadingWhenOverScroll, true);
    } finally {
        a.recycle();
    }

    cp = new CoContext();

    addHeader();
    addFooter();

    setFloatRefresh(floatRefresh);
    setAutoLoadMore(autoLoadMore);
    setEnableRefresh(enableRefresh);
    setEnableLoadmore(enableLoadmore);

    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example #20
Source File: CommentExpandableListView.java    From PoetryWeather with Apache License 2.0 5 votes vote down vote up
public CommentExpandableListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mScrollingChildHelper = new NestedScrollingChildHelper(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setNestedScrollingEnabled(true);
    }
}
 
Example #21
Source File: CommentExpandableListView.java    From CommentReplyComponent with MIT License 5 votes vote down vote up
public CommentExpandableListView(Context context, AttributeSet attrs) {
    super(context, attrs);
    mScrollingChildHelper = new NestedScrollingChildHelper(this);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        setNestedScrollingEnabled(true);
    }

}
 
Example #22
Source File: WXScrollView.java    From ucar-weex-core with Apache License 2.0 5 votes vote down vote up
private void init() {
  setWillNotDraw(false);
  startScrollerTask();
  setOverScrollMode(View.OVER_SCROLL_NEVER);
  childHelper = new NestedScrollingChildHelper(this);
  childHelper.setNestedScrollingEnabled(true);
}
 
Example #23
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 #24
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 #25
Source File: NestedScrollingChildView.java    From nestedscrollingchildviewdemo with Apache License 2.0 4 votes vote down vote up
public NestedScrollingChildView(Context context, AttributeSet attrs, int defStyleAttr) {
  super(context, attrs, defStyleAttr);
  mNestedScrollingChildHelper = new NestedScrollingChildHelper(this);
  mDetector = new GestureDetectorCompat(context, this);
  setNestedScrollingEnabled(true);
}
 
Example #26
Source File: NestedScrollAgentWebView.java    From AgentWeb with Apache License 2.0 4 votes vote down vote up
private void init() {
    mChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);
}
 
Example #27
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 #28
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 #29
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 #30
Source File: MyImageView.java    From AndroidUI with MIT License 4 votes vote down vote up
void init()
{
    nestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    nestedScrollingChildHelper.setNestedScrollingEnabled(true);
}