85 lines
2.8 KiB
Java
85 lines
2.8 KiB
Java
package com.gh.gamecenter;
|
|
|
|
import android.content.Intent;
|
|
import android.os.*;
|
|
import android.view.View;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.TextView;
|
|
import butterknife.BindView;
|
|
import butterknife.OnClick;
|
|
import com.gh.base.BaseActivity;
|
|
import com.gh.common.util.PackageUtils;
|
|
import com.gh.gamecenter.manager.UpdateManager;
|
|
|
|
import java.lang.ref.WeakReference;
|
|
|
|
/**
|
|
* Created by khy on 2017/2/28.
|
|
*/
|
|
public class AboutActivity extends BaseActivity {
|
|
|
|
@BindView(R.id.about_version_tv)
|
|
TextView mAboutVersion;
|
|
@BindView(R.id.about_version_pb)
|
|
ProgressBar mAboutPb;
|
|
|
|
private Handler handler = new MyHandler(this);
|
|
|
|
static class MyHandler extends Handler {
|
|
|
|
private WeakReference<AboutActivity> mWeakReference;
|
|
|
|
public MyHandler(AboutActivity activity) {
|
|
mWeakReference = new WeakReference<>(activity);
|
|
}
|
|
|
|
@Override
|
|
public void handleMessage(Message msg) {
|
|
super.handleMessage(msg);
|
|
final AboutActivity activity = mWeakReference.get();
|
|
if (activity != null) {
|
|
if (msg.what == 0) {
|
|
final String version = (String) msg.obj;
|
|
activity.mAboutVersion.setText("发现新版本 V" + version);
|
|
activity.mAboutPb.setVisibility(View.GONE);
|
|
} else if (msg.what == 1) {
|
|
activity.mAboutVersion.setText("已是最新版本");
|
|
activity.mAboutPb.setVisibility(View.GONE);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onCreate(Bundle savedInstanceState) {
|
|
super.onCreate(savedInstanceState);
|
|
View view = View.inflate(this, R.layout.activity_about, null);
|
|
init(view, "关于");
|
|
|
|
((TextView) findViewById(R.id.about_tv_version)).setText("V" + PackageUtils.getVersionName(this));
|
|
|
|
UpdateManager.getInstance(this).checkUpdate(false, handler); // 自动检出更新
|
|
}
|
|
|
|
@OnClick({R.id.about_version_tv, R.id.about_shengming})
|
|
public void OnClick(View view) {
|
|
if (view.getId() == R.id.about_version_tv) {
|
|
String content = mAboutVersion.getText().toString();
|
|
if (content.startsWith("发现新版本")) {
|
|
UpdateManager.getInstance(this).checkUpdate(false, handler); // 自动检出更新
|
|
}
|
|
} else if (view.getId() == R.id.about_shengming) {
|
|
Intent intent = new Intent(AboutActivity.this, WebActivity.class);
|
|
intent.putExtra("gameName", "使用条款与免责声明");
|
|
intent.putExtra("url", "http://api.ghzhushou.com/disclaimer");
|
|
startActivity(intent);
|
|
}
|
|
}
|
|
|
|
@Override
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
handler.removeCallbacksAndMessages(null);
|
|
}
|
|
}
|