android.support.v4.view.ViewCompat Java Examples

The following examples show how to use android.support.v4.view.ViewCompat. 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: SystemBarHelper.java    From FlycoSystemBar with MIT License 6 votes vote down vote up
/**
 * Android4.4以上的状态栏着色
 *
 * @param window         一般都是用于Activity的window,也可以是其他的例如Dialog,DialogFragment
 * @param statusBarColor 状态栏颜色
 * @param alpha          透明栏透明度[0.0-1.0]
 */
public static void tintStatusBar(Window window, @ColorInt int statusBarColor, @FloatRange(from = 0.0, to = 1.0) float alpha) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.KITKAT) {
        return;
    }

    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
        window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        window.setStatusBarColor(Color.TRANSPARENT);
    } else {
        window.addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
    }

    ViewGroup decorView = (ViewGroup) window.getDecorView();
    ViewGroup contentView = (ViewGroup) window.getDecorView().findViewById(Window.ID_ANDROID_CONTENT);
    View rootView = contentView.getChildAt(0);
    if (rootView != null) {
        ViewCompat.setFitsSystemWindows(rootView, true);
    }

    setStatusBar(decorView, statusBarColor, true);
    setTranslucentView(decorView, alpha);
}
 
Example #2
Source File: MaterialBadgeTextView.java    From Android with MIT License 6 votes vote down vote up
/**
 *
 * @param isDisplayInToolbarMenu
 */
public void setHighLightMode(boolean isDisplayInToolbarMenu){
    isHighLightMode = true;
    ViewGroup.LayoutParams params = getLayoutParams();
    params.width = ViewGroup.LayoutParams.WRAP_CONTENT;
    params.height = params.width;
    if(isDisplayInToolbarMenu && params instanceof FrameLayout.LayoutParams){
        ((FrameLayout.LayoutParams)params).topMargin=dp2px(getContext(), 10);
        ((FrameLayout.LayoutParams)params).rightMargin=dp2px(getContext(), 10);
    }
    setLayoutParams(params);

    final int diameter = getWidth() - (int) (2.5 * (float) mShadowRadius);
    OvalShadow oval = new OvalShadow(mShadowRadius, diameter);
    ShapeDrawable drawable = new ShapeDrawable(oval);
    ViewCompat.setLayerType(this, ViewCompat.LAYER_TYPE_SOFTWARE, drawable.getPaint());
    drawable.getPaint().setColor(backgroundColor);
    drawable.getPaint().setAntiAlias(true);
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN) {
        setBackground(drawable);
    } else {
        setBackgroundDrawable(drawable);
    }
    setText("");
    setVisibility(View.VISIBLE);
}
 
Example #3
Source File: DetailActivity.java    From Dashboard with MIT License 6 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    mImageView = (ImageView) findViewById(R.id.image);
    progressBar = (ProgressBar) findViewById(R.id.loading);
    mAttacher = new PhotoViewAttacher(mImageView);


    ViewCompat.setTransitionName(mImageView, EXTRA_IMAGE);
    Picasso.with(this).load(getIntent().getStringExtra(EXTRA_IMAGE)).into(mImageView, new Callback.EmptyCallback() {
        @Override public void onSuccess() {
            progressBar.setVisibility(View.GONE);
        }
        @Override
        public void onError() {
            progressBar.setVisibility(View.GONE);
        }


    });
}
 
Example #4
Source File: BaseItemAnimator.java    From SimpleNews with Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateMove(final ViewHolder holder, int fromX, int fromY, int toX, int toY) {
  final View view = holder.itemView;
  fromX += ViewCompat.getTranslationX(holder.itemView);
  fromY += ViewCompat.getTranslationY(holder.itemView);
  endAnimation(holder);
  int deltaX = toX - fromX;
  int deltaY = toY - fromY;
  if (deltaX == 0 && deltaY == 0) {
    dispatchMoveFinished(holder);
    return false;
  }
  if (deltaX != 0) {
    ViewCompat.setTranslationX(view, -deltaX);
  }
  if (deltaY != 0) {
    ViewCompat.setTranslationY(view, -deltaY);
  }
  mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
  return true;
}
 
