@Override public void onCheckedChanged(RadioGroup group, int checkedId) { if (GTACSettingActivity.this.show_profiler.getId() == checkedId) { GTACSettingActivity.switch_type = PROFILER; GTPref.getGTPref().edit().putInt(GTPref.AC_SWITCH, PROFILER).commit(); } else if (GTACSettingActivity.this.show_gw.getId() == checkedId) { GTACSettingActivity.switch_type = GW; GTPref.getGTPref().edit().putInt(GTPref.AC_SWITCH, GW).commit(); } }
@Override protected void onResume() { super.onResume(); cb_show_Switch.setChecked(isShow); cb_show_Switch.setOnCheckedChangeListener(this); switch_type = GTPref.getGTPref().getInt(GTPref.AC_SWITCH, GW); switch (switch_type) { case PROFILER: { show_profiler.setChecked(true); break; } case GW: default: { show_gw.setChecked(true); break; } } // 监听放在上面初始setChecked后面,避免提前触发监听造成逻辑混乱 this.show_quickswitch.setOnCheckedChangeListener(new OnCheckedChangeListenerImp()); }
@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.gt_floatview_setting); TextView tv_back = (TextView) findViewById(R.id.tv_back); tv_back.setOnClickListener(back); show_quickswitch = (RadioGroup) findViewById(R.id.show_quickswitch); show_profiler = (RadioButton) findViewById(R.id.show_profiler); show_gw = (RadioButton) findViewById(R.id.show_gw); cb_show_Switch = (GTCheckBox) findViewById(R.id.cb_switch); isShow = GTPref.getGTPref().getBoolean(GTPref.AC_SWITCH_FLAG, true); }
@Override public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { isShow = isChecked; GTPref.getGTPref().edit().putBoolean(GTPref.AC_SWITCH_FLAG, isShow).commit(); if (isShow) { Intent intent = new Intent(this, GTLogo.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startService(intent); Intent mintent = new Intent(this, GTFloatView.class); mintent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startService(mintent); } else { Intent intent = new Intent(this, GTLogo.class); stopService(intent); Intent FVintent = new Intent(this, GTFloatView.class); stopService(FVintent); } }