From 8b60859804bba9b5d1fe45938455ce86751e23e3 Mon Sep 17 00:00:00 2001 From: jonatansalas Date: Tue, 24 Jan 2017 21:42:10 -0300 Subject: [PATCH 01/29] General project update --- .idea/gradle.xml | 8 +- app/app.iml | 95 ++++++++++++++----- app/build.gradle | 18 ++-- .../com/bruce/pickerview/LoopViewTest.java | 4 +- build.gradle | 2 +- gradle/wrapper/gradle-wrapper.properties | 4 +- library/build.gradle | 8 +- library/library.iml | 49 +++++++--- .../popwindow/DatePickerPopWin.java | 52 +++++----- 9 files changed, 151 insertions(+), 89 deletions(-) diff --git a/.idea/gradle.xml b/.idea/gradle.xml index 5dea0cc..6ce9107 100644 --- a/.idea/gradle.xml +++ b/.idea/gradle.xml @@ -13,13 +13,7 @@ - + diff --git a/app/app.iml b/app/app.iml index ddc510c..8d9524b 100644 --- a/app/app.iml +++ b/app/app.iml @@ -32,12 +32,14 @@ + + @@ -64,14 +66,6 @@ - - - - - - - - @@ -80,41 +74,96 @@ + + + + + + + + - - - - - + + + + + + + + + + + + - - - - + - + - + - - + + + + + + + + + + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + + + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 75ae432..32d5071 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,13 +2,13 @@ apply plugin: 'com.android.application' apply plugin: 'cobertura' android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion 25 + buildToolsVersion "23.0.3" defaultConfig { applicationId "com.brucetoo.pickview" minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 versionCode 1 versionName "1.0" } @@ -32,13 +32,13 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' -// testCompile 'org.mockito:mockito-core:1.10.19' -// testCompile 'org.robolectric:robolectric:3.1' -// testCompile 'org.powermock:powermock-module-junit4:1.6.3' -// testCompile 'org.powermock:powermock-api-mockito:1.6.3' + testCompile 'org.mockito:mockito-core:1.10.19' + testCompile 'org.robolectric:robolectric:3.1' + testCompile 'org.powermock:powermock-module-junit4:1.6.3' + testCompile 'org.powermock:powermock-api-mockito:1.6.3' - compile 'com.android.support:appcompat-v7:23.0.1' - compile 'com.android.support:design:23.0.1' + compile 'com.android.support:appcompat-v7:25.1.0' + compile 'com.android.support:design:25.1.0' compile project(":library") // compile 'com.brucetoo.pickview:library:1.1.1' } diff --git a/app/src/test/java/com/bruce/pickerview/LoopViewTest.java b/app/src/test/java/com/bruce/pickerview/LoopViewTest.java index 87b3516..790e0e5 100644 --- a/app/src/test/java/com/bruce/pickerview/LoopViewTest.java +++ b/app/src/test/java/com/bruce/pickerview/LoopViewTest.java @@ -12,7 +12,6 @@ import org.robolectric.RobolectricGradleTestRunner; import org.robolectric.annotation.Config; -import java.util.ArrayList; import java.util.Arrays; import static org.junit.Assert.assertEquals; @@ -29,10 +28,9 @@ public void setUp() { loopView = new LoopView(mContext); loopView.setTextSize(12.0f); - loopView.setNotLoop(); Whitebox.setInternalState(loopView, "maxTextHeight", 12); - loopView.setArrayList(new ArrayList(Arrays.asList("1", "2", "3", "4", "5", "6", "7"))); + loopView.setDataList(Arrays.asList("1", "2", "3", "4", "5", "6", "7")); loopView.setInitPosition(3); } diff --git a/build.gradle b/build.gradle index 9a18025..42641c1 100644 --- a/build.gradle +++ b/build.gradle @@ -5,7 +5,7 @@ buildscript { jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:1.3.0' + classpath 'com.android.tools.build:gradle:2.2.3' classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.0' classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3' // classpath 'com.dicedmelon.gradle:jacoco-android:0.1.1' diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 8f609a7..d245365 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Sat Jul 09 16:25:30 CST 2016 +#Tue Jan 24 21:04:08 ART 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip diff --git a/library/build.gradle b/library/build.gradle index 7137204..8920366 100644 --- a/library/build.gradle +++ b/library/build.gradle @@ -4,12 +4,12 @@ apply plugin: 'com.android.library' version = "1.1.1" android { - compileSdkVersion 23 - buildToolsVersion "23.0.1" + compileSdkVersion 25 + buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 14 - targetSdkVersion 23 + targetSdkVersion 25 versionCode 2 versionName "1.1.1" } @@ -98,5 +98,5 @@ android { dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' - compile 'com.android.support:appcompat-v7:23.1.0' + compile 'com.android.support:appcompat-v7:25.1.0' } diff --git a/library/library.iml b/library/library.iml index 2336a57..203ce5a 100644 --- a/library/library.iml +++ b/library/library.iml @@ -33,12 +33,14 @@ + + @@ -48,6 +50,7 @@ + @@ -55,6 +58,7 @@ + @@ -62,13 +66,7 @@ - - - - - - - + @@ -76,31 +74,56 @@ + + + + + + + + + - + + + + + + + + + - + + - + - - + + + + + - + + + + + \ No newline at end of file diff --git a/library/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java b/library/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java index 9aaa0eb..3ba312e 100644 --- a/library/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java +++ b/library/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java @@ -58,16 +58,17 @@ public class DatePickerPopWin extends PopupWindow implements OnClickListener { private int viewTextSize; private boolean showDayMonthYear; - List yearList = new ArrayList(); - List monthList = new ArrayList(); - List dayList = new ArrayList(); + private final List yearList = new ArrayList<>(); + private final List monthList = new ArrayList<>(); + private final List dayList = new ArrayList<>(); - public static class Builder{ + public static class Builder { //Required private Context context; private OnDatePickedListener listener; - public Builder(Context context,OnDatePickedListener listener){ + + public Builder(Context context,OnDatePickedListener listener) { this.context = context; this.listener = listener; } @@ -84,37 +85,37 @@ public Builder(Context context,OnDatePickedListener listener){ private int btnTextSize = 16;//text btnTextsize of cancel and confirm button private int viewTextSize = 25; - public Builder minYear(int minYear){ + public Builder minYear(int minYear) { this.minYear = minYear; return this; } - public Builder maxYear(int maxYear){ + public Builder maxYear(int maxYear) { this.maxYear = maxYear; return this; } - public Builder textCancel(String textCancel){ + public Builder textCancel(String textCancel) { this.textCancel = textCancel; return this; } - public Builder textConfirm(String textConfirm){ + public Builder textConfirm(String textConfirm) { this.textConfirm = textConfirm; return this; } - public Builder dateChose(String dateChose){ + public Builder dateChose(String dateChose) { this.dateChose = dateChose; return this; } - public Builder colorCancel(int colorCancel){ + public Builder colorCancel(int colorCancel) { this.colorCancel = colorCancel; return this; } - public Builder colorConfirm(int colorConfirm){ + public Builder colorConfirm(int colorConfirm) { this.colorConfirm = colorConfirm; return this; } @@ -123,18 +124,18 @@ public Builder colorConfirm(int colorConfirm){ * set btn text btnTextSize * @param textSize dp */ - public Builder btnTextSize(int textSize){ + public Builder btnTextSize(int textSize) { this.btnTextSize = textSize; return this; } - public Builder viewTextSize(int textSize){ + public Builder viewTextSize(int textSize) { this.viewTextSize = textSize; return this; } - public DatePickerPopWin build(){ - if(minYear > maxYear){ + public DatePickerPopWin build() { + if(minYear > maxYear) { throw new IllegalArgumentException(); } return new DatePickerPopWin(this); @@ -146,7 +147,7 @@ public Builder showDayMonthYear(boolean useDayMonthYear) { } } - public DatePickerPopWin(Builder builder){ + public DatePickerPopWin(Builder builder) { this.minYear = builder.minYear; this.maxYear = builder.maxYear; this.textCancel = builder.textCancel; @@ -217,11 +218,11 @@ public void onItemSelect(int item) { confirmBtn.setOnClickListener(this); contentView.setOnClickListener(this); - if(!TextUtils.isEmpty(textConfirm)){ + if(!TextUtils.isEmpty(textConfirm)) { confirmBtn.setText(textConfirm); } - if(!TextUtils.isEmpty(textCancel)){ + if(!TextUtils.isEmpty(textCancel)) { cancelBtn.setText(textCancel); } @@ -240,7 +241,6 @@ public void onItemSelect(int item) { * Let the day loop view be handled separately */ private void initPickerViews() { - int yearCount = maxYear - minYear; for (int i = 0; i < yearCount; i++) { @@ -251,10 +251,10 @@ private void initPickerViews() { monthList.add(format2LenStr(j + 1)); } - yearLoopView.setDataList((ArrayList) yearList); + yearLoopView.setDataList(yearList); yearLoopView.setInitPosition(yearPos); - monthLoopView.setDataList((ArrayList) monthList); + monthLoopView.setDataList(monthList); monthLoopView.setInitPosition(monthPos); } @@ -265,7 +265,7 @@ private void initDayPickerView() { int dayMaxInMonth; Calendar calendar = Calendar.getInstance(); - dayList = new ArrayList(); + //dayList = new ArrayList<>(); calendar.set(Calendar.YEAR, minYear + yearPos); calendar.set(Calendar.MONTH, monthPos); @@ -277,7 +277,7 @@ private void initDayPickerView() { dayList.add(format2LenStr(i + 1)); } - dayLoopView.setDataList((ArrayList) dayList); + dayLoopView.setDataList(dayList); dayLoopView.setInitPosition(dayPos); } @@ -426,7 +426,6 @@ public static int spToPx(Context context, int spValue) { return (int) (spValue * fontScale + 0.5f); } - public interface OnDatePickedListener { /** @@ -437,7 +436,6 @@ public interface OnDatePickedListener { * @param day * @param dateDesc yyyy-MM-dd */ - void onDatePickCompleted(int year, int month, int day, - String dateDesc); + void onDatePickCompleted(int year, int month, int day, String dateDesc); } } From 89af1a048f1547172d6fc4c482f47f0873573a5a Mon Sep 17 00:00:00 2001 From: jonatansalas Date: Thu, 26 Jan 2017 10:25:39 -0300 Subject: [PATCH 02/29] Remove .idea folder --- .gitignore | 1 + .idea/.name | 1 - .idea/compiler.xml | 22 ------- .idea/copyright/profiles_settings.xml | 3 - .idea/encodings.xml | 6 -- .idea/gradle.xml | 20 ------ .idea/inspectionProfiles/Project_Default.xml | 11 ---- .../inspectionProfiles/profiles_settings.xml | 7 --- .idea/misc.xml | 62 ------------------- .idea/modules.xml | 10 --- .idea/runConfigurations.xml | 12 ---- .idea/vcs.xml | 6 -- 12 files changed, 1 insertion(+), 160 deletions(-) delete mode 100644 .idea/.name delete mode 100644 .idea/compiler.xml delete mode 100644 .idea/copyright/profiles_settings.xml delete mode 100644 .idea/encodings.xml delete mode 100644 .idea/gradle.xml delete mode 100644 .idea/inspectionProfiles/Project_Default.xml delete mode 100644 .idea/inspectionProfiles/profiles_settings.xml delete mode 100644 .idea/misc.xml delete mode 100644 .idea/modules.xml delete mode 100644 .idea/runConfigurations.xml delete mode 100644 .idea/vcs.xml diff --git a/.gitignore b/.gitignore index 83d6d47..00f1190 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ /build /captures .iml +.idea diff --git a/.idea/.name b/.idea/.name deleted file mode 100644 index aa622eb..0000000 --- a/.idea/.name +++ /dev/null @@ -1 +0,0 @@ -PickView \ No newline at end of file diff --git a/.idea/compiler.xml b/.idea/compiler.xml deleted file mode 100644 index 9a8b7e5..0000000 --- a/.idea/compiler.xml +++ /dev/null @@ -1,22 +0,0 @@ - - - - - \ No newline at end of file diff --git a/.idea/copyright/profiles_settings.xml b/.idea/copyright/profiles_settings.xml deleted file mode 100644 index e7bedf3..0000000 --- a/.idea/copyright/profiles_settings.xml +++ /dev/null @@ -1,3 +0,0 @@ - - - \ No newline at end of file diff --git a/.idea/encodings.xml b/.idea/encodings.xml deleted file mode 100644 index 97626ba..0000000 --- a/.idea/encodings.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/gradle.xml b/.idea/gradle.xml deleted file mode 100644 index 6ce9107..0000000 --- a/.idea/gradle.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml deleted file mode 100644 index 4a3785f..0000000 --- a/.idea/inspectionProfiles/Project_Default.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml deleted file mode 100644 index 3b31283..0000000 --- a/.idea/inspectionProfiles/profiles_settings.xml +++ /dev/null @@ -1,7 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 5b8df39..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 1.7 - - - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index 31a029c..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations.xml b/.idea/runConfigurations.xml deleted file mode 100644 index 7f68460..0000000 --- a/.idea/runConfigurations.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/vcs.xml b/.idea/vcs.xml deleted file mode 100644 index 94a25f7..0000000 --- a/.idea/vcs.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file From 0a0da963ba58e5c79019ad5a67a402d367ef846e Mon Sep 17 00:00:00 2001 From: jonatansalas Date: Thu, 26 Jan 2017 10:28:19 -0300 Subject: [PATCH 03/29] Major changes --- app/app.iml | 2 +- app/build.gradle | 2 +- .../com/brucetoo/pickview/MainActivity.java | 4 +-- settings.gradle | 2 +- {library => wheelview}/.gitignore | 0 {library => wheelview}/build.gradle | 0 {library => wheelview}/pickerview.iml | 0 {library => wheelview}/proguard-rules.pro | 0 .../com/bruce/pickerview/ApplicationTest.java | 0 .../src/main/AndroidManifest.xml | 0 .../bruce/pickerview/LoopScrollListener.java | 0 .../java/com/bruce/pickerview/LoopView.java | 29 +++++++++---------- .../popwindow/DatePickerPopWin.java | 0 .../main/res/anim/pop_win_content_fade_in.xml | 0 .../res/anim/pop_win_content_fade_out.xml | 0 .../main/res/layout/layout_date_picker.xml | 0 .../layout/layout_date_picker_inverted.xml | 26 +++++++++++------ .../src/main/res/values/attrs.xml | 0 .../src/main/res/values/color.xml | 0 .../src/main/res/values/dimen.xml | 0 .../src/main/res/values/strings.xml | 0 .../src/main/res/values/styles.xml | 0 .../com/bruce/pickerview/ExampleUnitTest.java | 0 .../library.iml => wheelview/wheelview.iml | 24 +++++++-------- 24 files changed, 48 insertions(+), 41 deletions(-) rename {library => wheelview}/.gitignore (100%) rename {library => wheelview}/build.gradle (100%) rename {library => wheelview}/pickerview.iml (100%) rename {library => wheelview}/proguard-rules.pro (100%) rename {library => wheelview}/src/androidTest/java/com/bruce/pickerview/ApplicationTest.java (100%) rename {library => wheelview}/src/main/AndroidManifest.xml (100%) rename {library => wheelview}/src/main/java/com/bruce/pickerview/LoopScrollListener.java (100%) rename {library => wheelview}/src/main/java/com/bruce/pickerview/LoopView.java (97%) rename {library => wheelview}/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java (100%) rename {library => wheelview}/src/main/res/anim/pop_win_content_fade_in.xml (100%) rename {library => wheelview}/src/main/res/anim/pop_win_content_fade_out.xml (100%) rename {library => wheelview}/src/main/res/layout/layout_date_picker.xml (100%) rename {library => wheelview}/src/main/res/layout/layout_date_picker_inverted.xml (80%) rename {library => wheelview}/src/main/res/values/attrs.xml (100%) rename {library => wheelview}/src/main/res/values/color.xml (100%) rename {library => wheelview}/src/main/res/values/dimen.xml (100%) rename {library => wheelview}/src/main/res/values/strings.xml (100%) rename {library => wheelview}/src/main/res/values/styles.xml (100%) rename {library => wheelview}/src/test/java/com/bruce/pickerview/ExampleUnitTest.java (100%) rename library/library.iml => wheelview/wheelview.iml (96%) diff --git a/app/app.iml b/app/app.iml index 8d9524b..1eab5d2 100644 --- a/app/app.iml +++ b/app/app.iml @@ -164,6 +164,6 @@ - + \ No newline at end of file diff --git a/app/build.gradle b/app/build.gradle index 32d5071..423f92c 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -39,7 +39,7 @@ dependencies { compile 'com.android.support:appcompat-v7:25.1.0' compile 'com.android.support:design:25.1.0' - compile project(":library") + compile project(':wheelview') // compile 'com.brucetoo.pickview:library:1.1.1' } diff --git a/app/src/main/java/com/brucetoo/pickview/MainActivity.java b/app/src/main/java/com/brucetoo/pickview/MainActivity.java index 702bd9a..6267744 100644 --- a/app/src/main/java/com/brucetoo/pickview/MainActivity.java +++ b/app/src/main/java/com/brucetoo/pickview/MainActivity.java @@ -41,7 +41,7 @@ public void onDatePickCompleted(int year, int month, int day, String dateDesc) { }).textConfirm("CONFIRM") //text of confirm button .textCancel("CANCEL") //text of cancel button .btnTextSize(16) // button text size - .viewTextSize(25) // pick view text size + .viewTextSize(12) // pick view text size .colorCancel(Color.parseColor("#999999")) //color of cancel button .colorConfirm(Color.parseColor("#009900"))//color of confirm button .minYear(1990) //min year in loop @@ -74,7 +74,7 @@ public void onItemSelect(int item) { } }); - loopView.setTextSize(25);//must be called before setDateList + loopView.setTextSize(12);//must be called before setDateList loopView.setDataList(getList()); // ((new ProvinceInfoParserTask(this, mHandler))).execute();// 解析本地地址信息文件 } diff --git a/settings.gradle b/settings.gradle index 3306997..e4e9c64 100644 --- a/settings.gradle +++ b/settings.gradle @@ -1 +1 @@ -include ':app', ':library' +include ':app', ':wheelview' diff --git a/library/.gitignore b/wheelview/.gitignore similarity index 100% rename from library/.gitignore rename to wheelview/.gitignore diff --git a/library/build.gradle b/wheelview/build.gradle similarity index 100% rename from library/build.gradle rename to wheelview/build.gradle diff --git a/library/pickerview.iml b/wheelview/pickerview.iml similarity index 100% rename from library/pickerview.iml rename to wheelview/pickerview.iml diff --git a/library/proguard-rules.pro b/wheelview/proguard-rules.pro similarity index 100% rename from library/proguard-rules.pro rename to wheelview/proguard-rules.pro diff --git a/library/src/androidTest/java/com/bruce/pickerview/ApplicationTest.java b/wheelview/src/androidTest/java/com/bruce/pickerview/ApplicationTest.java similarity index 100% rename from library/src/androidTest/java/com/bruce/pickerview/ApplicationTest.java rename to wheelview/src/androidTest/java/com/bruce/pickerview/ApplicationTest.java diff --git a/library/src/main/AndroidManifest.xml b/wheelview/src/main/AndroidManifest.xml similarity index 100% rename from library/src/main/AndroidManifest.xml rename to wheelview/src/main/AndroidManifest.xml diff --git a/library/src/main/java/com/bruce/pickerview/LoopScrollListener.java b/wheelview/src/main/java/com/bruce/pickerview/LoopScrollListener.java similarity index 100% rename from library/src/main/java/com/bruce/pickerview/LoopScrollListener.java rename to wheelview/src/main/java/com/bruce/pickerview/LoopScrollListener.java diff --git a/library/src/main/java/com/bruce/pickerview/LoopView.java b/wheelview/src/main/java/com/bruce/pickerview/LoopView.java similarity index 97% rename from library/src/main/java/com/bruce/pickerview/LoopView.java rename to wheelview/src/main/java/com/bruce/pickerview/LoopView.java index 7eed48b..1b5a909 100644 --- a/library/src/main/java/com/bruce/pickerview/LoopView.java +++ b/wheelview/src/main/java/com/bruce/pickerview/LoopView.java @@ -10,6 +10,7 @@ import android.os.Build; import android.os.Handler; import android.os.Message; +import android.support.annotation.NonNull; import android.util.AttributeSet; import android.util.Log; import android.view.GestureDetector; @@ -38,7 +39,6 @@ public class LoopView extends View { private GestureDetector mGestureDetector; private int mSelectedItem; private GestureDetector.SimpleOnGestureListener mOnGestureListener; - private Context mContext; private Paint mTopBottomTextPaint; //paint that draw top and bottom text private Paint mCenterTextPaint; // paint that draw center text private Paint mCenterLinePaint; // paint that draw line besides center text @@ -64,7 +64,6 @@ public class LoopView extends View { private int mCircularRadius; private int mWidgetWidth; - public Handler mHandler = new Handler(new Handler.Callback() { @Override public boolean handleMessage(Message msg) { @@ -88,34 +87,35 @@ public LoopView(Context context, AttributeSet attrs) { public LoopView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); - initView(context,attrs); + if (!isInEditMode()) { + initView(attrs); + } } - @TargetApi(Build.VERSION_CODES.LOLLIPOP) public LoopView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) { super(context, attrs, defStyleAttr, defStyleRes); - initView(context,attrs); + if (!isInEditMode()) { + initView(attrs); + } } + private void initView(@NonNull AttributeSet attrs) { + TypedArray array = getContext().obtainStyledAttributes(attrs, R.styleable.LoopView); - private void initView(Context context,AttributeSet attrs) { - TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.LoopView); if (array != null) { mTopBottomTextColor = array.getColor(R.styleable.LoopView_topBottomTextColor, 0xffafafaf); mCenterTextColor = array.getColor(R.styleable.LoopView_centerTextColor, 0xff313131); mCenterLineColor = array.getColor(R.styleable.LoopView_lineColor, 0xffc5c5c5); mCanLoop = array.getBoolean(R.styleable.LoopView_canLoop, true); mInitPosition = array.getInt(R.styleable.LoopView_initPosition, -1); - mTextSize = array.getDimensionPixelSize(R.styleable.LoopView_textSize, sp2px(context, 16)); + mTextSize = array.getDimensionPixelSize(R.styleable.LoopView_textSize, sp2px(getContext(), 16)); mDrawItemsCount = array.getInt(R.styleable.LoopView_drawItemCount, 7); array.recycle(); } lineSpacingMultiplier = 2.0F; - this.mContext = context; - mOnGestureListener = new LoopViewGestureListener(); mTopBottomTextPaint = new Paint(); @@ -126,16 +126,16 @@ private void initView(Context context,AttributeSet attrs) { setLayerType(LAYER_TYPE_SOFTWARE, null); } - mGestureDetector = new GestureDetector(context, mOnGestureListener); + mGestureDetector = new GestureDetector(getContext(), mOnGestureListener); mGestureDetector.setIsLongpressEnabled(false); } private void initData() { - if (mDataList == null) { throw new IllegalArgumentException("data list must not be null!"); } + mTopBottomTextPaint.setColor(mTopBottomTextColor); mTopBottomTextPaint.setAntiAlias(true); mTopBottomTextPaint.setTypeface(Typeface.MONOSPACE); @@ -213,7 +213,6 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { mBottomLineY = (int) ((mCircularDiameter + mItemHeight) / 2.0F) + mPaddingTopBottom; } - @Override protected void onDraw(Canvas canvas) { @@ -327,7 +326,6 @@ protected void onDraw(Canvas canvas) { @Override public boolean onTouchEvent(MotionEvent motionevent) { - switch (motionevent.getAction()) { case MotionEvent.ACTION_UP: default: @@ -335,6 +333,7 @@ public boolean onTouchEvent(MotionEvent motionevent) { startSmoothScrollTo(); } } + return true; } @@ -350,7 +349,7 @@ public final void setCanLoop(boolean canLoop) { */ public final void setTextSize(float size) { if (size > 0) { - mTextSize = sp2px(mContext, size); + mTextSize = sp2px(getContext(), size); } } diff --git a/library/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java b/wheelview/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java similarity index 100% rename from library/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java rename to wheelview/src/main/java/com/bruce/pickerview/popwindow/DatePickerPopWin.java diff --git a/library/src/main/res/anim/pop_win_content_fade_in.xml b/wheelview/src/main/res/anim/pop_win_content_fade_in.xml similarity index 100% rename from library/src/main/res/anim/pop_win_content_fade_in.xml rename to wheelview/src/main/res/anim/pop_win_content_fade_in.xml diff --git a/library/src/main/res/anim/pop_win_content_fade_out.xml b/wheelview/src/main/res/anim/pop_win_content_fade_out.xml similarity index 100% rename from library/src/main/res/anim/pop_win_content_fade_out.xml rename to wheelview/src/main/res/anim/pop_win_content_fade_out.xml diff --git a/library/src/main/res/layout/layout_date_picker.xml b/wheelview/src/main/res/layout/layout_date_picker.xml similarity index 100% rename from library/src/main/res/layout/layout_date_picker.xml rename to wheelview/src/main/res/layout/layout_date_picker.xml diff --git a/library/src/main/res/layout/layout_date_picker_inverted.xml b/wheelview/src/main/res/layout/layout_date_picker_inverted.xml similarity index 80% rename from library/src/main/res/layout/layout_date_picker_inverted.xml rename to wheelview/src/main/res/layout/layout_date_picker_inverted.xml index 89ba1ba..8ddcc22 100644 --- a/library/src/main/res/layout/layout_date_picker_inverted.xml +++ b/wheelview/src/main/res/layout/layout_date_picker_inverted.xml @@ -1,9 +1,10 @@ - + + android:textSize="@dimen/btn_text_size" + tools:text="cancel" />