Java Code Examples for androidx.core.view.ViewCompat#getPaddingStart()
The following examples show how to use
androidx.core.view.ViewCompat#getPaddingStart() .
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: OtpView.java From android-otpview-pinview with MIT License | 6 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int width; int height; int boxHeight = otpViewItemHeight; if (widthMode == MeasureSpec.EXACTLY) { width = widthSize; } else { int boxesWidth = (otpViewItemCount - 1) * otpViewItemSpacing + otpViewItemCount * otpViewItemWidth; width = boxesWidth + ViewCompat.getPaddingEnd(this) + ViewCompat.getPaddingStart(this); if (otpViewItemSpacing == 0) { width -= (otpViewItemCount - 1) * lineWidth; } } height = heightMode == MeasureSpec.EXACTLY ? heightSize : boxHeight + getPaddingTop() + getPaddingBottom(); setMeasuredDimension(width, height); }
Example 2
Source File: RecyclerViewFastScroller.java From LollipopContactsRecyclerViewFastScroller with Apache License 2.0 | 6 votes |
@Override public boolean onTouchEvent(@NonNull MotionEvent event) { final int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: if (event.getX() < handle.getX() - ViewCompat.getPaddingStart(handle)) return false; if (currentAnimator != null) currentAnimator.cancel(); if (bubble != null && bubble.getVisibility() == INVISIBLE) showBubble(); handle.setSelected(true); case MotionEvent.ACTION_MOVE: final float y = event.getY(); setBubbleAndHandlePosition(y); setRecyclerViewPosition(y); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: handle.setSelected(false); hideBubble(); return true; } return super.onTouchEvent(event); }
Example 3
Source File: FastScroll.java From RecyclerExt with Apache License 2.0 | 6 votes |
/** * Determines if the {@link MotionEvent#ACTION_DOWN} event should be ignored. * This occurs when the event position is outside the bounds of the drag handle or * the track (of the drag handle) when disabled (see {@link #setTrackClicksAllowed(boolean)} * * @param xPos The x coordinate of the event * @param yPos The y coordinate of the event * @return {@code true} if the event should be ignored */ protected boolean ignoreTouchDown(float xPos, float yPos) { //Verifies the event is within the allowed X coordinates if (ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_LTR) { if (xPos < handle.getX() - ViewCompat.getPaddingStart(handle)) { return true; } } else { if (xPos > handle.getX() + handle.getWidth() + ViewCompat.getPaddingStart(handle)) { return true; } } if (!trackClicksAllowed) { //Enforces selection to only occur on the handle if (yPos < handle.getY() - handle.getPaddingTop() || yPos > handle.getY() + handle.getHeight() + handle.getPaddingBottom()) { return true; } } return false; }
Example 4
Source File: TagTabStrip.java From ProjectX with Apache License 2.0 | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { if (isInEditMode()) { mCount = 5; mPosition = 2; } final int paddingStart = ViewCompat.getPaddingStart(this); final int paddingEnd = ViewCompat.getPaddingEnd(this); final int paddingTop = getPaddingTop(); final int paddingBottom = getPaddingBottom(); final int suggestedMinimumWidth = getSuggestedMinimumWidth(); final int suggestedMinimumHeight = getSuggestedMinimumHeight(); final int itemWidth = Math.max(mNormal.getIntrinsicWidth(), mSelected.getIntrinsicWidth()); final int itemHeight = Math.max(mNormal.getIntrinsicHeight(), mSelected.getIntrinsicHeight()); final int count = mCount; final int padding = mPadding; final float scale = mScale; final int width = count <= 0 ? 0 : count * itemWidth + padding * (count - 1) + (scale > 1 ? (int) Math.ceil(itemWidth * (scale - 1)) : 0); final int height = scale > 1 ? (int) Math.ceil(itemHeight * scale) : itemHeight; setMeasuredDimension( resolveSize(Math.max(width + paddingStart + paddingEnd, suggestedMinimumWidth), widthMeasureSpec), resolveSize(Math.max(height + paddingTop + paddingBottom, suggestedMinimumHeight), heightMeasureSpec)); applyGravity(itemWidth, itemHeight); }
Example 5
Source File: PinView.java From PinView with Apache License 2.0 | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int widthMode = MeasureSpec.getMode(widthMeasureSpec); int heightMode = MeasureSpec.getMode(heightMeasureSpec); int widthSize = MeasureSpec.getSize(widthMeasureSpec); int heightSize = MeasureSpec.getSize(heightMeasureSpec); int width; int height; int boxHeight = mPinItemHeight; if (widthMode == MeasureSpec.EXACTLY) { // Parent has told us how big to be. So be it. width = widthSize; } else { int boxesWidth = (mPinItemCount - 1) * mPinItemSpacing + mPinItemCount * mPinItemWidth; width = boxesWidth + ViewCompat.getPaddingEnd(this) + ViewCompat.getPaddingStart(this); if (mPinItemSpacing == 0) { width -= (mPinItemCount - 1) * mLineWidth; } } if (heightMode == MeasureSpec.EXACTLY) { // Parent has told us how big to be. So be it. height = heightSize; } else { height = boxHeight + getPaddingTop() + getPaddingBottom(); } setMeasuredDimension(width, height); }
Example 6
Source File: PinView.java From PinView with Apache License 2.0 | 5 votes |
private void updateItemRectF(int i) { float halfLineWidth = ((float) mLineWidth) / 2; float left = getScrollX() + ViewCompat.getPaddingStart(this) + i * (mPinItemSpacing + mPinItemWidth) + halfLineWidth; if (mPinItemSpacing == 0 && i > 0) { left = left - (mLineWidth) * i; } float right = left + mPinItemWidth - mLineWidth; float top = getScrollY() + getPaddingTop() + halfLineWidth; float bottom = top + mPinItemHeight - mLineWidth; mItemBorderRect.set(left, top, right, bottom); }
Example 7
Source File: SimpleMonthView.java From DateTimePicker with Apache License 2.0 | 5 votes |
/** * Returns the column (0 indexed) closest to the previouslyFocusedRect or center if null. * The 0 index is related to the first day of the week. */ private int findClosestColumn(@Nullable Rect previouslyFocusedRect) { if (previouslyFocusedRect == null) { return DAYS_IN_WEEK / 2; } else { int mPaddingLeft = ViewCompat.getPaddingStart(this); // TODO is this good? int centerX = previouslyFocusedRect.centerX() - mPaddingLeft; final int columnFromLeft = mathConstrain(centerX / mCellWidth, 0, DAYS_IN_WEEK - 1); return isLayoutRtl() ? DAYS_IN_WEEK - columnFromLeft - 1 : columnFromLeft; } }
Example 8
Source File: SimpleMonthView.java From DateTimePicker with Apache License 2.0 | 5 votes |
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int padStart = ViewCompat.getPaddingStart(this); int padEnd = ViewCompat.getPaddingEnd(this); final int preferredHeight = mDesiredDayHeight * MAX_WEEKS_IN_MONTH + mDesiredDayOfWeekHeight + mDesiredMonthHeight + getPaddingTop() + getPaddingBottom(); final int preferredWidth = mDesiredCellWidth * DAYS_IN_WEEK + padStart + padEnd; final int resolvedWidth = resolveSize(preferredWidth, widthMeasureSpec); final int resolvedHeight = resolveSize(preferredHeight, heightMeasureSpec); setMeasuredDimension(resolvedWidth, resolvedHeight); }
Example 9
Source File: HorizontalLinearTabStripLayout.java From ProjectX with Apache License 2.0 | 5 votes |
@Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int paddingStart = ViewCompat.getPaddingStart(this); final int paddingTop = getPaddingTop(); final int childWidth = mChildWidth; final int childHeight = mChildHeight; final boolean show = isShowingDividers(); final int divider = show ? mDivider.getIntrinsicWidth() : 0; final int count = getChildCount(); int start = paddingStart; if (show && (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING) { start += divider; } final boolean middle = (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE; for (int i = 0; i < count; i++) { final View child = getChildAt(i); if (i == count - 1) { final int right; if (show && (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END) right = getWidth() - ViewCompat.getPaddingEnd(this) - divider; else right = getWidth() - ViewCompat.getPaddingEnd(this); child.layout(start, paddingTop, right, paddingTop + childHeight); break; } else { child.layout(start, paddingTop, start + childWidth, paddingTop + childHeight); } start += childWidth; if (count % 2 == 0 && i == (count / 2) - 1 && mCenter != null) { start += mCenter.getIntrinsicWidth(); if (show && middle && mCenterAsItem) start = start + divider + divider; } else { if (show && middle) start += divider; } } }
Example 10
Source File: OtpView.java From android-otpview-pinview with MIT License | 5 votes |
private void updateItemRectF(int i) { float halfLineWidth = ((float) lineWidth) / 2; float left = getScrollX() + ViewCompat.getPaddingStart(this) + i * (otpViewItemSpacing + otpViewItemWidth) + halfLineWidth; if (otpViewItemSpacing == 0 && i > 0) { left = left - (lineWidth) * i; } float right = left + otpViewItemWidth - lineWidth; float top = getScrollY() + getPaddingTop() + halfLineWidth; float bottom = top + otpViewItemHeight - lineWidth; itemBorderRect.set(left, top, right, bottom); }
Example 11
Source File: FastScroller.java From FlexibleAdapter with Apache License 2.0 | 5 votes |
@Override public boolean onTouchEvent(@NonNull MotionEvent event) { if (recyclerView.computeVerticalScrollRange() <= recyclerView.computeVerticalScrollExtent()) { return super.onTouchEvent(event); } int action = event.getAction(); switch (action) { case MotionEvent.ACTION_DOWN: if (event.getX() < handle.getX() - ViewCompat.getPaddingStart(handle)) { return false; } if (ignoreTouchesOutsideHandle && (event.getY() < handle.getY() || event.getY() > handle.getY() + handle.getHeight())) { return false; } handle.setSelected(true); notifyScrollStateChange(true); showBubble(); showScrollbar(); case MotionEvent.ACTION_MOVE: float y = event.getY(); setBubbleAndHandlePosition(y); setRecyclerViewPosition(y); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: handle.setSelected(false); notifyScrollStateChange(false); hideBubble(); autoHideScrollbar(); return true; } return super.onTouchEvent(event); }
Example 12
Source File: TagTabStrip.java From ProjectX with Apache License 2.0 | 4 votes |
@SuppressLint("RtlHardcoded") private void applyGravity(int itemWidth, int itemHeight) { final int count = mCount; if (count == 0) { mFirstCenterX = 0; mFirstCenterY = 0; mItemCenterOffset = 0; return; } final int padding = mPadding; final float scale = mScale > 1 ? mScale : 1; final int paddingStart = ViewCompat.getPaddingStart(this); final int paddingEnd = ViewCompat.getPaddingEnd(this); final int paddingTop = getPaddingTop(); final int paddingBottom = getPaddingBottom(); final int width = getMeasuredWidth(); final int height = getMeasuredHeight(); final int contentWidth = width - paddingStart - paddingEnd; final int contentHeight = height - paddingTop - paddingBottom; mItemCenterOffset = itemWidth + padding; switch (GravityCompat.getAbsoluteGravity(mGravity, ViewCompat.getLayoutDirection(this))) { case Gravity.LEFT: case Gravity.TOP: case Gravity.LEFT | Gravity.TOP: mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.CENTER_HORIZONTAL: case Gravity.CENTER_HORIZONTAL | Gravity.TOP: mFirstCenterX = paddingStart + contentWidth * 0.5f - mItemCenterOffset * (count - 1) * 0.5f; mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.RIGHT: case Gravity.RIGHT | Gravity.TOP: mFirstCenterX = width - paddingEnd - itemWidth * scale * 0.5f - mItemCenterOffset * (count - 1); mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.CENTER_VERTICAL: case Gravity.CENTER_VERTICAL | Gravity.LEFT: mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + contentHeight * 0.5f; break; default: case Gravity.CENTER: mFirstCenterX = paddingStart + contentWidth * 0.5f - mItemCenterOffset * (count - 1) * 0.5f; mFirstCenterY = paddingTop + contentHeight * 0.5f; break; case Gravity.CENTER_VERTICAL | Gravity.RIGHT: mFirstCenterX = width - paddingEnd - itemWidth * scale * 0.5f - mItemCenterOffset * (count - 1); mFirstCenterY = paddingTop + contentHeight * 0.5f; break; case Gravity.BOTTOM: case Gravity.BOTTOM | Gravity.LEFT: mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; case Gravity.CENTER_HORIZONTAL | Gravity.BOTTOM: mFirstCenterX = paddingStart + contentWidth * 0.5f - mItemCenterOffset * (count - 1) * 0.5f; mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; case Gravity.RIGHT | Gravity.BOTTOM: mFirstCenterX = width - paddingEnd - itemWidth * scale * 0.5f - mItemCenterOffset * (count - 1); mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; // 水平方向上沾满 case Gravity.FILL: mItemCenterOffset = count == 1 ? 0 : (contentWidth - itemWidth * scale) / (count - 1); mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + contentHeight * 0.5f; break; case Gravity.FILL_HORIZONTAL: case Gravity.FILL_HORIZONTAL | Gravity.TOP: mItemCenterOffset = count == 1 ? 0 : (contentWidth - itemWidth * scale) / (count - 1); mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = paddingTop + itemHeight * scale * 0.5f; break; case Gravity.FILL_HORIZONTAL | Gravity.BOTTOM: mItemCenterOffset = count == 1 ? 0 : (contentWidth - itemWidth * scale) / (count - 1); mFirstCenterX = paddingStart + itemWidth * scale * 0.5f; mFirstCenterY = height - paddingBottom - itemHeight * scale * 0.5f; break; } }
Example 13
Source File: FastScroller.java From a with GNU General Public License v3.0 | 4 votes |
@Override @SuppressLint("ClickableViewAccessibility") public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (event.getX() < mHandleView.getX() - ViewCompat.getPaddingStart(mHandleView)) { return false; } requestDisallowInterceptTouchEvent(true); setHandleSelected(true); getHandler().removeCallbacks(mScrollbarHider); cancelAnimation(mScrollbarAnimator); cancelAnimation(mBubbleAnimator); if (!isViewVisible(mScrollbar)) { showScrollbar(); } if (mShowBubble && mSectionIndexer != null) { showBubble(); } if (mFastScrollStateChangeListener != null) { mFastScrollStateChangeListener.onFastScrollStart(this); } case MotionEvent.ACTION_MOVE: final float y = event.getY(); setViewPositions(y); setRecyclerViewPosition(y); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: requestDisallowInterceptTouchEvent(false); setHandleSelected(false); if (mFadeScrollbar) { getHandler().postDelayed(mScrollbarHider, sScrollbarHideDelay); } hideBubble(); if (mFastScrollStateChangeListener != null) { mFastScrollStateChangeListener.onFastScrollStop(this); } return true; } return super.onTouchEvent(event); }
Example 14
Source File: HorizontalLinearTabStripLayout.java From ProjectX with Apache License 2.0 | 4 votes |
@Override protected void onDraw(Canvas canvas) { super.onDraw(canvas); final int count = getChildCount(); if (mCenter == null && !isShowingDividers() && count <= 0) return; final int paddingStart = ViewCompat.getPaddingStart(this); final int paddingTop = getPaddingTop(); final int paddingBottom = getPaddingBottom(); final int childWidth = mChildWidth; final boolean show = isShowingDividers(); final Drawable dd = mDivider; final int divider = show ? dd.getIntrinsicWidth() : 0; final int padding = mDividerPadding; int start = paddingStart; if (show) dd.setBounds(1, paddingTop + padding, divider + 1, getHeight() - paddingBottom - padding); if (count == 1) { if (show && (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); start += divider; } start += childWidth; if (show && (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); } } else { final boolean middle = (mShowDividers & SHOW_DIVIDER_MIDDLE) == SHOW_DIVIDER_MIDDLE; for (int i = 0; i < count; i++) { if (i == 0) { if (show && (mShowDividers & SHOW_DIVIDER_BEGINNING) == SHOW_DIVIDER_BEGINNING) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); start += divider; } start += childWidth; } else if (i == count - 1) { if (show && middle) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); start += divider; } start += childWidth; if (show && (mShowDividers & SHOW_DIVIDER_END) == SHOW_DIVIDER_END) { start = getWidth() - ViewCompat.getPaddingEnd(this) - divider; canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); break; } } else { if (count % 2 == 0 && count / 2 == i && mCenter != null) { if (show && middle && mCenterAsItem) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); start += divider; } final Drawable center = mCenter; final int p = mCenterPadding; center.setBounds(0, paddingTop + p, center.getIntrinsicWidth(), getHeight() - paddingBottom - p); canvas.save(); canvas.translate(start, 0); center.draw(canvas); canvas.restore(); start += center.getIntrinsicWidth(); if (show && middle && mCenterAsItem) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); start += divider; } } else { if (show && middle) { canvas.save(); canvas.translate(start, 0); dd.draw(canvas); canvas.restore(); start += divider; } } start += childWidth; } } } }
Example 15
Source File: Utils.java From SmartTabLayout with Apache License 2.0 | 4 votes |
static int getPaddingStart(View v) { if (v == null) { return 0; } return ViewCompat.getPaddingStart(v); }
Example 16
Source File: MaterialButtonHelper.java From material-components-android with Apache License 2.0 | 4 votes |
void loadFromAttributes(@NonNull TypedArray attributes) { insetLeft = attributes.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetLeft, 0); insetRight = attributes.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetRight, 0); insetTop = attributes.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetTop, 0); insetBottom = attributes.getDimensionPixelOffset(R.styleable.MaterialButton_android_insetBottom, 0); // cornerRadius should override whatever corner radius is set in shapeAppearanceModel if (attributes.hasValue(R.styleable.MaterialButton_cornerRadius)) { cornerRadius = attributes.getDimensionPixelSize(R.styleable.MaterialButton_cornerRadius, -1); setShapeAppearanceModel(shapeAppearanceModel.withCornerSize(cornerRadius)); cornerRadiusSet = true; } strokeWidth = attributes.getDimensionPixelSize(R.styleable.MaterialButton_strokeWidth, 0); backgroundTintMode = ViewUtils.parseTintMode( attributes.getInt(R.styleable.MaterialButton_backgroundTintMode, -1), Mode.SRC_IN); backgroundTint = MaterialResources.getColorStateList( materialButton.getContext(), attributes, R.styleable.MaterialButton_backgroundTint); strokeColor = MaterialResources.getColorStateList( materialButton.getContext(), attributes, R.styleable.MaterialButton_strokeColor); rippleColor = MaterialResources.getColorStateList( materialButton.getContext(), attributes, R.styleable.MaterialButton_rippleColor); checkable = attributes.getBoolean(R.styleable.MaterialButton_android_checkable, false); int elevation = attributes.getDimensionPixelSize(R.styleable.MaterialButton_elevation, 0); // Store padding before setting background, since background overwrites padding values int paddingStart = ViewCompat.getPaddingStart(materialButton); int paddingTop = materialButton.getPaddingTop(); int paddingEnd = ViewCompat.getPaddingEnd(materialButton); int paddingBottom = materialButton.getPaddingBottom(); // Update materialButton's background without triggering setBackgroundOverwritten() if (attributes.hasValue(R.styleable.MaterialButton_android_background)) { setBackgroundOverwritten(); } else { materialButton.setInternalBackground(createBackground()); MaterialShapeDrawable materialShapeDrawable = getMaterialShapeDrawable(); if (materialShapeDrawable != null) { materialShapeDrawable.setElevation(elevation); } } // Set the stored padding values ViewCompat.setPaddingRelative( materialButton, paddingStart + insetLeft, paddingTop + insetTop, paddingEnd + insetRight, paddingBottom + insetBottom); }
Example 17
Source File: PinEntryEditText.java From PinEntryEditText with Apache License 2.0 | 4 votes |
@Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); mOriginalTextColors = getTextColors(); if (mOriginalTextColors != null) { mLastCharPaint.setColor(mOriginalTextColors.getDefaultColor()); mCharPaint.setColor(mOriginalTextColors.getDefaultColor()); mSingleCharPaint.setColor(getCurrentHintTextColor()); } int availableWidth = getWidth() - ViewCompat.getPaddingEnd(this) - ViewCompat.getPaddingStart(this); if (mSpace < 0) { mCharSize = (availableWidth / (mNumChars * 2 - 1)); } else { mCharSize = (availableWidth - (mSpace * (mNumChars - 1))) / mNumChars; } mLineCoords = new RectF[(int) mNumChars]; mCharBottom = new float[(int) mNumChars]; int startX; int bottom = getHeight() - getPaddingBottom(); int rtlFlag; final boolean isLayoutRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; if (isLayoutRtl) { rtlFlag = -1; startX = (int) (getWidth() - ViewCompat.getPaddingStart(this) - mCharSize); } else { rtlFlag = 1; startX = ViewCompat.getPaddingStart(this); } for (int i = 0; i < mNumChars; i++) { mLineCoords[i] = new RectF(startX, bottom, startX + mCharSize, bottom); if (mPinBackground != null) { if (mIsDigitSquare) { mLineCoords[i].top = getPaddingTop(); mLineCoords[i].right = startX + mLineCoords[i].width(); } else { mLineCoords[i].top -= mTextHeight.height() + mTextBottomPadding * 2; } } if (mSpace < 0) { startX += rtlFlag * mCharSize * 2; } else { startX += rtlFlag * (mCharSize + mSpace); } mCharBottom[i] = mLineCoords[i].bottom - mTextBottomPadding; } }
Example 18
Source File: FastScroller.java From HaoReader with GNU General Public License v3.0 | 4 votes |
@Override @SuppressLint("ClickableViewAccessibility") public boolean onTouchEvent(@NonNull MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (event.getX() < handleView.getX() - ViewCompat.getPaddingStart(scrollbar)) { return false; } requestDisallowInterceptTouchEvent(true); setHandleSelected(true); getHandler().removeCallbacks(scrollbarHider); cancelAnimation(scrollbarAnimator); cancelAnimation(bubbleAnimator); if (!isViewVisible(scrollbar)) { showScrollbar(); } if (showBubble && sectionIndexer != null) { showBubble(); } if (fastScrollListener != null) { fastScrollListener.onFastScrollStart(this); } case MotionEvent.ACTION_MOVE: if (layoutChangeListener != null) { recyclerView.removeOnLayoutChangeListener(layoutChangeListener); layoutChangeListener = null; } final float y = event.getY(); setViewPositions(y, true); setRecyclerViewPosition(y); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: requestDisallowInterceptTouchEvent(false); setHandleSelected(false); if (hideScrollbar) { getHandler().postDelayed(scrollbarHider, SCROLLBAR_HIDE_DELAY); } hideBubble(); if (fastScrollListener != null) { fastScrollListener.onFastScrollStop(this); } return true; } return super.onTouchEvent(event); }
Example 19
Source File: Pix.java From PixImagePicker with Apache License 2.0 | 4 votes |
@Override public boolean onTouch(View view, MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (event.getX() < mHandleView.getX() - ViewCompat.getPaddingStart(mHandleView)) { return false; } mHandleView.setSelected(true); handler.removeCallbacks(mScrollbarHider); Utility.cancelAnimation(mScrollbarAnimator); Utility.cancelAnimation(mBubbleAnimator); if (!Utility.isViewVisible(mScrollbar) && (recyclerView.computeVerticalScrollRange() - mViewHeight > 0)) { mScrollbarAnimator = Utility.showScrollbar(mScrollbar, Pix.this); } if (mainImageAdapter != null) { showBubble(); } if (mFastScrollStateChangeListener != null) { mFastScrollStateChangeListener.onFastScrollStart(this); } case MotionEvent.ACTION_MOVE: final float y = event.getRawY(); setViewPositions(y - TOPBAR_HEIGHT); setRecyclerViewPosition(y); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: mHandleView.setSelected(false); if (mHideScrollbar) { handler.postDelayed(mScrollbarHider, sScrollbarHideDelay); } hideBubble(); if (mFastScrollStateChangeListener != null) { mFastScrollStateChangeListener.onFastScrollStop(this); } return true; } return super.onTouchEvent(event); }
Example 20
Source File: FastScroller.java From MyBookshelf with GNU General Public License v3.0 | 4 votes |
@Override @SuppressLint("ClickableViewAccessibility") public boolean onTouchEvent(MotionEvent event) { switch (event.getAction()) { case MotionEvent.ACTION_DOWN: if (event.getX() < mHandleView.getX() - ViewCompat.getPaddingStart(mHandleView)) { return false; } requestDisallowInterceptTouchEvent(true); setHandleSelected(true); getHandler().removeCallbacks(mScrollbarHider); cancelAnimation(mScrollbarAnimator); cancelAnimation(mBubbleAnimator); if (!isViewVisible(mScrollbar)) { showScrollbar(); } if (mShowBubble && mSectionIndexer != null) { showBubble(); } if (mFastScrollStateChangeListener != null) { mFastScrollStateChangeListener.onFastScrollStart(this); } case MotionEvent.ACTION_MOVE: final float y = event.getY(); setViewPositions(y); setRecyclerViewPosition(y); return true; case MotionEvent.ACTION_UP: case MotionEvent.ACTION_CANCEL: requestDisallowInterceptTouchEvent(false); setHandleSelected(false); if (mFadeScrollbar) { getHandler().postDelayed(mScrollbarHider, sScrollbarHideDelay); } hideBubble(); if (mFastScrollStateChangeListener != null) { mFastScrollStateChangeListener.onFastScrollStop(this); } return true; } return super.onTouchEvent(event); }