Example #5
Source File: SlidingPaneLayout.java    From MiBandDecompiled with Apache License 2.0 6 votes vote down vote up
boolean a(float f1, int i1)
{
    if (!j)
    {
        return false;
    }
    LayoutParams layoutparams = (LayoutParams)k.getLayoutParams();
    int j1 = (int)((float)(getPaddingLeft() + layoutparams.leftMargin) + f1 * (float)n);
    if (t.smoothSlideViewTo(k, j1, k.getTop()))
    {
        a();
        ViewCompat.postInvalidateOnAnimation(this);
        return true;
    } else
    {
        return false;
    }
}
 
Example #6
Source File: DrawerLayout.java    From V.FlyoutTest with MIT License 6 votes vote down vote up
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfoCompat info) {
    final AccessibilityNodeInfoCompat superNode = AccessibilityNodeInfoCompat.obtain(info);
    super.onInitializeAccessibilityNodeInfo(host, superNode);

    info.setSource(host);
    final ViewParent parent = ViewCompat.getParentForAccessibility(host);
    if (parent instanceof View) {
        info.setParent((View) parent);
    }
    copyNodeInfoNoChildren(info, superNode);

    superNode.recycle();

    addChildrenForAccessibility(info, (ViewGroup) host);
}
 
Example #7
Source File: DefaultItemAnimator.java    From adt-leanback-support with Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateChange(ViewHolder oldHolder, ViewHolder newHolder,
        int fromX, int fromY, int toX, int toY) {
    final float prevTranslationX = ViewCompat.getTranslationX(oldHolder.itemView);
    final float prevTranslationY = ViewCompat.getTranslationY(oldHolder.itemView);
    final float prevAlpha = ViewCompat.getAlpha(oldHolder.itemView);
    endAnimation(oldHolder);
    int deltaX = (int) (toX - fromX - prevTranslationX);
    int deltaY = (int) (toY - fromY - prevTranslationY);
    // recover prev translation state after ending animation
    ViewCompat.setTranslationX(oldHolder.itemView, prevTranslationX);
    ViewCompat.setTranslationY(oldHolder.itemView, prevTranslationY);
    ViewCompat.setAlpha(oldHolder.itemView, prevAlpha);
    if (newHolder != null && newHolder.itemView != null) {
        // carry over translation values
        endAnimation(newHolder);
        ViewCompat.setTranslationX(newHolder.itemView, -deltaX);
        ViewCompat.setTranslationY(newHolder.itemView, -deltaY);
        ViewCompat.setAlpha(newHolder.itemView, 0);
    }
    mPendingChanges.add(new ChangeInfo(oldHolder, newHolder, fromX, fromY, toX, toY));
    return true;
}
 
Example #8
Source File: BoardView.java    From fingerpoetry-android with Apache License 2.0 6 votes vote down vote up
@Override
public void computeScroll() {
    if (!mScroller.isFinished() && mScroller.computeScrollOffset()) {
        int x = mScroller.getCurrX();
        int y = mScroller.getCurrY();
        if (getScrollX() != x || getScrollY() != y) {
            scrollTo(x, y);
        }

        // If auto scrolling at the same time as the scroller is running,
        // then update the drag item position to prevent stuttering item
        if (mAutoScroller.isAutoScrolling()) {
            mDragItem.setPosition(getListTouchX(mCurrentRecyclerView), getListTouchY(mCurrentRecyclerView));
        }

        ViewCompat.postInvalidateOnAnimation(this);
    } else {
        super.computeScroll();
    }
}
 
Example #9
Source File: ScrollAwareFABBehavior.java    From PowerSwitch_Android with GNU General Public License v3.0 6 votes vote down vote up
/**
 * Same animation that FloatingActionButton.Behavior
 * uses to show the FAB when the AppBarLayout enters
 *
 * @param floatingActionButton FAB
 */
//
private void animateIn(FloatingActionButton floatingActionButton) {
    if (SmartphonePreferencesHandler.getUseOptionsMenuInsteadOfFAB()) {
        return;
    }
    floatingActionButton.setVisibility(View.VISIBLE);
    if (Build.VERSION.SDK_INT >= 14) {
        ViewCompat.animate(floatingActionButton).scaleX(1.0F).scaleY(1.0F).alpha(1.0F)
                .setInterpolator(INTERPOLATOR).withLayer().setListener(null)
                .start();
    } else {
        Animation anim = AnimationUtils.loadAnimation(floatingActionButton.getContext(), android.R.anim.fade_in);
        anim.setDuration(200L);
        anim.setInterpolator(INTERPOLATOR);
        floatingActionButton.startAnimation(anim);
    }
}
 
