AlertDialog弹出ProgressDialog时,AlertDialog卡住

如题,求各位大神帮忙看下是什么问题,小弟先谢过。

AlertDialog.Builder builder = new Builder(
EngineeringParametersActivity.this);
builder.setMessage(message);
builder.setTitle("提示");
builder.setPositiveButton("确认", new DialogInterface.OnClickListener() {

@Override
public void onClick(DialogInterface dialog, int which) {
String msg = "";
if (tag == STATE_DOWNLOAD) {
msg = "正在下载中,请稍后...";
setDialogMessage(msg);
DownLoading();
} else if (tag == STATE_APPLICATION) {
msg = "加载应用中,请稍后...";
setDialogMessage(msg);
Applicationing();
} else if (tag == STATE_NOT_SELECTED
|| tag == STATE_HAVE_DOWNLOAD
|| tag == STATE_NOT_DOWNLOAD)
return;
}
});

下载方法:
String[] whole = data.get(selectId).path.split("/");
final String remotePath = "/" + whole[3] + "/" + whole[4] + "/"
+ whole[5];
final FTPUtils ftpUtils = FTPUtils.getInstance();
new Thread(new Runnable() {
@Override
public void run() {
ftpUtils.initFTPSetting(HttpConstant.FTP_HOST,
HttpConstant.FTP_PORT, HttpConstant.FTP_USER,
HttpConstant.FTP_PSW);
boolean downLoadFile = ftpUtils.downLoadFile(
data.get(selectId).localpath, data.get(selectId).name,
remotePath);
if (!downLoadFile) {
Toast.makeText(EngineeringParametersActivity.this,
"下载失败,请检查网络!", Toast.LENGTH_SHORT).show();
} else {
Message msg = loadingHandler.obtainMessage();
msg.what = 3;
msg.sendToTarget();
}
}
}).start();


setDialogMessage(msg);: 
private void setDialogMessage(String msg) {
loadingDialog = LoadProgressDialog.createDialog(
EngineeringParametersActivity.this).setMessage(msg);
// loadingDialog.setCancelable(false);// 设置点击返回Dialog不消失
loadingDialog.setCanceledOnTouchOutside(false);// 设置点击屏幕Dialog不消失
loadingDialog.show();
}


加载:
private void Applicationing() {
//解压
CellVersionInfo info = data.get(selectId);
File zipFile = new File(info.localpath);
String folderPath = getExternalCacheDir().getPath() + "/cell" ;
if(!zipFile.exists())
return;
try {
String path = ZipUtils.upZipFile(zipFile, folderPath);
//替换
importCells(path);
} catch (ZipException e) {
loadingDialog.dismiss();
Toast.makeText(this, "解压失败!", DOWNLOAD_FAILED).show();
e.printStackTrace();
} catch (FileNotFoundException e) {
loadingDialog.dismiss();
Toast.makeText(this, "文件异常,解压失败!", DOWNLOAD_FAILED).show();
e.printStackTrace();
} catch (IOException e) {
loadingDialog.dismiss();
Toast.makeText(this, "网络异常!", DOWNLOAD_FAILED).show();
e.printStackTrace();
}
}


importCells(path);:
private void importCells(String path) throws FileNotFoundException {
ImportCellUtil cellUtil = new ImportCellUtil(this);
cellUtil.improtCells(loadingHandler, loadingDialog, path);
}


