Example usage for android.support.v4.view NestedScrollingParentHelper NestedScrollingParentHelper

List of usage examples for android.support.v4.view NestedScrollingParentHelper NestedScrollingParentHelper

Introduction

In this page you can find the example usage for android.support.v4.view NestedScrollingParentHelper NestedScrollingParentHelper.

Prototype

public NestedScrollingParentHelper(ViewGroup viewGroup) 

Source Link

Document

Construct a new helper for a given ViewGroup

Usage

From source file:org.alex.swiperefreshlayout.SwipeRefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context// w w  w.  j  av a 2s  . c o m
 * @param attrs
 */
public SwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    isLoadingMore = false;
    loadMoreEnabled = true;
    loadMoreMinDistance = (int) dp2px(72);
    touchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
    mMediumAnimationDuration = getResources().getInteger(android.R.integer.config_mediumAnimTime);
    setWillNotDraw(false);
    decelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR);

    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    circleDiameter = (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
    spinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density);
    refreshMaxDragDistance = spinnerOffsetEnd;
    nestedScrollingParentHelper = new NestedScrollingParentHelper(this);
    nestedScrollingChildHelper = new NestedScrollingChildHelper(this);
    setNestedScrollingEnabled(true);

    originalOffsetTop = currentTargetOffsetTop = -circleDiameter;
    LogUtil.e("originalOffsetTop = " + originalOffsetTop);
    moveToStart(1.0f);

    final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a.getBoolean(0, true));
    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.SwipeRefreshLayout);
    footType = typedArray.getInteger(R.styleable.SwipeRefreshLayout_srl_footType, 100);
    typedArray.recycle();
    a.recycle();
    setColorSchemeColors(0xff99cc00, 0xffffbb33, 0xffff4444);
}

From source file:com.kido.ucmaindemo.widget.refresh.KSwipeRefreshLayout.java

/**
 * Constructor that is called when inflating CustomSwipeRefreshLayout from XML.
 *
 * @param context/* w ww.  ja v a  2  s .co  m*/
 * @param attrs
 */
public KSwipeRefreshLayout(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 a1 = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS);
    setEnabled(a1.getBoolean(0, true));
    a1.recycle();

    TypedArray a2 = context.obtainStyledAttributes(attrs, R.styleable.KSwipeRefreshLayout);
    mIndicatorNormalBackground = a2.getColor(R.styleable.KSwipeRefreshLayout_ksrl_indicator_normal_background,
            DEFAULT_INDICATOR_NORMAL_BACKGROUND);
    mIndicatorNormalForeground = a2.getColor(R.styleable.KSwipeRefreshLayout_ksrl_indicator_normal_foreground,
            DEFAULT_INDICATOR_NORMAL_FOREGROUND);
    mIndicatorTerminalBackground = a2.getColor(
            R.styleable.KSwipeRefreshLayout_ksrl_indicator_terminal_background,
            DEFAULT_INDICATOR_TERMINAL_BACKGROUND);
    mIndicatorTerminalForeground = a2.getColor(
            R.styleable.KSwipeRefreshLayout_ksrl_indicator_terminal_foreground,
            DEFAULT_INDICATOR_TERMINAL_FOREGROUND);
    mTerminalEnable = a2.getBoolean(R.styleable.KSwipeRefreshLayout_ksrl_terminal_enable, false);
    int terminalIconResId = a2.getResourceId(R.styleable.KSwipeRefreshLayout_ksrl_terminal_icon, -1);
    if (terminalIconResId != -1) {
        mTerminalIconDrawable = getResources().getDrawable(terminalIconResId);
    }
    a2.recycle();

    init();
}

From source file:com.taobao.weex.ui.view.refresh.core.WXSwipeLayout.java

private void initAttrs(Context context, AttributeSet attrs) {

    if (getChildCount() > 1) {
        throw new RuntimeException("WXSwipeLayout should not have more than one child");
    }/*from   ww w .  j a  v  a2  s.c om*/

    parentHelper = new NestedScrollingParentHelper(this);

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

    mRefreshViewBgColor = Color.TRANSPARENT;
    mProgressBgColor = Color.TRANSPARENT;
    mProgressColor = Color.RED;
}

From source file:com.hippo.refreshlayout.RefreshLayout.java

/**
 * Constructor that is called when inflating SwipeRefreshLayout from XML.
 *
 * @param context//from  w  w  w . j a  va  2  s .  c  o m
 * @param attrs
 */
public RefreshLayout(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);
    mAccelerateInterpolator = new AccelerateInterpolator(ACCELERATE_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
    mHeaderSpinnerOffsetEnd = (int) (DEFAULT_CIRCLE_TARGET * metrics.density);
    mHeaderTotalDragDistance = mHeaderSpinnerOffsetEnd;
    mNestedScrollingParentHelper = new NestedScrollingParentHelper(this);

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

    mHeaderOriginalOffsetTop = mHeaderCurrentTargetOffsetTop = -mCircleDiameter;
    moveToStart(1.0f);

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

    mProgressBar = new SwipeProgressBar(this);
    mProgressBarHeight = (int) (metrics.density * PROGRESS_BAR_HEIGHT);
}