Example #10
Source File: MyDefaultItemAnimator.java    From Dota2Helper with Apache License 2.0 6 votes vote down vote up
@Override
public boolean animateMove(final RecyclerView.ViewHolder holder, int fromX, int fromY,
                           int toX, int toY) {
    final View view = holder.itemView;
    fromX += ViewCompat.getTranslationX(holder.itemView);
    fromY += ViewCompat.getTranslationY(holder.itemView);
    resetAnimation(holder);
    int deltaX = toX - fromX;
    int deltaY = toY - fromY;
    if (deltaX == 0 && deltaY == 0) {
        dispatchMoveFinished(holder);
        return false;
    }
    if (deltaX != 0) {
        ViewCompat.setTranslationX(view, -deltaX);
    }
    if (deltaY != 0) {
        ViewCompat.setTranslationY(view, -deltaY);
    }
    mPendingMoves.add(new MoveInfo(holder, fromX, fromY, toX, toY));
    return true;
}
 
Example #11
Source File: SettingsActivity.java    From NHentai-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void setUpViews() {
	ViewCompat.setElevation(mToolbar, getResources().getDimension(R.dimen.appbar_elevation));

	switch (flag) {
		case FLAG_MAIN:
			mFragment = new SettingsMain();
			break;
		case FLAG_LICENSE:
			mFragment = new SettingsLicense();
			break;
	}
	getFragmentManager().beginTransaction()
			.replace(R.id.container, mFragment)
			.commit();
}
 
Example #12
Source File: WXSwipeLayout.java    From weex-uikit with MIT License 6 votes vote down vote up
/**
 * Whether child view can scroll up
 * @return
 */
public boolean canChildScrollUp() {
  if (mTargetView == null) {
    return false;
  }
  if (Build.VERSION.SDK_INT < 14) {
    if (mTargetView instanceof AbsListView) {
      final AbsListView absListView = (AbsListView) mTargetView;
      return absListView.getChildCount() > 0
             && (absListView.getFirstVisiblePosition() > 0 || absListView.getChildAt(0)
                                                                  .getTop() < absListView.getPaddingTop());
    } else {
      return ViewCompat.canScrollVertically(mTargetView, -1) || mTargetView.getScrollY() > 0;
    }
  } else {
    return ViewCompat.canScrollVertically(mTargetView, -1);
  }
}
 
Example #13
Source File: FragmentManagerImpl.java    From letv with Apache License 2.0 6 votes vote down vote up
@CallSuper
public void onAnimationStart(Animation animation) {
    if (this.mView != null) {
        this.mShouldRunOnHWLayer = FragmentManagerImpl.shouldRunOnHWLayer(this.mView, animation);
        if (this.mShouldRunOnHWLayer) {
            this.mView.post(new Runnable() {
                public void run() {
                    ViewCompat.setLayerType(AnimateOnHWLayerIfNeededListener.this.mView, 2, null);
                }
            });
        }
    }
    if (this.mOrignalListener != null) {
        this.mOrignalListener.onAnimationStart(animation);
    }
}
 
Example #14
Source File: SlidingLayer.java    From android-sliding-layer-lib with Apache License 2.0 6 votes vote down vote up
protected boolean canScroll(View v, boolean checkV, int dx, int dy, int x, int y) {

        if (v instanceof ViewGroup) {
            final ViewGroup group = (ViewGroup) v;
            final int scrollX = v.getScrollX();
            final int scrollY = v.getScrollY();

            final int count = group.getChildCount();
            // Count backwards - let topmost views consume scroll distance first.
            for (int i = count - 1; i >= 0; i--) {
                // TODO: Add versioned support here for transformed views.
                // This will not work for transformed views in Honeycomb+
                final View child = group.getChildAt(i);
                if (x + scrollX >= child.getLeft() && x + scrollX < child.getRight() &&
                        y + scrollY >= child.getTop() && y + scrollY < child.getBottom() &&
                        canScroll(child, true, dx, dy, x + scrollX - child.getLeft(),
                                y + scrollY - child.getTop())) {
                    return true;
                }
            }
        }

        return checkV && (
                (allowedDirection() == HORIZONTAL && ViewCompat.canScrollHorizontally(v, -dx) ||
                        allowedDirection() == VERTICAL && ViewCompat.canScrollVertically(v, -dy)));
    }
 
