Back to project page Antares.
The source code is released under:
Apache License
If you think the Android project Antares listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.takac_j30.antares; /*w w w. j a va 2 s . com*/ import twitter4j.auth.AccessToken; import android.content.Context; import android.content.Intent; import android.content.SharedPreferences; import android.content.SharedPreferences.Editor; import android.os.Bundle; import android.support.v4.app.Fragment; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.CompoundButton; import android.widget.CompoundButton.OnCheckedChangeListener; import android.widget.Switch; public class ReplySettings extends Fragment{ private static final String PREF_NAME = "antares_access_token"; private static final String IS_STARTING = "is_starting"; boolean isReplyEnabled = false; @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { return inflater.inflate(R.layout.reply_settings, null); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); Switch enable_switch = (Switch) getView().findViewById(R.id.EnableSwitch); isReplyEnabled = loadStartingState(); enable_switch.setChecked(isReplyEnabled); enable_switch.setOnCheckedChangeListener(new OnCheckedChangeListener() { @Override public void onCheckedChanged(CompoundButton arg0, boolean isChecked) { isReplyEnabled = !loadStartingState(); if(isReplyEnabled) { getActivity().startService(new Intent(getActivity(), AutoReply.class)); } else { getActivity().stopService(new Intent(getActivity(), AutoReply.class)); } storeStartingState(isReplyEnabled); } }); } public void storeStartingState(boolean bool) { SharedPreferences preferences = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); Editor editor = preferences.edit(); editor.putBoolean(IS_STARTING, bool); editor.commit(); } public boolean loadStartingState() { SharedPreferences preferences = getActivity().getSharedPreferences(PREF_NAME, Context.MODE_PRIVATE); boolean bool = preferences.getBoolean(IS_STARTING, false); return bool; } }