public class ImportCellUtil {
private Context context;

public ImportCellUtil(Context context) {
this.context = context;
}

public void improtCells(Handler loadingHandler,
LoadProgressDialog loadingDialog) {
inputStream = context.getResources().openRawResource(R.raw.lte);
Difference(loadingHandler, loadingDialog, null);
}

private InputStream inputStream;

public void improtCells(Handler loadingHandler,
LoadProgressDialog loadingDialog, String path)
throws FileNotFoundException {
inputStream = new FileInputStream(path);
Difference(loadingHandler, loadingDialog, path);
}

private void Difference(Handler loadingHandler,
LoadProgressDialog loadingDialog, String tag) {
InputStreamReader inputStreamReader = null;
try {
inputStreamReader = new InputStreamReader(inputStream, "gbk");
} catch (UnsupportedEncodingException e1) {
e1.printStackTrace();
}
BufferedReader reader = new BufferedReader(inputStreamReader);
LteCellInfoBean ltecell;
String line;
int i = 1;
try {
reader.readLine();// 去除表头
CellInfoDbUtil.deleteLetCellInfo();// 清空工参表
ArrayList<LteCellInfoBean> lteCellInfoBeans = new ArrayList<LteCellInfoBean>();
while ((line = reader.readLine()) != null) {
try {
String[] s = line.split(",");
ltecell = new LteCellInfoBean();
if (tag == null) {
ltecell.cellid = Integer.parseInt(s[0]);
ltecell.cellname = s[1];
ltecell.sectorid = Integer.parseInt(s[2]);
ltecell.tac = Integer.parseInt(s[3]);
ltecell.pci = Integer.parseInt(s[4]);
ltecell.earfcn = Integer.parseInt(s[5]);
ltecell.celltype = s[6];
ltecell.longitude = Double.valueOf(s[7]);
ltecell.latitude = Double.valueOf(s[8]);
GeoPoint bdPoint = new GeoPoint(
(int) (ltecell.latitude * 1E6),
(int) (ltecell.longitude * 1E6));
bdPoint = CoordinateConvert.fromWgs84ToBaidu(bdPoint);
ltecell.bdlongitude = bdPoint.getLongitudeE6();
ltecell.bdlatitude = bdPoint.getLatitudeE6();
ltecell.direction = Integer.parseInt(s[9]);
ltecell.enodebid = Integer.parseInt(s[10]);
} else {
ltecell.cellid = Integer.parseInt(s[2]);
ltecell.cellname = s[3];
ltecell.sectorid = Integer.parseInt(s[4]);
ltecell.tac = Integer.parseInt(s[0]);
ltecell.pci = Integer.parseInt(s[6]);
ltecell.earfcn = Integer.parseInt(s[5]);
ltecell.celltype = s[10];
ltecell.longitude = Double.valueOf(s[7]);
ltecell.latitude = Double.valueOf(s[8]);
GeoPoint bdPoint = new GeoPoint(
(int) (ltecell.latitude * 1E6),
(int) (ltecell.longitude * 1E6));
bdPoint = CoordinateConvert.fromWgs84ToBaidu(bdPoint);
ltecell.bdlongitude = bdPoint.getLongitudeE6();
ltecell.bdlatitude = bdPoint.getLatitudeE6();
ltecell.direction = Integer.parseInt(s[9]);
ltecell.enodebid = Integer.parseInt(s[1]);
}
lteCellInfoBeans.add(ltecell);
} catch (Exception e) {
e.printStackTrace();
}
i++;

Message msg = loadingHandler.obtainMessage();
msg.what = 0;
msg.arg1 = i;
msg.sendToTarget();
if (lteCellInfoBeans.size() >= 4999) {
CellInfoDbUtil.saveLetCellInfo(lteCellInfoBeans);
lteCellInfoBeans.clear();

}
}
CellInfoDbUtil.saveLetCellInfo(lteCellInfoBeans);
lteCellInfoBeans.clear();
Message msg = loadingHandler.obtainMessage();
msg.what = 1;
msg.sendToTarget();
} catch (IOException e) {
e.printStackTrace();
}
loadingDialog.dismiss();
}


Handler:
private Handler loadingHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// 显示进度条
try {
switch (msg.what) {
case 0:
loadingDialog.setMessage("应用数据加载中..." + msg.arg1);
break;
case 1:
Toast.makeText(EngineeringParametersActivity.this, "应用完成!",
Toast.LENGTH_SHORT).show();
break;
case 3:
loadingDialog.dismiss();
adapter.notifyDataSetChanged();
break;
default:
break;
}

} catch (Exception e) {
e.printStackTrace();
}
}
};


点击下载后的截图
点击应用后的截图
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值