Example #15
Source File: ReboundHLayout.java    From CoordinatorLayoutExample with Apache License 2.0 6 votes vote down vote up
@Override
public void onNestedPreScroll(View target, int dx, int dy, int[] consumed) {
    // 如果在自定义ViewGroup之上还有父View交给我来处理
    getParent().requestDisallowInterceptTouchEvent(true);
    // dx>0 往左滑动 dx<0往右滑动
    boolean hiddenLeft = dx > 0 && getScrollX() < MAX_WIDTH && !ViewCompat
            .canScrollHorizontally(target, -1);
    boolean showLeft = dx < 0 && !ViewCompat.canScrollHorizontally(target, -1);
    boolean hiddenRight = dx < 0 && getScrollX() > MAX_WIDTH && !ViewCompat
            .canScrollHorizontally(target, 1);
    boolean showRight = dx > 0 && !ViewCompat.canScrollHorizontally(target, 1);
    if (hiddenLeft || showLeft || hiddenRight || showRight) {
        scrollBy(dx / mDrag, 0);
        consumed[0] = dx;
    }

    // 限制错位问题
    if (dx > 0 && getScrollX() > MAX_WIDTH && !ViewCompat.canScrollHorizontally(target, -1)) {
        scrollTo(MAX_WIDTH, 0);
    }
    if (dx < 0 && getScrollX() < MAX_WIDTH && !ViewCompat.canScrollHorizontally(target, 1)) {
        scrollTo(MAX_WIDTH, 0);
    }
}
 
Example #16
Source File: InsetView.java    From insets-dispatcher with Apache License 2.0 6 votes vote down vote up
private void setInsets(Rect insets) {
    if (insets == null || mWindowInset == -1) return;
    final ViewGroup.LayoutParams lp = getLayoutParams();
    switch (mWindowInset) {
        case 0:
            lp.width = insets.left;
            break;
        case 1:
            lp.height = insets.top;
            break;
        case 2:
            lp.width = insets.right;
            break;
        case 3:
            lp.height = insets.bottom;
            break;
    }
    setLayoutParams(lp);
    ViewCompat.postInvalidateOnAnimation(this);
}
 
Example #17
Source File: ItemTouchHelper.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
/**
 * Converts a given set of flags to absolution direction which means {@link #START} and
 * {@link #END} are replaced with {@link #LEFT} and {@link #RIGHT} depending on the layout
 * direction.
 *
 * @param flags           The flag value that include any number of movement flags.
 * @param layoutDirection The layout direction of the RecyclerView.
 * @return Updated flags which includes only absolute direction values.
 */
public int convertToAbsoluteDirection(int flags, int layoutDirection) {
    int masked = flags & RELATIVE_DIR_FLAGS;
    if (masked == 0) {
        return flags; // does not have any relative flags, good.
    }
    flags &= ~masked; //remove start / end
    if (layoutDirection == ViewCompat.LAYOUT_DIRECTION_LTR) {
        // no change. just OR with 2 bits shifted mask and return
        flags |= masked >> 2; // START is 2 bits after LEFT, END is 2 bits after RIGHT.
        return flags;
    } else {
        // add START flag as RIGHT
        flags |= ((masked >> 1) & ~RELATIVE_DIR_FLAGS);
        // first clean start bit then add END flag as LEFT
        flags |= ((masked >> 1) & RELATIVE_DIR_FLAGS) >> 2;
    }
    return flags;
}
 
Example #18
Source File: ViewOffsetHelper.java    From MyBlogDemo with Apache License 2.0 5 votes vote down vote up
private void updateOffsets() {
    ViewCompat.offsetTopAndBottom(mView, mOffsetTop - (mView.getTop() - mLayoutTop));
    ViewCompat.offsetLeftAndRight(mView, mOffsetLeft - (mView.getLeft() - mLayoutLeft));

    // Manually invalidate the view and parent to make sure we get drawn pre-M
    if (Build.VERSION.SDK_INT < 23) {
        tickleInvalidationFlag(mView);
        final ViewParent vp = mView.getParent();
        if (vp instanceof View) {
            tickleInvalidationFlag((View) vp);
        }
    }
}
 
