Skip to content

Commit 9469ec0

Browse files
committed
add attr wheelItemRotate
1 parent 691c5ea commit 9469ec0

File tree

7 files changed

+18
-10
lines changed

7 files changed

+18
-10
lines changed

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,15 @@ You can also receive a callback for when an item is clicked, and whether it is s
1717

1818
### Gradle
1919

20-
`compile 'github.hellocsl:CursorWheelLayout:1.0.1'`
20+
`compile 'github.hellocsl:CursorWheelLayout:1.0.2'`
2121

2222
### Maven
2323

2424
```xml
2525
<dependency>
2626
<groupId>github.hellocsl</groupId>
2727
<artifactId>CursorWheelLayout</artifactId>
28-
<version>1.0.1</version>
28+
<version>1.0.2</version>
2929
<type>pom</type>
3030
</dependency>
3131
```
@@ -111,6 +111,7 @@ public class SimpleTextAdapter implements CursorWheelLayout.CycleWheelAdapter{
111111
* wheelCursorHeight
112112
* wheelCursorColor
113113
* wheelBackgroundColor
114+
* wheelRotateItem
114115

115116

116117
## Refer to

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
android:layout_gravity="center_horizontal|top"
3434
app:wheelCursorColor="#009688"
3535
app:wheelCursorHeight="19dip"
36+
app:wheelRotateItem="false"
3637
app:wheelSelectedAngle="270">
3738

3839
<TextView

build.gradle

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.0.0'
9-
10-
classpath 'com.android.tools.build:gradle:1.2.3'
8+
classpath 'com.android.tools.build:gradle:2.2.0'
119
classpath 'com.novoda:bintray-release:0.3.4'
1210

1311
// NOTE: Do not place your application dependencies here; they belong

demo/app-debug.apk

-1.27 MB
Binary file not shown.

library/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ publish {
2929
userOrg = 'bcsl'
3030
groupId = 'github.hellocsl'
3131
artifactId = 'CursorWheelLayout'
32-
publishVersion = '1.0.1'
32+
publishVersion = '1.0.2'
3333
desc = 'An Android Widget for selecting items that rotate on a wheel'
3434
website = 'https://github.com/BCsl/CursorWheelLayout'
3535
}

library/src/main/java/github/hellocsl/cursorwheel/CursorWheelLayout.java

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@
2828
* @attr ref wheelFlingValue
2929
* @attr ref wheelCursorColor
3030
* @attr ref wheelCursorHeight
31-
* @see github.hellocsl.cursorwheel.R.attr
31+
* @attr ref wheelRotateItem
32+
* @see R.github.hellocsl.cursorwheel.R.attr
3233
*/
3334
public class CursorWheelLayout extends ViewGroup {
3435
private static final String TAG = "CircleMenuLayout";
@@ -174,6 +175,7 @@ public class CursorWheelLayout extends ViewGroup {
174175

175176
private int mTriangleHeight;
176177

178+
177179
/**
178180
* callback on menu item being click
179181
*/
@@ -197,6 +199,8 @@ public class CursorWheelLayout extends ViewGroup {
197199
private float mCenterRadioDimension;
198200
private float mPaddingRadio;
199201

202+
private boolean mRotateItem;
203+
200204
public CursorWheelLayout(Context context) {
201205
this(context, null);
202206
}
@@ -234,6 +238,7 @@ private void initWheel(Context context, AttributeSet attrs) {
234238
mMenuRadioDimension = ta.getFloat(R.styleable.CursorWheelLayout_wheelItemRadio, RADIO_DEFAULT_CHILD_DIMENSION);
235239
mCenterRadioDimension = ta.getFloat(R.styleable.CursorWheelLayout_wheelCenterRadio, RADIO_DEFAULT_CENTER_DIMENSION);
236240
mPaddingRadio = ta.getFloat(R.styleable.CursorWheelLayout_wheelPaddingRadio, RADIO_PADDING_LAYOUT);
241+
mRotateItem = ta.getBoolean(R.styleable.CursorWheelLayout_wheelRotateItem, true);
237242
ta.recycle();
238243
}
239244
init(context);
@@ -417,9 +422,11 @@ protected void onLayout(boolean changed, int l, int t, int r, int b) {
417422
* cWidth);
418423

419424
child.layout(left, top, left + cWidth, top + cWidth);
420-
child.setPivotX(cWidth / 2.0f);
421-
child.setPivotY(cWidth / 2.0f);
422-
child.setRotation((float) (90 + mStartAngle));
425+
if (mRotateItem) {
426+
child.setPivotX(cWidth / 2.0f);
427+
child.setPivotY(cWidth / 2.0f);
428+
child.setRotation((float) (90 + mStartAngle));
429+
}
423430
mStartAngle += angleDelay;
424431

425432
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,6 @@
99
<attr name="wheelCursorHeight" format="dimension"></attr>
1010
<attr name="wheelCursorColor" format="color"></attr>
1111
<attr name="wheelBackgroundColor" format="color"></attr>
12+
<attr name="wheelRotateItem" format="boolean"></attr>
1213
</declare-styleable>
1314
</resources>

0 commit comments

Comments
 (0)