Skip to content

Commit 6af26c3

Browse files
author
Iain Connor
committed
Adding option for strip offset
1 parent 79e1f7d commit 6af26c3

File tree

4 files changed

+13
-2
lines changed

4 files changed

+13
-2
lines changed

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
<com.tippingcanoe.dewey.Dewey
1313
android:id="@+id/dewey"
14-
android:layout_width="wrap_content"
14+
android:layout_width="match_parent"
1515
android:layout_height="wrap_content"
1616
android:background="@color/material_deep_teal_200"
1717
custom:stripColor="@color/accent_material_light"

library/src/main/java/com/tippingcanoe/dewey/Dewey.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ public class Dewey extends RecyclerView {
3131
float minCloakPercentage = 50f;
3232
Interpolator cloakCurveInterpolator = new AccelerateInterpolator();
3333

34+
int stripOffset = 0;
3435
int stripHeight = 10;
3536
int stripColor = Color.RED;
3637
Interpolator stripAnimationInterpolator = new AccelerateDecelerateInterpolator();
@@ -64,6 +65,7 @@ protected void setup ( Context context, @Nullable AttributeSet attrs ) {
6465
try {
6566
cloakColor = typedArray.getColor(R.styleable.Dewey_cloakColor, cloakColor);
6667
minCloakPercentage = typedArray.getFloat(R.styleable.Dewey_minCloakPercentage, minCloakPercentage);
68+
stripOffset = typedArray.getDimensionPixelSize(R.styleable.Dewey_stripOffset, stripOffset);
6769
stripHeight = typedArray.getDimensionPixelSize(R.styleable.Dewey_stripHeight, stripHeight);
6870
stripColor = typedArray.getColor(R.styleable.Dewey_stripColor, stripColor);
6971
animationDurationMs = typedArray.getInteger(R.styleable.Dewey_animationDurationMs, animationDurationMs);
@@ -225,6 +227,14 @@ public void setUniformCells(boolean uniformCells) {
225227
((DeweyLayoutManager) getLayoutManager()).setUniformCells(uniformCells);
226228
}
227229

230+
public int getStripOffset() {
231+
return stripOffset;
232+
}
233+
234+
public void setStripOffset(@DimenRes int stripOffset) {
235+
this.stripOffset = getResources().getDimensionPixelSize(stripOffset);
236+
}
237+
228238
public static interface OnFocusedPositionChangedListener {
229239
void onFocusedPositionChanged ( int previousFocusedPosition, int newFocusedPosition );
230240
}

library/src/main/java/com/tippingcanoe/dewey/DeweyDecorator.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -407,7 +407,7 @@ protected void drawStrip ( RecyclerView parent, Canvas c, int firstVisiblePos, i
407407
}
408408

409409
if (currentFocusedChild != null) {
410-
dY = parent.getMeasuredHeight() - dewey.getStripHeight();
410+
dY = parent.getMeasuredHeight() - dewey.getStripHeight() - dewey.getStripOffset();
411411
dWidth = currentFocusedChild.getMeasuredWidth();
412412

413413
if (isAnimating) {

library/src/main/res/values/attrs.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
<attr name="minCloakPercentage" format="float" />
66
<attr name="stripHeight" format="dimension" />
77
<attr name="stripColor" format="color" />
8+
<attr name="stripOffset" format="dimension" />
89
<attr name="animationDurationMs" format="integer" />
910
<attr name="uniformCells" format="boolean" />
1011
</declare-styleable>

0 commit comments

Comments
 (0)