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; }
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); }
public PullToRefreshView(Context context, AttributeSet attrs) { super(context, attrs); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RefreshView); final int type = a.getInteger(R.styleable.RefreshView_type, STYLE_SUN); a.recycle(); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mTotalDragDistance = Utils.convertDpToPixel(context, DRAG_MAX_DISTANCE); mRefreshView = new ImageView(context); setRefreshStyle(type); addView(mRefreshView); setWillNotDraw(false); ViewCompat.setChildrenDrawingOrderEnabled(this, true); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
private void init() { mPullHandler = new ProxyPullHeader(HEADER_FACTORY.made(getContext())); mIsPinContent = HEADER_FACTORY.isPinContent(); if (mIsPinContent) { scrollerHelper = new PinContentScroller(); } else { scrollerHelper = new AllScroller(); } setWillNotDraw(false); addHeadView(); final ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
public StickyNavigationLayout(Context context, AttributeSet attrs) { super(context, attrs); //setOrientation(LinearLayout.VERTICAL); mGroupStickyDelegate = new GroupStickyDelegate(); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); mScroller = new OverScroller(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();//触摸阙值 mMaximumVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity(); mMinimumVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StickyNavigationLayout); // mCodeSet will set stick view from onFinishInflate. mTopViewId = a.getResourceId(R.styleable.StickyNavigationLayout_stickyLayout_top_id, 0); mIndicatorId = a.getResourceId(R.styleable.StickyNavigationLayout_stickyLayout_indicator_id, 0); mContentId = a.getResourceId(R.styleable.StickyNavigationLayout_stickyLayout_content_id, 0); mAutoFitScroll = a.getBoolean(R.styleable.StickyNavigationLayout_stickyLayout_auto_fit_scroll, false); a.recycle(); //getWindowVisibleDisplayFrame(mExpectTopRect); }
public StickyNavigationLayout_backup(Context context, AttributeSet attrs) { super(context, attrs); //setOrientation(LinearLayout.VERTICAL); mGroupStickyDelegate = new GroupStickyDelegate(); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); mScroller = new OverScroller(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();//触摸阙值 mMaximumVelocity = ViewConfiguration.get(context).getScaledMaximumFlingVelocity(); mMinimumVelocity = ViewConfiguration.get(context).getScaledMinimumFlingVelocity(); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StickyNavigationLayout); // mCodeSet will set stick view from onFinishInflate. if(!mCodeSet) { mTopViewId = a.getResourceId(R.styleable.StickyNavigationLayout_stickyLayout_top_id, 0); mIndicatorId = a.getResourceId(R.styleable.StickyNavigationLayout_stickyLayout_indicator_id, 0); mContentId = a.getResourceId(R.styleable.StickyNavigationLayout_stickyLayout_content_id, 0); } mAutoFitScroll = a.getBoolean(R.styleable.StickyNavigationLayout_stickyLayout_auto_fit_scroll, false); mAutoFitPercent = a.getFloat(R.styleable.StickyNavigationLayout_stickyLayout_threshold_percent, 0.5f); a.recycle(); //getWindowVisibleDisplayFrame(mExpectTopRect); }
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; }
public NestedScrollView(Context paramContext, AttributeSet paramAttributeSet, int paramInt) { super(paramContext, paramAttributeSet, paramInt); setFocusable(true); setDescendantFocusability(262144); setWillNotDraw(false); ViewConfiguration localViewConfiguration = ViewConfiguration.get(getContext()); this.mTouchSlop = localViewConfiguration.getScaledTouchSlop(); this.mMinimumVelocity = localViewConfiguration.getScaledMinimumFlingVelocity(); this.mMaximumVelocity = localViewConfiguration.getScaledMaximumFlingVelocity(); TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, SCROLLVIEW_STYLEABLE, paramInt, 0); setFillViewport(localTypedArray.getBoolean(0, false)); localTypedArray.recycle(); this.mParentHelper = new NestedScrollingParentHelper(this); this.mChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE); }
public SwipeRefreshLayout(Context paramContext, AttributeSet paramAttributeSet) { super(paramContext, paramAttributeSet); this.mTouchSlop = ViewConfiguration.get(paramContext).getScaledTouchSlop(); this.mMediumAnimationDuration = getResources().getInteger(17694721); setWillNotDraw(false); this.mDecelerateInterpolator = new DecelerateInterpolator(2.0F); TypedArray localTypedArray = paramContext.obtainStyledAttributes(paramAttributeSet, LAYOUT_ATTRS); setEnabled(localTypedArray.getBoolean(0, true)); localTypedArray.recycle(); DisplayMetrics localDisplayMetrics = getResources().getDisplayMetrics(); this.mCircleWidth = ((int)(40.0F * localDisplayMetrics.density)); this.mCircleHeight = ((int)(40.0F * localDisplayMetrics.density)); this.mCircleView = new CircleImageView(getContext()); this.mProgress = new MaterialProgressDrawable(getContext(), this); this.mProgress.setBackgroundColor(-328966); this.mCircleView.setImageDrawable(this.mProgress); this.mCircleView.setVisibility(8); addView(this.mCircleView); ViewCompat.setChildrenDrawingOrderEnabled$4d3af60(this); this.mSpinnerFinalOffset = (64.0F * localDisplayMetrics.density); this.mTotalDragDistance = this.mSpinnerFinalOffset; this.mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); this.mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
/** */ @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); }
/** * @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)); }
public ResolverDrawerLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ResolverDrawerLayout, defStyleAttr, 0); mMaxWidth = a.getDimensionPixelSize(R.styleable.ResolverDrawerLayout_resolverMaxWidth, -1); mMaxCollapsedHeight = a.getDimensionPixelSize( R.styleable.ResolverDrawerLayout_maxCollapsedHeight, 0); mMaxCollapsedHeightSmall = a.getDimensionPixelSize( R.styleable.ResolverDrawerLayout_maxCollapsedHeightSmall, mMaxCollapsedHeight); a.recycle(); mParentHelper = new NestedScrollingParentHelper(this); mScroller = new OverScroller(context, AnimationUtils.loadInterpolator(context, android.R.interpolator.decelerate_quint)); mVelocityTracker = VelocityTracker.obtain(); final ViewConfiguration vc = ViewConfiguration.get(context); mTouchSlop = vc.getScaledTouchSlop(); mMinFlingVelocity = vc.getScaledMinimumFlingVelocity(); }
public NestedScrollView(Context context, AttributeSet attributeset, int i) { super(context, attributeset, i); mTempRect = new Rect(); mIsLayoutDirty = true; mIsLaidOut = false; mChildToScrollTo = null; mIsBeingDragged = false; mSmoothScrollingEnabled = true; mActivePointerId = -1; mScrollOffset = new int[2]; mScrollConsumed = new int[2]; initScrollView(); context = context.obtainStyledAttributes(attributeset, SCROLLVIEW_STYLEABLE, i, 0); setFillViewport(context.getBoolean(0, false)); context.recycle(); mParentHelper = new NestedScrollingParentHelper(this); mChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); ViewCompat.setAccessibilityDelegate(this, ACCESSIBILITY_DELEGATE); }
/** * 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())); }
public CoordinatorLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); this.mLayoutDependencyComparator = new Comparator<View>() { public int compare(View lhs, View rhs) { if (lhs == rhs) { return 0; } if (((LayoutParams) lhs.getLayoutParams()).dependsOn(CoordinatorLayout.this, lhs, rhs)) { return 1; } return ((LayoutParams) rhs.getLayoutParams()).dependsOn(CoordinatorLayout.this, rhs, lhs) ? -1 : 0; } }; this.mDependencySortedChildren = new ArrayList(); this.mTempList1 = new ArrayList(); this.mTempDependenciesList = new ArrayList(); this.mTempRect1 = new Rect(); this.mTempRect2 = new Rect(); this.mTempRect3 = new Rect(); this.mTempIntPair = new int[2]; this.mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); ThemeUtils.checkAppCompatTheme(context); TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.CoordinatorLayout, defStyleAttr, R.style.Widget_Design_CoordinatorLayout); int keylineArrayRes = a.getResourceId(R.styleable.CoordinatorLayout_keylines, 0); if (keylineArrayRes != 0) { Resources res = context.getResources(); this.mKeylines = res.getIntArray(keylineArrayRes); float density = res.getDisplayMetrics().density; int count = this.mKeylines.length; for (int i = 0; i < count; i++) { int[] iArr = this.mKeylines; iArr[i] = (int) (((float) iArr[i]) * density); } } this.mStatusBarBackground = a.getDrawable(R.styleable.CoordinatorLayout_statusBarBackground); a.recycle(); if (INSETS_HELPER != null) { INSETS_HELPER.setupForWindowInsets(this, new ApplyInsetsListener()); } super.setOnHierarchyChangeListener(new HierarchyChangeListener()); }
/** * 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(); }
private void init() { setOrientation(VERTICAL); scrollingParentHelper = new NestedScrollingParentHelper(this); headLayout = new LinearLayout(getContext()); headLayout.setOrientation(VERTICAL); myScrollView = new LinearLayout(getContext()); ViewCompat.setNestedScrollingEnabled(myScrollView, true); footLayout = new LinearLayout(getContext()); footLayout.setOrientation(VERTICAL); addView(headLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); addView(myScrollView, new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); addView(footLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
private void init() { setOrientation(VERTICAL); scrollingParentHelper = new NestedScrollingParentHelper(this); headLayout = new LinearLayout(getContext()); headLayout.setOrientation(VERTICAL); myScrollView = new MyScrollView(getContext()); ViewCompat.setNestedScrollingEnabled(myScrollView, true); footLayout = new LinearLayout(getContext()); footLayout.setOrientation(VERTICAL); addView(headLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); addView(myScrollView, new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); addView(footLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
private void init() { setOrientation(VERTICAL); scrollingParentHelper = new NestedScrollingParentHelper(this); headLayout = new LinearLayout(getContext()); headLayout.setOrientation(VERTICAL); myRecyclerView = new MyRecyclerView(getContext()); myRecyclerView.setNestedScrollingEnabled(true); footLayout = new LinearLayout(getContext()); footLayout.setOrientation(VERTICAL); addView(headLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); addView(myRecyclerView, new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); addView(footLayout, new LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT)); }
private void init(Context context) { int childCount = getChildCount(); if (childCount > 1) { throw new IllegalStateException("Only support one child"); } nestedScrollingParentHelper = new NestedScrollingParentHelper(this); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); if (refreshingEnabled) { addDefaultRefreshView(); } if (loadingEnabled) { addDefaultLoadingIndicator(); } }
private void init() { mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); mScroller = new Scroller(getContext(), new DecelerateInterpolator()); ViewConfiguration configuration = ViewConfiguration.get(getContext()); mTouchSlop = configuration.getScaledTouchSlop(); mRefreshContainer.setGravity(Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM); mDefaultScrollUpProcessor = new DefaultScrollUpProcessor(); addRefreshStateListener(mRefreshStateWatcher); }
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context * @param attrs */ public DistRefreshLayout(Context context, AttributeSet attrs) { super(context, attrs); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); setWillNotDraw(false); mDecelerateInterpolator = new DecelerateInterpolator(DECELERATE_INTERPOLATION_FACTOR); final TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); // the absolute offset has to take into account that the circle starts at an offset // mSpinnerFinalOffset = mTotalDragDistance = DEFAULT_REFRESH_TARGET * metrics.density; createProgressView(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. */ 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 TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density); mCircleHeight = (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 mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density; mTotalDragDistance = mSpinnerFinalOffset; mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
public NestedLinearLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); // 通过 NestedScrolling 机制来处理嵌套滚动 mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mScroller = new OverScroller(context); scrollerCompat = ScrollerCompat.create(context); mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop(); mMaximumVelocity = ViewConfiguration.get(context) .getScaledMaximumFlingVelocity(); mMinimumVelocity = ViewConfiguration.get(context) .getScaledMinimumFlingVelocity(); }
private void init() { setOverScrollMode(View.OVER_SCROLL_NEVER); this.mParentHelper = new NestedScrollingParentHelper(this); this.touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); SENSOR_DISTANCE = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 100.0F, getResources().getDisplayMetrics()); Log.i(TAG, "touch slop = " + this.touchSlop + " SENSOR_DISTANCE = " + SENSOR_DISTANCE); }
private void init() { setOverScrollMode(View.OVER_SCROLL_NEVER); this.mParentHelper = new NestedScrollingParentHelper(this); this.touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); SENSOR_DISTANCE = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 200.0F, getResources().getDisplayMetrics()); // Log.i(TAG, "touch slop = " + this.touchSlop + " SENSOR_DISTANCE = " + SENSOR_DISTANCE); }
private void initialize() { this.nestedScrollingChildHelper = new NestedScrollingChildHelper(this); this.nestedScrollingParentHelper = new NestedScrollingParentHelper(this); setNestedScrollingEnabled(true); setForceScrolling(false); this.touchSlop = ViewConfiguration.get(getContext()).getScaledTouchSlop(); }
public BothWaySwipeRefreshLayout(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(); mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density); mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density); mDragTriggerDistances[DIRECTION_TOP] = DEFAULT_CIRCLE_TARGET * metrics.density; mDragTriggerDistances[DIRECTION_BOTTOM] = DEFAULT_CIRCLE_TARGET * metrics.density; createProgressView(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); 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(); }
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context * @param attrs */ public SwipeRefreshPlusLayout(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 TypedArray a = context.obtainStyledAttributes(attrs, LAYOUT_ATTRS); setEnabled(a.getBoolean(0, true)); a.recycle(); final DisplayMetrics metrics = getResources().getDisplayMetrics(); mCircleWidth = (int) (CIRCLE_DIAMETER * metrics.density); mCircleHeight = (int) (CIRCLE_DIAMETER * metrics.density); createProgressView(); createLoadMoreProgressView(); ViewCompat.setChildrenDrawingOrderEnabled(this, true); // the absolute offset has to take into account that the circle starts at an offset mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density; mTotalDragDistance = mSpinnerFinalOffset; mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
/** * Constructor that is called when inflating SwipeRefreshLayout from XML. * * @param context * @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); }
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))); }
public HeadViewFrameLayout(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); setNestedScrollingEnabled(true); }
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(); }
private void initView(Context context, AttributeSet attrs) { setClipToPadding(false); DensityUtil density = new DensityUtil(); ViewConfiguration configuration = ViewConfiguration.get(context); mScroller = new Scroller(context); mScreenHeightPixels = context.getResources().getDisplayMetrics().heightPixels; mReboundInterpolator = new ViscousFluidInterpolator(); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); 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); mHeaderTriggerRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlHeaderTriggerRate, mHeaderTriggerRate); mFooterTriggerRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlFooterTriggerRate, mFooterTriggerRate); 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_srlEnableOverScrollBounce, mEnableOverScrollBounce); mEnablePureScrollMode = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnablePureScrollMode, mEnablePureScrollMode); mEnableScrollContentWhenLoaded = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableScrollContentWhenLoaded, mEnableScrollContentWhenLoaded); mEnableLoadmoreWhenContentNotFull = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableLoadmoreWhenContentNotFull, mEnableLoadmoreWhenContentNotFull); 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; mHeaderExtendHeight = (int) Math.max((mHeaderHeight * (mHeaderMaxDragRate - 1)), 0); mFooterExtendHeight = (int) Math.max((mFooterHeight * (mFooterMaxDragRate - 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(); }
private void initView(Context context, AttributeSet attrs) { setClipToPadding(false); DensityUtil density = new DensityUtil(); ViewConfiguration configuration = ViewConfiguration.get(context); mKernel = new RefreshKernelImpl(); mScroller = new Scroller(context); mVelocityTracker = VelocityTracker.obtain(); mScreenHeightPixels = context.getResources().getDisplayMetrics().heightPixels; mReboundInterpolator = new ViscousFluidInterpolator(); mTouchSlop = configuration.getScaledTouchSlop(); mMinimumVelocity = configuration.getScaledMinimumFlingVelocity(); mMaximumVelocity = configuration.getScaledMaximumFlingVelocity(); mNestedScrollingParentHelper = new NestedScrollingParentHelper(this); mNestedScrollingChildHelper = new NestedScrollingChildHelper(this); 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); mHeaderTriggerRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlHeaderTriggerRate, mHeaderTriggerRate); mFooterTriggerRate = ta.getFloat(R.styleable.SmartRefreshLayout_srlFooterTriggerRate, mFooterTriggerRate); 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_srlEnableOverScrollBounce, mEnableOverScrollBounce); mEnablePureScrollMode = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnablePureScrollMode, mEnablePureScrollMode); mEnableScrollContentWhenLoaded = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableScrollContentWhenLoaded, mEnableScrollContentWhenLoaded); mEnableLoadmoreWhenContentNotFull = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableLoadmoreWhenContentNotFull, mEnableLoadmoreWhenContentNotFull); mEnableFooterFollowWhenLoadFinished = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableFooterFollowWhenLoadFinished, mEnableFooterFollowWhenLoadFinished); mEnableOverScrollDrag = ta.getBoolean(R.styleable.SmartRefreshLayout_srlEnableOverScrollDrag, mEnableOverScrollDrag); 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; mHeaderExtendHeight = (int) Math.max((mHeaderHeight * (mHeaderMaxDragRate - 1)), 0); mFooterExtendHeight = (int) Math.max((mFooterHeight * (mFooterMaxDragRate - 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(); }