Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added Empty wheel activity to demo.

Fixed issue with last item (the previous fix was wrong)

git-svn-id: http://android-wheel.googlecode.com/svn/trunk@5 c364614a-9a97-51b3-f556-90fca60df64e
  • Loading branch information...
commit 4b4a4b8161d7195b687ec674640e6de1a734c924 1 parent c05c068
yuri.kanivets authored
View
6 wheel/AndroidManifest.xml
@@ -48,6 +48,12 @@
<category android:name="kankan.wheel.WHEEL_SAMPLE"/>
</intent-filter>
</activity>
+ <activity android:name="kankan.wheel.demo.EmptyActivity" android:label="Empty wheel">
+ <intent-filter>
+ <action android:name="android.intent.action.MAIN" />
+ <category android:name="kankan.wheel.WHEEL_SAMPLE"/>
+ </intent-filter>
+ </activity>
</application>
View
14 wheel/gen/kankan/wheel/R.java
@@ -18,12 +18,18 @@
}
public static final class id {
public static final int city=0x7f040000;
- public static final int hour=0x7f040001;
- public static final int mins=0x7f040002;
+ public static final int empty=0x7f040001;
+ public static final int hour=0x7f040006;
+ public static final int mins=0x7f040007;
+ public static final int passw_1=0x7f040002;
+ public static final int passw_2=0x7f040003;
+ public static final int passw_3=0x7f040004;
+ public static final int passw_4=0x7f040005;
}
public static final class layout {
public static final int cities_layout=0x7f030000;
- public static final int passw_layout=0x7f030001;
- public static final int time_layout=0x7f030002;
+ public static final int empty_layout=0x7f030001;
+ public static final int passw_layout=0x7f030002;
+ public static final int time_layout=0x7f030003;
}
}
View
29 wheel/res/layout/empty_layout.xml
@@ -0,0 +1,29 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ Copyright (C) 2010 Yuri Kanivets
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+-->
+
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_height="wrap_content"
+ android:orientation="vertical"
+ android:background="@drawable/layout_bg"
+ android:layout_width="fill_parent">
+
+ <kankan.wheel.widget.WheelView android:id="@+id/empty"
+ android:layout_height="wrap_content"
+ android:layout_width="fill_parent"/>
+
+</LinearLayout>
View
8 wheel/res/layout/passw_layout.xml
@@ -36,16 +36,16 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content">
- <kankan.wheel.widget.WheelView
+ <kankan.wheel.widget.WheelView android:id="@+id/passw_1"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView
+ <kankan.wheel.widget.WheelView android:id="@+id/passw_2"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView
+ <kankan.wheel.widget.WheelView android:id="@+id/passw_3"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
- <kankan.wheel.widget.WheelView
+ <kankan.wheel.widget.WheelView android:id="@+id/passw_4"
android:layout_height="wrap_content"
android:layout_width="wrap_content"/>
</LinearLayout>
View
32 wheel/src/kankan/wheel/demo/EmptyActivity.java
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2010 Yuri Kanivets
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+package kankan.wheel.demo;
+
+import kankan.wheel.R;
+
+import android.app.Activity;
+import android.os.Bundle;
+
+public class EmptyActivity extends Activity {
+ @Override
+ public void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+
+ setContentView(R.layout.empty_layout);
+ }
+}
View
16 wheel/src/kankan/wheel/demo/PasswActivity.java
@@ -18,6 +18,8 @@
package kankan.wheel.demo;
import kankan.wheel.R;
+import kankan.wheel.widget.NumericWheelAdapter;
+import kankan.wheel.widget.WheelView;
import android.app.Activity;
import android.os.Bundle;
@@ -27,5 +29,19 @@ public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.passw_layout);
+ initWheel(R.id.passw_1);
+ initWheel(R.id.passw_2);
+ initWheel(R.id.passw_3);
+ initWheel(R.id.passw_4);
+ }
+
+ /**
+ * Initializes wheel
+ * @param id the wheel widget id
+ */
+ private void initWheel(int id) {
+ WheelView wheel = (WheelView) findViewById(id);
+ wheel.setAdapter(new NumericWheelAdapter(0, 9));
+ wheel.setCurrentItem((int)(Math.random() * 10));
}
}
View
6 wheel/src/kankan/wheel/widget/WheelView.java
@@ -74,7 +74,7 @@
private static final int DEF_VISIBLE_ITEMS = 5;
// Wheel Values
- private WheelAdapter adapter = new NumericWheelAdapter(); // to do: do not initialize it
+ private WheelAdapter adapter = null;
private int currentItem = 0;
// Widths
@@ -283,7 +283,7 @@ private String buildText() {
itemsText.append("\n"); // here will be current value
- for (int i = currentItem + 1; i < currentItem + addItems; i++) {
+ for (int i = currentItem + 1; i <= currentItem + addItems; i++) {
if (adapter != null && i < adapter.getItemsCount()) {
String text = adapter.getItem(i);
if (text != null) {
@@ -553,7 +553,7 @@ public boolean onTouchEvent(MotionEvent event) {
int count = (int) (visibleItems * delta / getHeight());
int pos = currentItem - count;
pos = Math.max(pos, 0);
- pos = Math.min(pos, adapter.getItemsCount());
+ pos = Math.min(pos, adapter.getItemsCount() - 1);
if (pos != currentItem) {
lastYTouch = event.getY();
setCurrentItem(pos);
Please sign in to comment.
Something went wrong with that request. Please try again.