Skip to content

Commit b94f644

Browse files
committed
修复联动选择器联动时的一个数组越界异常
1 parent b2ba7f4 commit b94f644

10 files changed

Lines changed: 176 additions & 84 deletions

File tree

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -227,16 +227,16 @@ dependencies {
227227

228228
地址选择器(含省级、地级、县级):
229229
```java
230-
ArrayList<AddressPicker.Province> data = new ArrayList<AddressPicker.Province>();
230+
ArrayList<Province> data = new ArrayList<Province>();
231231
String json = AssetsUtils.readText(this, "city.json");
232-
data.addAll(JSON.parseArray(json, AddressPicker.Province.class));
232+
data.addAll(JSON.parseArray(json, Province.class));
233233
AddressPicker picker = new AddressPicker(this, result);
234234
picker.setSelectedItem("贵州", "贵阳", "花溪");
235235
//picker.setHideProvince(true);//加上此句举将只显示地级及县级
236236
//picker.setHideCounty(true);//加上此句举将只显示省级及地级
237237
picker.setOnAddressPickListener(new AddressPicker.OnAddressPickListener() {
238238
@Override
239-
public void onAddressPicked(String province, String city, String county) {
239+
public void onAddressPicked(Province province, City city, County county) {
240240
showToast(province + city + county);
241241
}
242242
});

app/proguard-rules.pro

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
*;
3939
}
4040

41+
#使用fastjson,不能混淆泛型和注解
4142
-keepattributes Exceptions,InnerClasses,Signature
4243
-keepattributes *Annotation*
4344

@@ -48,6 +49,5 @@
4849
-dontwarn android.support.**
4950
-keep class android.support.v4.** { *; }
5051

51-
#不混淆地址选择器的实体类,一般fastjson能正常解析
52+
#不混淆地址选择器的实体类,以便fastjson能正常解析
5253
-keep class cn.qqtheme.framework.entity.** { *;}
53-
-keep class cn.qqtheme.framework.picker.AddressPickerr$* { *;}

app/src/main/java/cn/qqtheme/androidpicker/MyApp.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ public class MyApp extends Application {
1717
public void onCreate() {
1818
super.onCreate();
1919
AppConfig.DEBUG_ENABLE = true;//BuildConfig.DEBUG;
20+
if (!AppConfig.DEBUG_ENABLE) {
21+
android.util.Log.d(AppConfig.DEBUG_TAG, "logcat is disabled");
22+
}
2023
}
2124

2225
}

build.gradle

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ buildscript {
55
jcenter()
66
}
77
dependencies {
8-
classpath 'com.android.tools.build:gradle:2.2.0'
8+
classpath 'com.android.tools.build:gradle:2.2.1'
99
classpath "com.jfrog.bintray.gradle:gradle-bintray-plugin:1.5"
1010
}
1111
}
@@ -181,7 +181,7 @@ subprojects {
181181

182182
bintray {
183183
// You should configure "bintray.user" and "bintray.apiKey" in the gradle.properties
184-
// that in gradle cache directory (${HOME}/.gradle/gradle.properties)
184+
// that in gradle cache directory (/.gradle/gradle.properties)
185185
user = safeGetProperty("bintray.user")
186186
key = safeGetProperty("bintray.apikey")
187187

library/Common/src/main/java/cn/qqtheme/framework/util/CompatUtils.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,10 @@ public static String getString(Context context, @StringRes int stringRes) {
6060
}
6161
}
6262

63+
@TargetApi(Build.VERSION_CODES.M)
6364
@ColorInt
6465
public static int getColor(Context context, @ColorRes int colorRes) {
65-
if (Build.VERSION.SDK_INT < 21) {
66+
if (Build.VERSION.SDK_INT < 23) {
6667
//noinspection deprecation
6768
return context.getResources().getColor(colorRes);
6869
} else {
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package cn.qqtheme.framework.entity;
2+
3+
/**
4+
* 省市县抽象,本类及其子类不可混淆
5+
* <br/>
6+
* Author:李玉江[QQ:1032694760]
7+
* DateTime:2016-10-15 19:06
8+
* Builder:Android Studio
9+
*/
10+
public abstract class Area {
11+
private String areaId;
12+
private String areaName;
13+
14+
public String getAreaId() {
15+
return areaId;
16+
}
17+
18+
public void setAreaId(String areaId) {
19+
this.areaId = areaId;
20+
}
21+
22+
public String getAreaName() {
23+
return areaName;
24+
}
25+
26+
public void setAreaName(String areaName) {
27+
this.areaName = areaName;
28+
}
29+
30+
@Override
31+
public String toString() {
32+
return "areaId=" + areaId + ",areaName=" + areaName;
33+
}
34+
35+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.qqtheme.framework.entity;
2+
3+
import java.util.ArrayList;
4+
5+
/**
6+
* 地市
7+
* <br/>
8+
* Author:李玉江[QQ:1032694760]
9+
* DateTime:2016-10-15 19:07
10+
* Builder:Android Studio
11+
*/
12+
public class City extends Area {
13+
private ArrayList<County> counties = new ArrayList<County>();
14+
15+
public ArrayList<County> getCounties() {
16+
return counties;
17+
}
18+
19+
public void setCounties(ArrayList<County> counties) {
20+
this.counties = counties;
21+
}
22+
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package cn.qqtheme.framework.entity;
2+
3+
/**
4+
* 区县
5+
* <br/>
6+
* Author:李玉江[QQ:1032694760]
7+
* DateTime:2016-10-15 19:08
8+
* Builder:Android Studio
9+
*/
10+
public class County extends Area {
11+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package cn.qqtheme.framework.entity;
2+
3+
import java.util.ArrayList;
4+
5+
/**
6+
* 省份
7+
* <br/>
8+
* Author:李玉江[QQ:1032694760]
9+
* DateTime:2016-10-15 19:06
10+
* Builder:Android Studio
11+
*/
12+
public class Province extends Area {
13+
private ArrayList<City> cities = new ArrayList<City>();
14+
15+
public ArrayList<City> getCities() {
16+
return cities;
17+
}
18+
19+
public void setCities(ArrayList<City> cities) {
20+
this.cities = cities;
21+
}
22+
23+
}

0 commit comments

Comments
 (0)