aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/org/connectbot/HostEditorActivity.java
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-09-07 22:15:57 -0700
committerKenny Root <kenny@the-b.org>2015-09-07 22:15:57 -0700
commit57afa9bdc5b269a48bd27fc8455cab4cb956d02a (patch)
tree86e301f6769a92bf853e8d60b156a4e98f077ecf /app/src/main/java/org/connectbot/HostEditorActivity.java
parent747e11c6ff28fc833855b9979ce68a15b99915f6 (diff)
downloadconnectbot-57afa9bdc5b269a48bd27fc8455cab4cb956d02a.tar.gz
connectbot-57afa9bdc5b269a48bd27fc8455cab4cb956d02a.tar.bz2
connectbot-57afa9bdc5b269a48bd27fc8455cab4cb956d02a.zip
Never cache instances of the HostDatabase
Diffstat (limited to 'app/src/main/java/org/connectbot/HostEditorActivity.java')
-rw-r--r--app/src/main/java/org/connectbot/HostEditorActivity.java18
1 files changed, 6 insertions, 12 deletions
diff --git a/app/src/main/java/org/connectbot/HostEditorActivity.java b/app/src/main/java/org/connectbot/HostEditorActivity.java
index 4fc41bf..7316775 100644
--- a/app/src/main/java/org/connectbot/HostEditorActivity.java
+++ b/app/src/main/java/org/connectbot/HostEditorActivity.java
@@ -68,6 +68,7 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
// fill a cursor and cache the values locally
// this makes sure we don't have any floating cursor to dispose later
+ HostDatabase hostdb = HostDatabase.get(HostEditorActivity.this);
SQLiteDatabase db = hostdb.getWritableDatabase();
Cursor cursor = db.query(table, null, "_id = ?",
new String[] { String.valueOf(id) }, null, null, null);
@@ -98,7 +99,7 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
}
public boolean commit() {
- //Log.d(this.getClass().toString(), "commit() changes back to database");
+ HostDatabase hostdb = HostDatabase.get(HostEditorActivity.this);
SQLiteDatabase db = hostdb.getWritableDatabase();
db.beginTransaction();
try {
@@ -214,9 +215,6 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
protected static final String TAG = "CB.HostEditorActivity";
- protected HostDatabase hostdb = null;
- private PubkeyDatabase pubkeydb = null;
-
private CursorPreferenceHack pref;
private ServiceConnection connection;
@@ -232,8 +230,7 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
// TODO: we could pass through a specific ContentProvider uri here
//this.getPreferenceManager().setSharedPreferencesName(uri);
- this.hostdb = HostDatabase.get(this);
- this.pubkeydb = PubkeyDatabase.get(this);
+ HostDatabase hostdb = HostDatabase.get(this);
host = hostdb.findHostById(hostId);
@@ -259,6 +256,7 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
// TODO: should consider moving into onStart, but we dont have a good way of resetting the listpref after filling once
ListPreference pubkeyPref = (ListPreference) findPreference(HostDatabase.FIELD_HOST_PUBKEYID);
+ PubkeyDatabase pubkeydb = PubkeyDatabase.get(this);
List<CharSequence> pubkeyNicks = new LinkedList<CharSequence>(Arrays.asList(pubkeyPref.getEntries()));
pubkeyNicks.addAll(pubkeydb.allValues(PubkeyDatabase.FIELD_PUBKEY_NICKNAME));
pubkeyPref.setEntries(pubkeyNicks.toArray(new CharSequence[pubkeyNicks.size()]));
@@ -293,9 +291,6 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
super.onStart();
bindService(new Intent(this, TerminalManager.class), connection, Context.BIND_AUTO_CREATE);
-
- hostdb = HostDatabase.get(this);
- pubkeydb = PubkeyDatabase.get(this);
}
@Override
@@ -303,12 +298,11 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
super.onStop();
unbindService(connection);
-
- hostdb = null;
- pubkeydb = null;
}
private void updateSummaries() {
+ PubkeyDatabase pubkeydb = PubkeyDatabase.get(this);
+
// for all text preferences, set hint as current database value
for (String key : this.pref.values.keySet()) {
if (key.equals(HostDatabase.FIELD_HOST_POSTLOGIN)) continue;