From f64d6a3d3bd5eddeffe9ef161cd3e14f4def57c5 Mon Sep 17 00:00:00 2001 From: Ricky Barrette Date: Sat, 26 May 2012 17:17:02 -0400 Subject: [PATCH] Started working on deleteing features from the database, after they are removed and saved. Signed-off-by: Ricky Barrette --- .../OnContentChangedListener.java | 1 + .../ui/RingerInformationActivity.java | 7 +++++ .../ui/fragments/FeatureListFragment.java | 27 +++++++++++++++++-- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java index dfe9d4c..1fc4b26 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/OnContentChangedListener.java @@ -19,4 +19,5 @@ public interface OnContentChangedListener { void onInfoContentChanged(ContentValues info); + void onInfoContentRemoved(String... keys); } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java index 9c28a7b..b9d0215 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/RingerInformationActivity.java @@ -220,4 +220,11 @@ public class RingerInformationActivity extends FragmentActivity implements OnCon this.mPager.setScrollEnabled(enabled); } + @Override + public void onInfoContentRemoved(String... keys) { + for(String key : keys) + if(this.mInfo.containsKey(key)) + this.mInfo.remove(key); + } + } \ No newline at end of file diff --git a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java index 195a9c2..1a52e4e 100644 --- a/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java +++ b/LocationRinger/src/com/TwentyCodes/android/LocationRinger/ui/fragments/FeatureListFragment.java @@ -245,7 +245,30 @@ public class FeatureListFragment extends BaseFragmentListFragment implements OnC public void onFeatureRemoved(Fragment f) { this.remove(f); - if(f instanceof IdFragment) - mAdded.remove(new Integer(((IdFragment) f).getFragmentId())); + if(f instanceof IdFragment){ + final int id = ((IdFragment) f).getFragmentId(); + mAdded.remove(new Integer(id)); + + switch(id){ + case KEY_ADDED_RINGTONE: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_RINGTONE_VOLUME); + break; + case KEY_ADDED_NOTIFICATIONTONE: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_NOTIFICATION_RINGTONE_URI, RingerDatabase.KEY_RINGTONE_IS_SILENT, RingerDatabase.KEY_NOTIFICATION_RINGTONE_VOLUME); + break; + case KEY_ADDED_ALARM_VOLUME: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_ALARM_VOLUME); + break; + case KEY_ADDED_MUSIC_VOLUME: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_MUSIC_VOLUME); + break; + case KEY_ADDED_BT: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_BT); + break; + case KEY_ADDED_WIFI: + this.mListener.onInfoContentRemoved(RingerDatabase.KEY_WIFI); + break; + } + } } } \ No newline at end of file