Skip to content

Commit

Permalink
修改1.0.0bug
Browse files Browse the repository at this point in the history
  • Loading branch information
lihuichao committed Sep 30, 2017
1 parent 3c02869 commit cb33131
Show file tree
Hide file tree
Showing 4 changed files with 90 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions addresspickerlibrary/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apply plugin: 'com.android.library'

apply plugin: 'com.github.dcendents.android-maven'
group='com.github.CHAOHUILI'
android {
compileSdkVersion 26
buildToolsVersion "25.0.2"
Expand All @@ -22,5 +23,6 @@ android {
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.alibaba:fastjson:1.2.38'
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
package com.addresspicker.huichao.addresspickerlibrary;

import android.content.Context;
import android.os.AsyncTask;
import android.widget.Toast;


import com.addresspicker.huichao.addresspickerlibrary.address.Province;
import com.alibaba.fastjson.JSON;

import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;

/**
* Created by lihuichao on 2017/9/27.
*/

public class InitAreaTask extends AsyncTask<Integer, Integer, Boolean> {
protected onLoadingAddressListener onLoadingAddressListener;
Context mContext;
ArrayList<Province> provinces;


public InitAreaTask(Context context, ArrayList<Province> provinces) {
mContext = context;
this.provinces = provinces;
}

public void setOnLoadingAddressListener(onLoadingAddressListener onLoadingAddressListener) {
this.onLoadingAddressListener = onLoadingAddressListener;
}

@Override
protected void onPreExecute() {
}

@Override
protected void onPostExecute(Boolean result) {
if (provinces.size() > 0) {
this.onLoadingAddressListener.onLoadFinished();
} else {
Toast.makeText(mContext, "数据初始化失败", Toast.LENGTH_SHORT).show();
}
}

@Override
protected Boolean doInBackground(Integer... params) {
String address = null;
InputStream in = null;
try {
in = mContext.getResources().getAssets().open("address.txt");
byte[] arrayOfByte = new byte[in.available()];
in.read(arrayOfByte);
address = new String(arrayOfByte, "UTF-8");

List<Province> provinces1 = JSON.parseArray(address, Province.class);
provinces.addAll(provinces1);
return true;
} catch (Exception e) {
e.printStackTrace();
} finally {
if (in != null) {
try {
in.close();
} catch (IOException e) {
}
}
}
return false;
}

public interface onLoadingAddressListener {
void onLoadFinished();
}

}
3 changes: 2 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ buildscript {
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'

classpath 'com.github.dcendents:android-maven-gradle-plugin:1.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
Expand All @@ -15,6 +15,7 @@ buildscript {
allprojects {
repositories {
jcenter()
maven { url "https://jitpack.io"}
}
}

Expand Down

0 comments on commit cb33131

Please sign in to comment.