Example #19
Source File: MessageHolders.java    From ChatKit with Apache License 2.0 5 votes vote down vote up
@Override
public final void applyStyle(MessagesListStyle style) {
    super.applyStyle(style);
    if (time != null) {
        time.setTextColor(style.getOutcomingImageTimeTextColor());
        time.setTextSize(TypedValue.COMPLEX_UNIT_PX, style.getOutcomingImageTimeTextSize());
        time.setTypeface(time.getTypeface(), style.getOutcomingImageTimeTextStyle());
    }

    if (imageOverlay != null) {
        ViewCompat.setBackground(imageOverlay, style.getOutcomingImageOverlayDrawable());
    }
}
 
Example #20
Source File: SuperSwipeRefreshLayout.java    From AutoRecycleView with Apache License 2.0 5 votes vote down vote up
@SuppressWarnings("deprecation")
public SuperSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);

    /**
     * getScaledTouchSlop是一个距离,表示滑动的时候,手的移动要大于这个距离才开始移动控件。如果小于这个距离就不触发移动控件
     */
    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();

    WindowManager wm = (WindowManager) context
            .getSystemService(Context.WINDOW_SERVICE);
    Display display = wm.getDefaultDisplay();
    final DisplayMetrics metrics = getResources().getDisplayMetrics();
    mHeaderViewWidth = (int) display.getWidth();
    mFooterViewWidth = (int) display.getWidth();
    mHeaderViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    mFooterViewHeight = (int) (HEADER_VIEW_HEIGHT * metrics.density);
    defaultProgressView = new CircleProgressView(getContext());
    createHeaderViewContainer();
    createFooterViewContainer();
    ViewCompat.setChildrenDrawingOrderEnabled(this, true);
    mSpinnerFinalOffset = DEFAULT_CIRCLE_TARGET * metrics.density;
    density = metrics.density;
    mTotalDragDistance = mSpinnerFinalOffset;
}
 
Example #21
Source File: MaterialViewPagerAnimator.java    From MaterialViewPager with Apache License 2.0 5 votes vote down vote up
/**
 * move the toolbarlayout (containing toolbar & tabs)
 * following the current scroll
 */
private void followScrollToolbarLayout(float yOffset) {
    if (mHeader.toolbar.getBottom() == 0) {
        return;
    }

    if (toolbarJoinsTabs()) {
        if (firstScrollValue == Float.MIN_VALUE) {
            firstScrollValue = yOffset;
        }

        float translationY = firstScrollValue - yOffset;

        if (translationY > 0) {
            translationY = 0;
        }

        log("translationY " + translationY);

        ViewCompat.setTranslationY(mHeader.toolbarLayout, translationY);
    } else {
        ViewCompat.setTranslationY(mHeader.toolbarLayout, 0);
        justToolbarAnimated = false;
    }

    followScrollToolbarIsVisible = (ViewCompat.getY(mHeader.toolbarLayout) >= 0);
}
 
Example #22
Source File: Workspace.java    From TurboLauncher with Apache License 2.0 5 votes vote down vote up
@Override
public void onChildViewAdded(View parent, View child) {
    if (!(child instanceof CellLayout)) {
        throw new IllegalArgumentException("A Workspace can only have CellLayout children.");
    }
    CellLayout cl = ((CellLayout) child);
    cl.setOnInterceptTouchListener(this);
    cl.setClickable(true);
    cl.setImportantForAccessibility(ViewCompat.IMPORTANT_FOR_ACCESSIBILITY_NO);
    super.onChildViewAdded(parent, child);
}
 
Example #23
Source File: ForegroundToBackgroundTransformer.java    From LoyalNativeSlider with MIT License 5 votes vote down vote up
@Override
protected void onTransform(View view, float position) {
	final float height = view.getHeight();
	final float width = view.getWidth();
	final float scale = min(position > 0 ? 1f : Math.abs(1f + position), 0.5f);

	ViewCompat.setScaleX(view, scale);
       ViewCompat.setScaleY(view,scale);
       ViewCompat.setPivotX(view,width * 0.5f);
       ViewCompat.setPivotY(view,height * 0.5f);
       ViewCompat.setTranslationX(view,position > 0 ? width * position : -width * position * 0.25f);
}
 
