1、修复url匹配正则
2、部分onclick处理 3、代码整理
This commit is contained in:
@ -2,15 +2,16 @@ package com.gh.gamecenter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.*;
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.view.View;
|
||||
import android.view.View.OnClickListener;
|
||||
import android.view.Window;
|
||||
import android.widget.*;
|
||||
import butterknife.BindView;
|
||||
import butterknife.OnClick;
|
||||
import com.gh.base.BaseActivity;
|
||||
import com.gh.common.constant.Config;
|
||||
import com.gh.common.util.DialogUtils;
|
||||
@ -19,9 +20,16 @@ import com.gh.gamecenter.eventbus.EBReuse;
|
||||
import com.gh.gamecenter.eventbus.EBSkip;
|
||||
import com.kyleduo.switchbutton.SwitchButton;
|
||||
import de.greenrobot.event.EventBus;
|
||||
import rx.*;
|
||||
import rx.Observable.OnSubscribe;
|
||||
import rx.android.schedulers.AndroidSchedulers;
|
||||
import rx.schedulers.Schedulers;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import static com.gh.gamecenter.R.id.setting_rl_about;
|
||||
import static java.lang.Thread.sleep;
|
||||
|
||||
/**
|
||||
* 游戏设置页面
|
||||
*
|
||||
@ -47,12 +55,8 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
|
||||
private Dialog loadingDialog = null;
|
||||
|
||||
private Handler handler = new Handler();
|
||||
|
||||
private int checkSizeIndex;
|
||||
|
||||
private Context context = this;
|
||||
|
||||
@Override
|
||||
public void finish() {
|
||||
saveCurrentSetting();
|
||||
@ -70,15 +74,6 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
|
||||
init(getString(R.string.title_settings));
|
||||
|
||||
findViewById(R.id.setting_rl_autoinstall).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_autodelete).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_deletedata).setOnClickListener(this);
|
||||
// findViewById(R.id.setting_rl_feedback).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_cache).setOnClickListener(this);
|
||||
findViewById(R.id.setting_cv_font_size).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_concerngame).setOnClickListener(this);
|
||||
findViewById(R.id.setting_rl_about).setOnClickListener(this);
|
||||
|
||||
setting_tv_cache.setText(getCacheSize());
|
||||
|
||||
sp = getSharedPreferences(Config.PREFERENCE, Activity.MODE_PRIVATE);
|
||||
@ -86,7 +81,6 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
// 未打开下载按钮,显示修复下载按钮
|
||||
if (!sp.getBoolean("isShow", true)) {
|
||||
findViewById(R.id.setting_cv_fix_download).setVisibility(View.VISIBLE);
|
||||
findViewById(R.id.setting_cv_fix_download).setOnClickListener(this);
|
||||
}
|
||||
|
||||
setting_sb_autoinstall.setChecked(sp.getBoolean("autoinstall", true));
|
||||
@ -146,12 +140,20 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
mEditor.apply();
|
||||
}
|
||||
|
||||
@OnClick({
|
||||
R.id.setting_cv_fix_download,
|
||||
R.id.setting_rl_autoinstall,
|
||||
R.id.setting_rl_autodelete,
|
||||
R.id.setting_rl_deletedata,
|
||||
R.id.setting_rl_cache,
|
||||
R.id.setting_cv_font_size,
|
||||
R.id.setting_rl_concerngame,
|
||||
R.id.setting_rl_about
|
||||
})
|
||||
@Override
|
||||
public void onClick(final View v) {
|
||||
|
||||
switch (v.getId()) {
|
||||
case R.id.actionbar_rl_back:
|
||||
finish();
|
||||
break;
|
||||
case R.id.setting_cv_fix_download:
|
||||
Editor editor = sp.edit();
|
||||
editor.putBoolean("isShow", true);
|
||||
@ -186,20 +188,15 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
new DialogUtils.ConfirmListener() {
|
||||
@Override
|
||||
public void onConfirm() {
|
||||
loadingDialog = DialogUtils.showWaitDialog(context, "清除缓存中...");
|
||||
claerCache();
|
||||
loadingDialog = DialogUtils.showWaitDialog(SettingActivity.this, "清除缓存中...");
|
||||
clearCache();
|
||||
}
|
||||
});
|
||||
break;
|
||||
// case R.id.setting_rl_feedback:
|
||||
// Intent intent = new Intent(SettingActivity.this, SuggestionActivity.class);
|
||||
// intent.putExtra("mEntrance", "(设置)");
|
||||
// startActivity(intent);
|
||||
// break;
|
||||
case R.id.setting_cv_font_size:
|
||||
fontSize();
|
||||
break;
|
||||
case R.id.setting_rl_about:
|
||||
case setting_rl_about:
|
||||
Intent intentAbout = new Intent(this, AboutActivity.class);
|
||||
startActivity(intentAbout);
|
||||
break;
|
||||
@ -261,10 +258,12 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
}
|
||||
|
||||
// 清除缓存
|
||||
private void claerCache() {
|
||||
new Thread() {
|
||||
private void clearCache() {
|
||||
|
||||
Observable.create(new OnSubscribe<Object>() {
|
||||
@Override
|
||||
public void run() {
|
||||
public void call(Subscriber<? super Object> subscriber) {
|
||||
|
||||
long start = System.currentTimeMillis();
|
||||
FileUtils.deleteFolder(getCacheDir());
|
||||
FileUtils.deleteFolder(getExternalCacheDir());
|
||||
@ -273,22 +272,33 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
try {
|
||||
sleep(1000 - time);
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
subscriber.onCompleted();
|
||||
}
|
||||
|
||||
}).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Object>() {
|
||||
@Override
|
||||
public void onCompleted() {
|
||||
if (loadingDialog != null) {
|
||||
loadingDialog.dismiss();
|
||||
}
|
||||
handler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
setting_tv_cache.setText(getCacheSize());
|
||||
Toast.makeText(SettingActivity.this, "缓存清除成功", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
setting_tv_cache.setText(getCacheSize());
|
||||
Toast.makeText(SettingActivity.this, "缓存清除成功", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}.start();
|
||||
|
||||
@Override
|
||||
public void onError(Throwable e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onNext(Object o) {
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -297,9 +307,4 @@ public class SettingActivity extends BaseActivity implements OnClickListener {
|
||||
saveCurrentSetting();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDestroy() {
|
||||
super.onDestroy();
|
||||
handler.removeCallbacksAndMessages(null);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user