Skip to content

Commit 677aec4

Browse files
committed
修复bug,异常加固
1 parent 83083be commit 677aec4

9 files changed

Lines changed: 58 additions & 35 deletions

File tree

‎.gitignore‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ build/
1212
local.properties
1313
proguard/
1414
*.log
15+
*.apk

‎app-release.apk‎

-742 KB
Binary file not shown.

‎app/build.gradle‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,34 @@ android {
2121

2222
}
2323

24+
tasks.all { task ->
25+
def name = task.name;
26+
if (name.contains("assemble") || name.contains("build")) {
27+
task.doLast {
28+
copyDebugApk();
29+
}
30+
}
31+
}
32+
33+
def copyDebugApk() {
34+
def debugOld = "${rootDir}/${project.name}/build/outputs/apk/app-debug.apk";
35+
def debugNew = "${rootDir}/app-debug.apk";
36+
def fis = new FileInputStream(debugOld);
37+
def fos = new FileOutputStream(debugNew);
38+
byte[] buffer = new byte[1024];
39+
while (true) {
40+
def len = fis.read(buffer);
41+
if (len == -1) {
42+
fis.close();
43+
fos.flush();
44+
fos.close();
45+
break;
46+
} else {
47+
fos.write(buffer, 0, len);
48+
}
49+
}
50+
}
51+
2452
dependencies {
2553
compile 'com.alibaba:fastjson:1.1.54.android'
2654
compile 'com.github.florent37:viewanimator:1.0.3'

‎app/src/main/java/cn/qqtheme/androidpicker/MainActivity.java‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ public void onOptionPicker(View view) {
150150
"第一项", "第二项", "这是一个很长很长很长很长很长很长很长很长很长的很长很长的很长很长的项"
151151
});
152152
picker.setOffset(2);
153-
picker.setSelectedIndex(1);
153+
picker.setSelectedIndex(0);
154154
picker.setTextSize(11);
155155
picker.setOnOptionPickListener(new OptionPicker.OnOptionPickListener() {
156156
@Override
@@ -225,6 +225,8 @@ public void onOptionPicked(int position, String option) {
225225

226226
public void onNumberPicker(View view) {
227227
NumberPicker picker = new NumberPicker(this);
228+
picker.setWidth(picker.getScreenWidthPixels() / 2);
229+
picker.setLineVisible(false);
228230
picker.setOffset(2);//偏移量
229231
picker.setRange(145, 200, 1);//数字范围
230232
picker.setSelectedItem(172);

‎gradle.properties‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ com.android.build.gradle.overridePathCheck=true
1515
#android.useDeprecatedNdk=true
1616

1717
#下面定义一些常量供gradle脚本使用
18-
VERSION_NAME=1.2.4
18+
VERSION_NAME=1.2.4.20161123
1919
VERSION_CODE=124
2020
COMPILE_SDK_VERSION=23
2121
MIN_SDK_VERSION=11

‎installApk.sh‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,6 @@
22
# -r: replace existing application
33
# -d: allow version code downgrade
44

5-
adb install -r -d ./app-release.apk
5+
#adb install -r -d ./app-release.apk
66

7+
adb install -r -d ./app-debug.apk

‎library/Common/src/main/java/cn/qqtheme/framework/popup/BasicPopup.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,14 @@ public BasicPopup(Activity activity) {
4444
popupDialog.setOnKeyListener(this);
4545
}
4646

47+
public int getScreenWidthPixels() {
48+
return screenWidthPixels;
49+
}
50+
51+
public int getScreenHeightPixels() {
52+
return screenHeightPixels;
53+
}
54+
4755
/**
4856
* 创建弹窗的内容视图
4957
*

‎library/WheelPicker/src/main/java/cn/qqtheme/framework/picker/DatePicker.java‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,14 @@ private void changeYearData() {
334334
private int changeMonthData(int year) {
335335
String preSelectMonth = months.size() > selectedMonthIndex ? months.get(selectedMonthIndex) : null;
336336
months.clear();
337+
if (startMonth < 1 || endMonth < 1 || startMonth > 12 || endMonth > 12) {
338+
throw new IllegalArgumentException("month out of range [1-12]");
339+
}
340+
if (startMonth > endMonth) {
341+
int tmp = startMonth;
342+
startMonth = endMonth;
343+
endMonth = tmp;
344+
}
337345
if (startYear == endYear) {
338346
for (int i = startMonth; i <= endMonth; i++) {
339347
months.add(DateUtils.fillZero(i));

‎library/WheelPicker/src/main/java/cn/qqtheme/framework/picker/OptionPicker.java‎

Lines changed: 7 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,9 @@
2222
public class OptionPicker extends WheelPicker {
2323
protected ArrayList<String> options = new ArrayList<String>();
2424
private OnOptionPickListener onOptionPickListener;
25-
private int selectedOption = 0;
25+
private int selectedOptionIndex = 0;
2626
private String label = "";
2727

28-
/**
29-
* Instantiates a new Option picker.
30-
*
31-
* @param activity the activity
32-
* @param options the options
33-
*/
3428
public OptionPicker(Activity activity, String[] options) {
3529
super(activity);
3630
this.options.addAll(Arrays.asList(options));
@@ -53,7 +47,7 @@ public void setLabel(String label) {
5347
*/
5448
public void setSelectedIndex(int index) {
5549
if (index >= 0 && index < options.size()) {
56-
selectedOption = index;
50+
selectedOptionIndex = index;
5751
}
5852
}
5953

@@ -93,11 +87,11 @@ protected View makeCenterView() {
9387
if (!TextUtils.isEmpty(label)) {
9488
labelView.setText(label);
9589
}
96-
optionView.setItems(options, selectedOption);
90+
optionView.setItems(options, selectedOptionIndex);
9791
optionView.setOnWheelViewListener(new WheelView.OnWheelViewListener() {
9892
@Override
9993
public void onSelected(boolean isUserScroll, int selectedIndex, String item) {
100-
selectedOption = selectedIndex;
94+
selectedOptionIndex = selectedIndex;
10195
}
10296
});
10397
return layout;
@@ -106,39 +100,20 @@ public void onSelected(boolean isUserScroll, int selectedIndex, String item) {
106100
@Override
107101
public void onSubmit() {
108102
if (onOptionPickListener != null) {
109-
onOptionPickListener.onOptionPicked(selectedOption, options.get(selectedOption));
103+
onOptionPickListener.onOptionPicked(selectedOptionIndex, options.get(selectedOptionIndex));
110104
}
111105
}
112106

113-
/**
114-
* Gets selected option.
115-
*
116-
* @return the selected option
117-
*/
118107
public String getSelectedOption() {
119-
return options.get(selectedOption);
108+
return options.get(selectedOptionIndex);
120109
}
121110

122-
/**
123-
* Get the selected position.
124-
*
125-
* @return the selected position
126-
*/
127111
public int getSelectedPosition() {
128-
return selectedOption;
112+
return selectedOptionIndex;
129113
}
130114

131-
/**
132-
* The interface On option pick listener.
133-
*/
134115
public interface OnOptionPickListener {
135116

136-
/**
137-
* On option picked.
138-
*
139-
* @param position the position you selected
140-
* @param option the option
141-
*/
142117
void onOptionPicked(int position, String option);
143118

144119
}

0 commit comments

Comments
 (0)