更新提示Dialog 修改
This commit is contained in:
@ -8,6 +8,7 @@ import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.text.Html;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
@ -67,7 +68,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
|
||||
private SharedPreferences sp;
|
||||
|
||||
private Dialog dialog = null;
|
||||
private Dialog loadingDialog = null;
|
||||
private Dialog downloadDialog = null;
|
||||
|
||||
private AppEntity appEntity;
|
||||
|
||||
@ -96,8 +98,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
if (appEntity != null && appEntity.isForce()) {
|
||||
AppController.getInstance().finishActivity();
|
||||
} else {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
if (downloadDialog != null) {
|
||||
downloadDialog.dismiss();
|
||||
}
|
||||
isShowDownload = false;
|
||||
}
|
||||
@ -230,7 +232,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
setting_sb_autoupdate.performClick();
|
||||
break;
|
||||
case R.id.setting_rl_update:
|
||||
dialog = DialogUtils.showWaitDialog(this, "检查更新中...");
|
||||
loadingDialog = DialogUtils.showWaitDialog(this, "检查更新中...");
|
||||
if (isChecking)
|
||||
break;
|
||||
isChecking = true;
|
||||
@ -241,7 +243,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
new DialogUtils.ConfiremListener() {
|
||||
@Override
|
||||
public void onConfirem() {
|
||||
dialog = DialogUtils.showWaitDialog(context, "清除缓存中...");
|
||||
loadingDialog = DialogUtils.showWaitDialog(context, "清除缓存中...");
|
||||
claerCache();
|
||||
}
|
||||
});
|
||||
@ -330,8 +332,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
if (loadingDialog != null) {
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
@ -370,8 +372,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
public void onResponse(JSONObject response) {
|
||||
|
||||
isChecking = false;
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
if (loadingDialog != null) {
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
|
||||
if (response.length() == 0) {
|
||||
@ -394,6 +396,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
game.setVersion(appEntity.getVersion());
|
||||
game.setUrl(appEntity.getUrl());
|
||||
game.setPlatform("官方版");
|
||||
game.setId("5618b86e8ab49e17088b4575");
|
||||
PackageManager.addUpdate(0, game);
|
||||
|
||||
String updateMD5 = MD5Utils.getUpdateMD5(
|
||||
@ -412,8 +415,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
@Override
|
||||
public void onErrorResponse(VolleyError error) {
|
||||
isChecking = false;
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
if (loadingDialog != null) {
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
|
||||
Utils.log("error = " + error.toString());
|
||||
@ -425,23 +428,18 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
}
|
||||
|
||||
private void showUpdateDialog(final String md5) {
|
||||
dialog = new Dialog(this);
|
||||
View view = View.inflate(this, R.layout.app_update_hint_dialog,
|
||||
null);
|
||||
TextView content = (TextView) view
|
||||
.findViewById(R.id.updeta_content);
|
||||
TextView size = (TextView) view
|
||||
.findViewById(R.id.update_app_size);
|
||||
final Dialog updateDialog = new Dialog(this);
|
||||
View view = View.inflate(this, R.layout.app_update_hint_dialog, null);
|
||||
|
||||
TextView content = (TextView) view.findViewById(R.id.updeta_content);
|
||||
content.setText(Html.fromHtml(appEntity.getContent()));
|
||||
|
||||
TextView versison = (TextView) view.findViewById(R.id.update_app_version);
|
||||
versison.setText(String.format("光环助手V%s更新内容:", appEntity.getVersion()));
|
||||
|
||||
versison.setText("光环助手V"+appEntity.getVersion()+"更新内容:");
|
||||
size.setText("大小:"+appEntity.getSize());
|
||||
content.setText(appEntity.getContent()+"");
|
||||
TextView size = (TextView) view.findViewById(R.id.update_app_size);
|
||||
size.setText(String.format("大小:%s", appEntity.getSize()));
|
||||
|
||||
if (appEntity.isForce()) {
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setCancelable(false);
|
||||
}
|
||||
view.findViewById(R.id.update_cannel).setOnClickListener(
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
@ -452,9 +450,7 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
} else {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
updateDialog.dismiss();
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -462,13 +458,9 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
new OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
String path = FileUtils.getDownloadPath(
|
||||
SettingActivity.this,
|
||||
"光环助手V" + appEntity.getVersion() + "_" + md5
|
||||
+ ".apk");
|
||||
updateDialog.dismiss();
|
||||
String path = FileUtils.getDownloadPath(SettingActivity.this,
|
||||
"光环助手V" + appEntity.getVersion() + "_" + md5 + ".apk");
|
||||
File file = new File(path);
|
||||
if (file.exists() && file.length() > 0) {
|
||||
startActivity(PackageUtils.getInstallIntent(path));
|
||||
@ -478,16 +470,20 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
}
|
||||
}
|
||||
});
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
if (appEntity.isForce()) {
|
||||
updateDialog.setCanceledOnTouchOutside(false);
|
||||
updateDialog.setCancelable(false);
|
||||
}
|
||||
updateDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
updateDialog.setContentView(view);
|
||||
updateDialog.show();
|
||||
}
|
||||
|
||||
private void showDownloadDialog(String md5) {
|
||||
dialog = new Dialog(SettingActivity.this);
|
||||
dialog.setCanceledOnTouchOutside(false);
|
||||
dialog.setCancelable(false);
|
||||
dialog.closeOptionsMenu();
|
||||
final Dialog downloadDialog = new Dialog(SettingActivity.this);
|
||||
downloadDialog.setCanceledOnTouchOutside(false);
|
||||
downloadDialog.setCancelable(false);
|
||||
downloadDialog.closeOptionsMenu();
|
||||
View view = View.inflate(this, R.layout.app_updating_dialog, null);
|
||||
|
||||
app_pb_progress = (ProgressBar) view.findViewById(R.id.app_pb_progress);
|
||||
@ -506,17 +502,15 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
setResult(RESULT_OK, data);
|
||||
finish();
|
||||
} else {
|
||||
if (dialog != null) {
|
||||
dialog.dismiss();
|
||||
}
|
||||
downloadDialog.dismiss();
|
||||
isShowDownload = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
dialog.setContentView(view);
|
||||
dialog.show();
|
||||
downloadDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
|
||||
downloadDialog.setContentView(view);
|
||||
downloadDialog.show();
|
||||
|
||||
isShowDownload = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user