|
|
@@ -6,7 +6,7 @@ import android.graphics.Canvas;
|
|
|
import android.graphics.Paint;
|
|
|
import android.support.v7.widget.LinearLayoutManager;
|
|
|
import android.support.v7.widget.RecyclerView;
|
|
|
-import android.view.View;
|
|
|
+import android.util.Log;
|
|
|
|
|
|
/**
|
|
|
* MainBannerViewItemDotIndicator
|
|
|
@@ -33,7 +33,7 @@ public class MainBannerViewItemDotIndicator extends RecyclerView.ItemDecoration
|
|
|
/**
|
|
|
* Indicator stroke width.
|
|
|
*/
|
|
|
- private final float mIndicatorStrokeWidth = DP * 4;
|
|
|
+ private final float mIndicatorStrokeWidth = DP * 2;
|
|
|
|
|
|
/**
|
|
|
* Indicator width.
|
|
|
@@ -56,7 +56,7 @@ public class MainBannerViewItemDotIndicator extends RecyclerView.ItemDecoration
|
|
|
//this.context = context;
|
|
|
mPaint.setStrokeCap(Paint.Cap.ROUND);
|
|
|
mPaint.setStrokeWidth(mIndicatorStrokeWidth);
|
|
|
- mPaint.setStyle(Paint.Style.STROKE);
|
|
|
+ mPaint.setStyle(Paint.Style.FILL);
|
|
|
mPaint.setAntiAlias(true);
|
|
|
}
|
|
|
|
|
|
@@ -66,13 +66,11 @@ public class MainBannerViewItemDotIndicator extends RecyclerView.ItemDecoration
|
|
|
|
|
|
int itemCount = parent.getAdapter().getItemCount();
|
|
|
|
|
|
- // center horizontally, calculate width and subtract half from center
|
|
|
float totalLength = mIndicatorItemLength * itemCount;
|
|
|
float paddingBetweenItems = Math.max(0, itemCount - 1) * mIndicatorItemPadding;
|
|
|
float indicatorTotalWidth = totalLength + paddingBetweenItems;
|
|
|
float indicatorStartX = (parent.getWidth() - indicatorTotalWidth) / 2F;
|
|
|
|
|
|
- // center vertically in the allotted space
|
|
|
float indicatorPosY = parent.getHeight() - mIndicatorHeight / 2F;
|
|
|
|
|
|
drawInactiveIndicators(c, indicatorStartX, indicatorPosY, itemCount);
|
|
|
@@ -81,19 +79,11 @@ public class MainBannerViewItemDotIndicator extends RecyclerView.ItemDecoration
|
|
|
// find active page (which should be highlighted)
|
|
|
LinearLayoutManager layoutManager = (LinearLayoutManager) parent.getLayoutManager();
|
|
|
int activePosition = layoutManager.findFirstVisibleItemPosition();
|
|
|
+ Log.e("APP# MainBannerViewItemDotIndicator | onDrawOver", "|" + activePosition);
|
|
|
if (activePosition == RecyclerView.NO_POSITION) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- // find offset of active page (if the user is scrolling)
|
|
|
- final View activeChild = layoutManager.findViewByPosition(activePosition);
|
|
|
- int left = activeChild.getLeft();
|
|
|
- int width = activeChild.getWidth();
|
|
|
-
|
|
|
- // on swipe the active item will be positioned from [-width, 0]
|
|
|
- // interpolate offset for smooth animation
|
|
|
- //float progress = mInterpolator.getInterpolation(left * -1 / (float) width);
|
|
|
-
|
|
|
drawHighlights(c, indicatorStartX, indicatorPosY, activePosition, itemCount);
|
|
|
}
|
|
|
|