public void readData() { mNotifyRunBackgroundSwitch.setChecked( PreferenceUtils.getPrefBoolean(getActivity(), PreferenceConstants.FOREGROUND, true)); mNewMsgSoundSwitch.setChecked( PreferenceUtils.getPrefBoolean(getActivity(), PreferenceConstants.SCLIENTNOTIFY, false)); mNewMsgVibratorSwitch.setChecked( PreferenceUtils.getPrefBoolean(getActivity(), PreferenceConstants.VIBRATIONNOTIFY, true)); mVisiableNewMsgSwitch.setChecked( PreferenceUtils.getPrefBoolean(getActivity(), PreferenceConstants.TICKER, true)); }
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); mNotifyRunBackgroundSwitch = (Switch) view.findViewById(R.id.notify_run_background_switch); mNotifyRunBackgroundSwitch.setOnCheckedChangeListener(this); mNewMsgSoundSwitch = (Switch) view.findViewById(R.id.new_msg_sound_switch); mNewMsgSoundSwitch.setOnCheckedChangeListener(this); mNewMsgVibratorSwitch = (Switch) view.findViewById(R.id.new_msg_vibrator_switch); mNewMsgVibratorSwitch.setOnCheckedChangeListener(this); mVisiableNewMsgSwitch = (Switch) view.findViewById(R.id.visiable_new_msg_switch); mVisiableNewMsgSwitch.setOnCheckedChangeListener(this); }
@Override public void onCheckedChanged(Switch buttonView, boolean isChecked) { switch (buttonView.getId()) { case R.id.notify_run_background_switch: PreferenceUtils.setPrefBoolean(getActivity(), PreferenceConstants.FOREGROUND, isChecked); break; case R.id.new_msg_sound_switch: PreferenceUtils.setPrefBoolean(getActivity(), PreferenceConstants.SCLIENTNOTIFY, isChecked); Setting.setVoiceEnable(isChecked); break; case R.id.new_msg_vibrator_switch: PreferenceUtils.setPrefBoolean( getActivity(), PreferenceConstants.VIBRATIONNOTIFY, isChecked); Setting.setVibrateEnable(isChecked); break; case R.id.visiable_new_msg_switch: PreferenceUtils.setPrefBoolean(getActivity(), PreferenceConstants.TICKER, isChecked); break; default: break; } }