Example #24
Source File: ScrollAwareFABBehavior.java    From droidddle with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onStartNestedScroll(final CoordinatorLayout coordinatorLayout, final FloatingActionButton child,
                                   final View directTargetChild, final View target, final int nestedScrollAxes) {
    // Ensure we react to vertical scrolling
    return nestedScrollAxes == ViewCompat.SCROLL_AXIS_VERTICAL
            || super.onStartNestedScroll(coordinatorLayout, child, directTargetChild, target, nestedScrollAxes);
}
 
Example #25
Source File: CoordinatorLayout.java    From ticdesign with Apache License 2.0 5 votes vote down vote up
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
    mAppBarLayoutScrollRange = -1;
    mScrollingContainerView = null;
    mScrollingView = null;
    mViewScrollingStatusAccessor.attach(null);

    final int layoutDirection = ViewCompat.getLayoutDirection(this);
    final int childCount = mDependencySortedChildren.size();
    for (int i = 0; i < childCount; i++) {
        final View child = mDependencySortedChildren.get(i);
        final LayoutParams lp = (LayoutParams) child.getLayoutParams();
        final Behavior behavior = lp.getBehavior();

        if (behavior == null || !behavior.onLayoutChild(this, child, layoutDirection)) {
            onLayoutChild(child, layoutDirection);
        }

        if (behavior instanceof ScrollingViewBehavior) {
            mScrollingContainerView = child;
            mScrollingView = ((ScrollingViewBehavior) behavior).getScrollingView();
            mViewScrollingStatusAccessor.attach(mScrollingView);
        }

        if (child instanceof AppBarLayout) {
            mAppBarLayoutScrollRange = ((AppBarLayout) child).getTotalScrollRange();
        }
    }
}
 
Example #26
Source File: SwipeProgressBar.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Update the progress the user has made toward triggering the swipe
 * gesture. and use this value to update the percentage of the trigger that
 * is shown.
 */
void setTriggerPercentage(float triggerPercentage) {
    mTriggerPercentage = triggerPercentage;
    mStartTime = 0;
    ViewCompat.postInvalidateOnAnimation(
            mParent, mBounds.left, mBounds.top, mBounds.right, mBounds.bottom);
}
 
Example #27
Source File: SwipeRefreshLayout.java    From android-source-codes with Creative Commons Attribution 4.0 International 5 votes vote down vote up
@Override
public void requestDisallowInterceptTouchEvent(boolean b) {
    // if this is a List < L or another view that doesn't support nested
    // scrolling, ignore this request so that the vertical scroll event
    // isn't stolen
    if ((android.os.Build.VERSION.SDK_INT < 21 && mTarget instanceof AbsListView)
            || (mTarget != null && !ViewCompat.isNestedScrollingEnabled(mTarget))) {
        // Nope.
    } else {
        super.requestDisallowInterceptTouchEvent(b);
    }
}
 
Example #28
Source File: ViewPagerCompat.java    From android-auto-scroll-viewpager with Apache License 2.0 5 votes vote down vote up
private void enableLayers(boolean enable) {
    final int childCount = getChildCount();
    for (int i = 0; i < childCount; i++) {
        final int layerType = enable ?
                ViewCompat.LAYER_TYPE_HARDWARE : ViewCompat.LAYER_TYPE_NONE;
        ViewCompat.setLayerType(getChildAt(i), layerType, null);
    }
}
 
Example #29
Source File: DividerItemDecoration.java    From PracticalRecyclerView with Apache License 2.0 5 votes vote down vote up
private void drawDividerHorizontal(Canvas canvas, RecyclerView parent, int top, int bottom,
                                   int i) {
    final View child = parent.getChildAt(i);
    parent.getLayoutManager().getDecoratedBoundsWithMargins(child, mBounds);
    final int right = mBounds.right + Math.round(ViewCompat.getTranslationX(child));
    final int left = right - mDivider.getIntrinsicWidth();
    mDivider.setBounds(left, top, right, bottom);
    mDivider.draw(canvas);
}
 
Example #30
Source File: SlidingUpPanelLayout.java    From AndroidSlidingUpPanel with Apache License 2.0 5 votes vote down vote up
@Override
public void computeScroll() {
    if (mDragHelper != null && mDragHelper.continueSettling(true)) {
        if (!isEnabled()) {
            mDragHelper.abort();
            return;
        }

        ViewCompat.postInvalidateOnAnimation(this);
    }
}