正在查看: 爱心e站 v1.0.0 应用的 MineAboutActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 爱心e站 v1.0.0 应用的 MineAboutActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.newheyd.JZKFcanjiren.Activity;
import android.content.DialogInterface;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.support.v4.app.ActivityCompat;
import android.support.v4.content.ContextCompat;
import android.support.v4.media.TransportMediator;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;
import com.google.gson.Gson;
import com.iflytek.cloud.SpeechEvent;
import com.iflytek.cloud.SpeechUtility;
import com.newheyd.JZKFcanjiren.BaseActivity;
import com.newheyd.JZKFcanjiren.R;
import com.newheyd.JZKFcanjiren.Utils.ToastUtils;
import com.newheyd.JZKFcanjiren.Utils.VesionUpdate.ApkUpdateUtils;
import com.newheyd.JZKFcanjiren.View.PhotoSelect.CommonMethod;
import com.newheyd.JZKFcanjiren.View.TitleView;
import com.newheyd.JZKFcanjiren.config.NewHYConfig;
import com.newheyd.JZKFcanjiren.model.BaseResult;
import com.newheyd.JZKFcanjiren.net.NewHYTask;
import com.tencent.bugly.beta.Beta;
import org.json.JSONException;
import org.json.JSONObject;
public class MineAboutActivity extends BaseActivity {
private CommonMethod commonMethod;
private TitleView title_about;
private TextView tv_checknew;
private String UpdateURl = "";
Handler handler = new Handler() {
@Override
public void handleMessage(Message msg) {
super.handleMessage(msg);
switch (msg.what) {
case 128:
MineAboutActivity.this.UpdateURl = String.valueOf(msg.obj);
MineAboutActivity.this.ChoiceTishiDialog("服务器有新版本,是否更新?", false, new BaseActivity.OnChoiceDialogYes() {
@Override
public void onChoiceDialogYes(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
MineAboutActivity.this.VersionUpdate(MineAboutActivity.this.UpdateURl);
}
}, new BaseActivity.OnChoiceDialogNo() {
@Override
public void onChoiceDialogNo(DialogInterface dialogInterface, int i) {
ToastUtils.showShortToast(MineAboutActivity.this, "您稍后可以通过此功能进行手动更新");
dialogInterface.dismiss();
}
});
break;
case 131:
ToastUtils.showShortToast(MineAboutActivity.this, "您当前APP是最新版本");
new Gson();
break;
}
}
};
@Override
protected void onCreate(Bundle savedInstanceState) {
setContentView(R.layout.page_mine_about);
super.onCreate(savedInstanceState);
}
@Override
public void onResponseBefore(NewHYTask task) {
}
@Override
public void onResponseAfter(NewHYTask task) {
}
@Override
public void onResponseSuccessful(NewHYTask task, BaseResult object) {
}
@Override
public void onResponseError(NewHYTask task, BaseResult object) {
}
@Override
public void onServerError(NewHYTask task, int failedType) {
}
@Override
public void initViews() {
this.title_about = (TitleView) findViewById(R.id.titleview_mine_about);
this.title_about.setOnTitleClik(null, null);
this.tv_checknew = (TextView) findViewById(R.id.tv_mine_about_checknew);
this.tv_checknew.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
MineAboutActivity.this.CheckNewDialog();
}
});
try {
PackageInfo packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
((TextView) findViewById(R.id.tv_sversion)).setText("版本号" + packageInfo.versionName);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
}
@Override
public void setListener() {
}
public void CheckNewDialog() {
Beta.checkUpgrade(true, false);
if (!testConnectivityManager()) {
ToastUtils.showShortToast(this, "当前未连接任何网络");
}
}
private void dealUpdataData(String response) {
try {
JSONObject jsonObj = new JSONObject(response);
if (jsonObj.optBoolean(SpeechUtility.TAG_RESOURCE_RESULT)) {
Message msg = this.handler.obtainMessage();
JSONObject jsonObject = jsonObj.optJSONObject(SpeechEvent.KEY_EVENT_RECORD_DATA);
PackageInfo packageInfo = null;
try {
packageInfo = getPackageManager().getPackageInfo(getPackageName(), 0);
} catch (PackageManager.NameNotFoundException e) {
e.printStackTrace();
}
if ("1".equals(jsonObject.optString("isForce")) && packageInfo.versionCode != jsonObject.optInt("version")) {
msg.obj = jsonObject.optString("address");
msg.what = 129;
} else if ("1".equals(jsonObject.optString("isUpdate"))) {
msg.what = 128;
msg.obj = jsonObject.optString("address");
} else {
msg.what = 131;
}
this.handler.sendMessage(msg);
return;
}
this.handler.sendEmptyMessage(-2);
} catch (JSONException e2) {
e2.printStackTrace();
this.handler.sendEmptyMessage(-2);
}
}
public void VersionUpdate(String url_download) {
if (!canDownloadState()) {
Toast.makeText(this, "下载服务不可用,请您启用", 0).show();
showDownloadSetting();
} else {
ApkUpdateUtils.download(this, NewHYConfig.ROOT + url_download, getResources().getString(2131296314));
}
}
public void requestStoragePermission() {
this.commonMethod = new CommonMethod(this);
if (Build.VERSION.SDK_INT >= 23) {
if (ContextCompat.checkSelfPermission(this.mContext, "android.permission.WRITE_EXTERNAL_STORAGE") != 0) {
ActivityCompat.requestPermissions(this, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE"}, 129);
} else if (ContextCompat.checkSelfPermission(this.mContext, "android.permission.CAMERA") != 0) {
ActivityCompat.requestPermissions(this, new String[]{"android.permission.CAMERA"}, TransportMediator.KEYCODE_MEDIA_RECORD);
}
}
}
@Override
public void onRequestPermissionsResult(int requestCode, String[] permissions, int[] grantResults) {
switch (requestCode) {
case 129:
if (grantResults[0] != 0) {
if (!ActivityCompat.shouldShowRequestPermissionRationale(this, "android.permission.READ_EXTERNAL_STORAGE")) {
this.commonMethod.dialogAndInset("读写手机存储权限");
break;
} else {
this.commonMethod.dialogAndInset("读写手机存储权限");
break;
}
} else {
VersionUpdate(this.UpdateURl);
break;
}
default:
super.onRequestPermissionsResult(requestCode, permissions, grantResults);
break;
}
}
}