diff --git a/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollPopup.java b/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollPopup.java index e4aee1e55c1d6769f2c3b8a6ea9f98ca9d29d8f4..a3d13fac7f32cc797c9453b2adc116e3c37b65c3 100644 --- a/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollPopup.java +++ b/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollPopup.java @@ -53,10 +53,12 @@ public class FastScrollPopup { private AnimatorValue mAlphaAnimator; private boolean mVisible; - @FastScroller.PopupTextVerticalAlignmentMode private int mTextVerticalAlignmentMode; - @FastScroller.PopupPosition private int mPosition; + @FastScroller.PopupTextVerticalAlignmentMode + private int mTextVerticalAlignmentMode; + @FastScroller.PopupPosition + private int mPosition; - FastScrollPopup( FastScrollRecyclerView recyclerView) { + FastScrollPopup(FastScrollRecyclerView recyclerView) { mRecyclerView = recyclerView; mBackgroundPaint = new Paint(); @@ -95,9 +97,6 @@ public class FastScrollPopup { mRecyclerView.invalidate(); } - /** - * Animates the visibility of the fast scroller popup. - */ public void animateVisibility(boolean visible) { if (mVisible != visible) { mVisible = visible; @@ -168,13 +167,13 @@ public class FastScrollPopup { // Draw the fast scroller popup int restoreCount = canvas.save(); // canvas.translate(mBgBounds.left, mBgBounds.top); - mTmpRect.set(mBgBounds.left,mBgBounds.top,mBgBounds.right,mBgBounds.bottom); + mTmpRect.set(mBgBounds.left, mBgBounds.top, mBgBounds.right, mBgBounds.bottom); mTmpRect.offset(0, 0); mBackgroundPath.reset(); - mBackgroundRect.bottom =mTmpRect.bottom; - mBackgroundRect.top =mTmpRect.top; - mBackgroundRect.left =mTmpRect.left; - mBackgroundRect.right =mTmpRect.right; + mBackgroundRect.bottom = mTmpRect.bottom; + mBackgroundRect.top = mTmpRect.top; + mBackgroundRect.left = mTmpRect.left; + mBackgroundRect.right = mTmpRect.right; float[] radii = createRadii(); float baselinePosition; @@ -192,8 +191,8 @@ public class FastScrollPopup { canvas.drawPath(mBackgroundPath, mBackgroundPaint); canvas.drawText(mTextPaint, mSectionName, - (mBgBounds.getWidth() - mTextBounds.getWidth()) / 2f+mBgBounds.left, - baselinePosition+mBgBounds.top + (mBgBounds.getWidth() - mTextBounds.getWidth()) / 2f + mBgBounds.left, + baselinePosition + mBgBounds.top ); canvas.restoreToCount(restoreCount); } @@ -211,10 +210,12 @@ public class FastScrollPopup { /** * Updates the bounds for the fast scroller. * - * @return the invalidation rect for this update. + * @param recyclerView recyclerView + * @param thumbOffsetY thumbOffsetY + * @return Rect */ public Rect updateFastScrollerBounds(FastScrollRecyclerView recyclerView, int thumbOffsetY) { - mInvalidateRect.set(mBgBounds.left,mBgBounds.top,mBgBounds.right,mBgBounds.bottom); + mInvalidateRect.set(mBgBounds.left, mBgBounds.top, mBgBounds.right, mBgBounds.bottom); if (isVisible()) { // Calculate the dimensions and position of the fast scroller popup @@ -243,7 +244,7 @@ public class FastScrollPopup { } // Combine the old and new fast scroller bounds to create the full invalidate rect - Utils.rectUnion(mInvalidateRect,mBgBounds); + Utils.rectUnion(mInvalidateRect, mBgBounds); return mInvalidateRect; } diff --git a/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollRecyclerView.java b/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollRecyclerView.java index 49e1ffb38d7ccd37c2f673af4c09ad2054342c6c..e6531256156d0a9d0932a66fc6d2af0fc7102ae8 100644 --- a/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollRecyclerView.java +++ b/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScrollRecyclerView.java @@ -62,7 +62,7 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To */ public FastScrollRecyclerView(Context context, AttrSet attrs) { super(context, attrs); - init(context,attrs); + init(context, attrs); } public FastScrollRecyclerView(Context context, AttrSet attrs, String defStyleAttr) { @@ -107,10 +107,6 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To return handleTouchEvent(touchEvent); } - /** - * Handles the touch event and determines whether to show the fast scroller (or updates it if - * it is already showing). - */ private boolean handleTouchEvent(TouchEvent ev) { int action = ev.getAction(); float x = getTouchX(ev, 0, this); @@ -163,12 +159,6 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To return y; } - /** - * Returns the available scroll height: - * AvailableScrollHeight = Total height of the all items - last page height - * - * @param yOffset the offset from the top of the recycler view to start tracking. - */ protected int getAvailableScrollHeight(int adapterHeight, int yOffset) { int visibleHeight = getHeight(); int scrollHeight = getPaddingTop() + yOffset + adapterHeight + getPaddingBottom(); @@ -178,6 +168,8 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To /** * Returns the available scroll bar height: * AvailableScrollBarHeight = Total height of the visible view - thumb height + * + * @return int */ protected int getAvailableScrollBarHeight() { int visibleHeight = getHeight() - getPaddingTop() - getPaddingBottom(); @@ -195,6 +187,10 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To /** * Maps the touch (from 0..1) to the adapter position that should be visible. + * + * @param touchFraction1 touchFraction1 + * @param barTop barTop + * @return String */ public String scrollToPositionAtProgress(float touchFraction1, float barTop) { if (!(getAdapter() instanceof SectionedAdapter)) { @@ -273,7 +269,7 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To } } - return (height + Math.abs(component.getContentPositionY())); + return height + Math.abs(component.getContentPositionY()); } /** @@ -401,6 +397,8 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To * Set the FastScroll Popup position. This is either {@link FastScroller.PopupPosition#ADJACENT}, * meaning the popup moves adjacent to the FastScroll thumb, or {@link FastScroller.PopupPosition#CENTER}, * meaning the popup is static and centered within the RecyclerView. + * + * @param popupPosition popupPosition */ public void setPopupPosition(@FastScroller.PopupPosition int popupPosition) { mScrollbar.setPopupPosition(popupPosition); @@ -441,7 +439,6 @@ public class FastScrollRecyclerView extends RecyclerView implements Component.To invalidateAllScrollOffsets(); } - @Override public void onItemRangeInserted(int positionStart, int itemCount) { invalidateAllScrollOffsets(); diff --git a/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScroller.java b/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScroller.java index d58497b05df5e203595bd1d042dc9005707bc342..c7674f594bac37c69a85dcca34c9d8e3f8fdfc76 100644 --- a/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScroller.java +++ b/recyclerview_fastscroll/src/main/java/com/simplecityapps/recyclerview_fastscroll/views/FastScroller.java @@ -188,10 +188,6 @@ public class FastScroller { return mIsDragging; } - /** - * Handles the touch event and determines whether to show the fast scroller (or updates it if - * it is already showing). - */ public void handleTouchEvent(TouchEvent ev, float downX, float downY, float lastY, OnFastScrollStateChangeListener stateChangeListener) { int action = ev.getAction();