Skip to content

Commit

Permalink
闪烁问题 #97
Browse files Browse the repository at this point in the history
  • Loading branch information
liyujiang-gzu committed Mar 8, 2017
1 parent 5dd25b5 commit 7f79a4a
Show file tree
Hide file tree
Showing 7 changed files with 7,200 additions and 11 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7.3'
}
}
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ COMPILE_SDK_VERSION=23
MIN_SDK_VERSION=14
#安卓6.0开始(API23+),需要动态申请权限
TARGET_SDK_VERSION=23
BUILD_TOOL_VERSION=23.0.1
BUILD_TOOL_VERSION=25.0.0
ANDROID_SUPPORT_VERSION=latest.release
GROUP=cn.qqtheme.framework
SITE_URL=http://qqtheme.cn
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Wed Aug 10 00:49:00 CST 2016
#Fri Mar 03 00:22:35 CST 2017
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
4 changes: 4 additions & 0 deletions library/ColorPicker/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,7 @@ ext {
dependencies {
compile project(":library:Common")
}

android {
buildToolsVersion '25.0.0'
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public class DateTimePicker extends WheelPicker {
public @interface DateMode {
}

@IntDef(flag = false, value = {NONE, HOUR_24, HOUR_12, HOUR_OF_DAY, HOUR})
@IntDef(flag = false, value = {NONE, HOUR_24, HOUR_12})
@Retention(RetentionPolicy.SOURCE)
public @interface TimeMode {
}
Expand Down Expand Up @@ -321,20 +321,29 @@ public void setOnDateTimePickListener(OnDateTimePickListener listener) {

public String getSelectedYear() {
if (dateMode == YEAR_MONTH_DAY || dateMode == YEAR_MONTH) {
if (years.size() <= selectedYearIndex) {
selectedYearIndex = years.size() - 1;
}
return years.get(selectedYearIndex);
}
return "";
}

public String getSelectedMonth() {
if (dateMode != NONE) {
if (months.size() <= selectedMonthIndex) {
selectedMonthIndex = months.size() - 1;
}
return months.get(selectedMonthIndex);
}
return "";
}

public String getSelectedDay() {
if (dateMode == YEAR_MONTH_DAY || dateMode == MONTH_DAY) {
if (days.size() <= selectedDayIndex) {
selectedDayIndex = days.size() - 1;
}
return days.get(selectedDayIndex);
}
return "";
Expand Down Expand Up @@ -420,6 +429,11 @@ public void onSelected(boolean isUserScroll, int index, String item) {
int selectedYear = DateUtils.trimZero(item);
changeMonthData(selectedYear);
monthView.setItems(months, selectedMonthIndex);
if (months.size() <= selectedMonthIndex) {
selectedMonthIndex = months.size() - 1;
}
changeDayData(selectedYear, DateUtils.trimZero(months.get(selectedMonthIndex)));
dayView.setItems(days, selectedDayIndex);
}
});
layout.addView(yearView);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
public class WheelView extends ListView implements ListView.OnScrollListener, View.OnTouchListener,
ViewTreeObserver.OnGlobalLayoutListener {
public static final int SMOOTH_SCROLL_DURATION = 50;//ms
public static final int DELAY = 500;//ms

public static final int TEXT_SIZE = 16;//sp
public static final float TEXT_ALPHA = 0.8f;
Expand Down Expand Up @@ -240,26 +239,25 @@ public String getSelectedItem() {
}

public void setSelectedItem(String item) {
//noinspection deprecation
setSelection(adapter.getData().indexOf(item));
}

/**
* 设置滚轮位置
* @deprecated use {@link #setSelectedIndex(int)} instead
*/
@Override
@Deprecated
public void setSelection(int position) {
setVisibility(INVISIBLE);
final int realPosition = getRealPosition(position);
//延时一下以保证数据初始化完成,才定位到选中项
postDelayed(new Runnable() {
@Override
public void run() {
//LogUtils.verbose("post delayed, set selection to " + realPosition);
setVisibility(VISIBLE);
WheelView.super.setSelection(realPosition);
refreshCurrentPosition();
}
}, DELAY);
}, 500);
}

/**
Expand Down Expand Up @@ -715,6 +713,9 @@ public final String getItem(int position) {
if (isLoop) {
return data.size() > 0 ? data.get(position % data.size()) : null;
}
if (data.size() <= position) {
position = data.size() - 1;
}
return data.get(position);
}

Expand Down
Loading

0 comments on commit 7f79a4a

Please sign in to comment.