aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/org/connectbot/HostEditorActivity.java
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-09-11 10:57:30 -0700
committerKenny Root <kenny@the-b.org>2015-09-11 11:01:56 -0700
commit2baa56c2629532adad82d0f67abe9dd568a24760 (patch)
treea2389ad30251f44dfa9c388cf8c1cee18e5c1338 /app/src/main/java/org/connectbot/HostEditorActivity.java
parent5d2ebeaa409fb2f74fe9eb799793cc004f9d9d29 (diff)
downloadconnectbot-2baa56c2629532adad82d0f67abe9dd568a24760.tar.gz
connectbot-2baa56c2629532adad82d0f67abe9dd568a24760.tar.bz2
connectbot-2baa56c2629532adad82d0f67abe9dd568a24760.zip
Revert "Never cache instances of the HostDatabase"
This reverts commit 57afa9bdc5b269a48bd27fc8455cab4cb956d02a. This won't work with injection and makes testing a bit harder, so revert it.
Diffstat (limited to 'app/src/main/java/org/connectbot/HostEditorActivity.java')
-rw-r--r--app/src/main/java/org/connectbot/HostEditorActivity.java17
1 files changed, 11 insertions, 6 deletions
diff --git a/app/src/main/java/org/connectbot/HostEditorActivity.java b/app/src/main/java/org/connectbot/HostEditorActivity.java
index 7316775..f9dee45 100644
--- a/app/src/main/java/org/connectbot/HostEditorActivity.java
+++ b/app/src/main/java/org/connectbot/HostEditorActivity.java
@@ -68,7 +68,6 @@ 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);
@@ -99,7 +98,6 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
}
public boolean commit() {
- HostDatabase hostdb = HostDatabase.get(HostEditorActivity.this);
SQLiteDatabase db = hostdb.getWritableDatabase();
db.beginTransaction();
try {
@@ -215,6 +213,9 @@ 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;
@@ -230,7 +231,8 @@ public class HostEditorActivity extends PreferenceActivity implements OnSharedPr
// TODO: we could pass through a specific ContentProvider uri here
//this.getPreferenceManager().setSharedPreferencesName(uri);
- HostDatabase hostdb = HostDatabase.get(this);
+ this.hostdb = HostDatabase.get(this);
+ this.pubkeydb = PubkeyDatabase.get(this);
host = hostdb.findHostById(hostId);
@@ -256,7 +258,6 @@ 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()]));
@@ -291,6 +292,9 @@ 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
@@ -298,11 +302,12 @@ 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;