diff options
author | lado <herrlado@gmail.com> | 2012-01-22 02:53:51 +0100 |
---|---|---|
committer | lado <herrlado@gmail.com> | 2012-01-22 02:53:51 +0100 |
commit | 24e7980ebeaca1f8b65178b6b9075ca78f306861 (patch) | |
tree | 5a3ebe6782300d6f7b891b7de4d956e4d7d1c954 /vdrmanager/src | |
parent | 71cd552798123fc6b600b4d727ca245b4d62893c (diff) | |
download | vdr-manager-24e7980ebeaca1f8b65178b6b9075ca78f306861.tar.gz vdr-manager-24e7980ebeaca1f8b65178b6b9075ca78f306861.tar.bz2 |
delete vdr if not mofified after init
Diffstat (limited to 'vdrmanager/src')
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java | 7 | ||||
-rw-r--r-- | vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java | 50 |
2 files changed, 38 insertions, 19 deletions
diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java index 61f6385..0899ee2 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrListActivity.java @@ -15,6 +15,7 @@ import com.j256.ormlite.android.apptools.OrmLiteBaseListActivity; import de.bjusystems.vdrmanager.R; import de.bjusystems.vdrmanager.app.Intents; +import de.bjusystems.vdrmanager.data.Preferences; import de.bjusystems.vdrmanager.data.db.OrmDatabaseHelper; public class VdrListActivity extends OrmLiteBaseListActivity<OrmDatabaseHelper> implements OnItemClickListener, OnItemLongClickListener { @@ -106,6 +107,12 @@ public class VdrListActivity extends OrmLiteBaseListActivity<OrmDatabaseHelper> } + + @Override + public void onBackPressed() { + Preferences.init(this); + super.onBackPressed(); + } /** * Refresh the list diff --git a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java index b373c8e..6e5c25e 100644 --- a/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java +++ b/vdrmanager/src/de/bjusystems/vdrmanager/gui/VdrPreferencesActivity.java @@ -16,6 +16,8 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements Vdr vdr; VdrSharedPreferences pref; + int id = -1; + @Override public SharedPreferences getSharedPreferences(String name, int mode) { return this.pref; @@ -27,8 +29,8 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements } private void initVDR() { - Integer id = getIntent().getExtras().getInt(Intents.VDR_ID); - if (id == null) {// new vdr + id = getIntent().getIntExtra(Intents.VDR_ID, -1); + if (id == -1) {// new vdr vdr = new Vdr(); pref = new VdrSharedPreferences(); pref.instance = vdr; @@ -41,6 +43,7 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements vdr = new Vdr(); pref = new VdrSharedPreferences(); pref.instance = vdr; + id = -1; } } } @@ -90,13 +93,12 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements private void enableWolPreferences() { Preference p = findPreference(getString(R.string.wakeup_wol_mac_key)); - if(p != null) - - p.setEnabled(true); - p = - findPreference(getString(R.string.wakeup_wol_custom_broadcast_key)); - if(p!=null){ - p.setEnabled(true); + if (p != null) + + p.setEnabled(true); + p = findPreference(getString(R.string.wakeup_wol_custom_broadcast_key)); + if (p != null) { + p.setEnabled(true); } } @@ -128,17 +130,17 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements } private void enableWakeupUrlPrefenreces() { - Preference p = findPreference(getString(R.string.wakeup_url_key)); - if(p!=null){ + Preference p = findPreference(getString(R.string.wakeup_url_key)); + if (p != null) { p.setEnabled(true); } - + p = findPreference(getString(R.string.wakeup_password_key)); - if(p != null){ - p.setEnabled(true); - } + if (p != null) { + p.setEnabled(true); + } p = findPreference(getString(R.string.wakeup_user_key)); - if(p != null){ + if (p != null) { p.setEnabled(true); } } @@ -169,8 +171,18 @@ public class VdrPreferencesActivity extends BasePreferencesActivity implements @Override public void onBackPressed() { - setResult(RESULT_OK); - finish(); + if (id != -1) {// no new devices + setResult(RESULT_OK); + finish(); + return; + } + if (pref.commits < 2) {// user has not changed anything + getHelper().getVdrDAO().delete(pref.instance); + finish(); + return; + } + + super.onBackPressed(); } - + } |