中通快递.apk(点击下载) / NetUpdateApkAsyncTask.java
package cn.beekee.zhongtong.util.net;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.AsyncTask;
import android.util.Log;
import cn.beekee.zhongtong.bean.UpdateCheckBean;
import cn.beekee.zhongtong.util.SweetDialogCreator;
import java.io.IOException;
import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
public class NetUpdateApkAsyncTask extends AsyncTask<Void, Void, UpdateCheckBean> {
public static final int LINK_TIME = 1000;
private static final String NET_UTF_8 = "utf-8";
public static final int READ_TIME = 2000;
String mCheckUrl = "http://www.zto.cn/app/zto_update.xml";
Context mContext;
Dialog mDialog;
IUpdateListener mListener;
public interface IUpdateListener {
void checkBean(UpdateCheckBean updateCheckBean);
}
public NetUpdateApkAsyncTask(Context context, IUpdateListener listener) {
this.mContext = context;
this.mListener = listener;
}
/* access modifiers changed from: protected */
public void onPreExecute() {
super.onPreExecute();
}
/* access modifiers changed from: protected */
/* JADX WARNING: Removed duplicated region for block: B:25:0x0067 A[SYNTHETIC, Splitter:B:25:0x0067] */
/* JADX WARNING: Removed duplicated region for block: B:32:0x0076 A[SYNTHETIC, Splitter:B:32:0x0076] */
/* JADX WARNING: Removed duplicated region for block: B:39:0x0085 A[SYNTHETIC, Splitter:B:39:0x0085] */
/* JADX WARNING: Removed duplicated region for block: B:46:0x0094 A[SYNTHETIC, Splitter:B:46:0x0094] */
/* JADX WARNING: Removed duplicated region for block: B:52:0x00a0 A[SYNTHETIC, Splitter:B:52:0x00a0] */
public UpdateCheckBean doInBackground(Void... params) {
Throwable th;
Exception e;
IOException e2;
MalformedURLException e3;
URISyntaxException e4;
UpdateCheckBean updateCheckBean = null;
InputStream inputStream = null;
try {
try {
URL url = new URI(this.mCheckUrl).toURL();
Log.e("", "更新Url:" + url);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setConnectTimeout(1000);
conn.setReadTimeout(2000);
conn.connect();
if (conn.getResponseCode() == 200) {
InputStream inputStream2 = conn.getInputStream();
updateCheckBean = UpdateCheckBean.parseUpdateXml(inputStream2);
if (inputStream2 != null) {
try {
inputStream2.close();
} catch (IOException e5) {
e5.printStackTrace();
}
}
} else if (0 != 0) {
try {
inputStream.close();
} catch (IOException e6) {
e6.printStackTrace();
}
}
} catch (URISyntaxException e7) {
e4 = e7;
try {
e4.printStackTrace();
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e8) {
e8.printStackTrace();
}
}
return updateCheckBean;
} catch (Throwable th2) {
th = th2;
if (0 != 0) {
}
throw th;
}
} catch (MalformedURLException e9) {
e3 = e9;
e3.printStackTrace();
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e10) {
e10.printStackTrace();
}
}
return updateCheckBean;
} catch (IOException e11) {
e2 = e11;
e2.printStackTrace();
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e12) {
e12.printStackTrace();
}
}
return updateCheckBean;
} catch (Exception e13) {
e = e13;
e.printStackTrace();
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e14) {
e14.printStackTrace();
}
}
return updateCheckBean;
} catch (Throwable th3) {
th = th3;
if (0 != 0) {
try {
inputStream.close();
} catch (IOException e15) {
e15.printStackTrace();
}
}
throw th;
}
} catch (URISyntaxException e16) {
e4 = e16;
e4.printStackTrace();
if (0 != 0) {
}
return updateCheckBean;
} catch (MalformedURLException e17) {
e3 = e17;
e3.printStackTrace();
if (0 != 0) {
}
return updateCheckBean;
} catch (IOException e18) {
e2 = e18;
e2.printStackTrace();
if (0 != 0) {
}
return updateCheckBean;
} catch (Exception e19) {
e = e19;
e.printStackTrace();
if (0 != 0) {
}
return updateCheckBean;
}
return updateCheckBean;
}
/* access modifiers changed from: protected */
public void onPostExecute(UpdateCheckBean updateLogBean) {
super.onPostExecute((Object) updateLogBean);
closeDialog();
if (this.mListener != null) {
this.mListener.checkBean(updateLogBean);
}
}
private void showDialog() {
this.mDialog = SweetDialogCreator.getLoadingDialog(this.mContext);
this.mDialog.setOnCancelListener(new DialogInterface.OnCancelListener() {
/* class cn.beekee.zhongtong.util.net.NetUpdateApkAsyncTask.AnonymousClass1 */
public void onCancel(DialogInterface dialog) {
dialog.dismiss();
NetUpdateApkAsyncTask.this.cancel(true);
}
});
this.mDialog.show();
}
private void closeDialog() {
if (this.mDialog != null) {
this.mDialog.dismiss();
}
}
}