So basically I have a PreferenceActivity that I use to make calls to a Web Service through private classes extending AsyncTask. Whenever a Preference changes I have a "huge" "switch case" determining which preference has been changed and then makes the call accordingly.
Now I have two questions :
- This seems like a "silly" way to deal with my problem. Do you have any suggestions as to what I should do instead?
- I just made another set of preferences consisting of N CheckboxPreferences. How do I "deal" with these in terms of calling the class JoinQueueTask().execute(String queue_key) (JoinQueue extends AsyncTask) ?
Relevant Code snippet :
public void onSharedPreferenceChanged(SharedPreferences arg0, String key)
{
if(isFirstRun)
return;
// Call Forward Preferences
if(key.contentEquals("call_forward_always"))
{
cfInfo[0] = "1";
cfInfo[1] = arg0.getString(key, "ERROR");
new PushCallForwardInfoTask().execute(cfInfo);
ep1.setSummary("Viderestiller til " + cfInfo[1]);
}
else if(key.contentEquals("call_forward_busy"))
{
cfInfo[2] = "1";
cfInfo[3] = arg0.getString(key, "ERROR");
new PushCallForwardInfoTask().execute(cfInfo);
ep2.setSummary("Viderestiller til " + cfInfo[3]);
}
else if(key.contentEquals("call_forward_noresponse"))
{
cfInfo[4] = "1";
cfInfo[5] = arg0.getString(key, "ERROR");
new PushCallForwardInfoTask().execute(cfInfo);
ep3.setSummary("Viderestiller til " + cfInfo[5]);
}
else if(key.contentEquals("call_forward_timeout"))
{
cfInfo[6] = arg0.getString(key, "ERROR");
new PushCallForwardInfoTask().execute(cfInfo);
ep4.setSummary("Viderestiller efter " + cfInfo[6] + " sekunder");
}
// Show Number Preferences
else if(key.contentEquals("shownumber_list"))
{
String[] newnumber = {""};
newnumber[0] = arg0.getString(key, "ERROR");
new PushNumberTask().execute(newnumber);
lp.setSummary(arg0.getString(key, "ERROR"));
}
// Voicemail Preferences
else if(key.contentEquals("voicemail_checkbox"))
{
final Boolean[] vmStatus = { Boolean.FALSE };
vmStatus[0] = cp.isChecked();
new PushVoicemailStatus().execute(vmStatus);
}
}