diff options
author | Kenny Root <kenny@the-b.org> | 2015-09-11 10:57:30 -0700 |
---|---|---|
committer | Kenny Root <kenny@the-b.org> | 2015-09-11 11:01:56 -0700 |
commit | 2baa56c2629532adad82d0f67abe9dd568a24760 (patch) | |
tree | a2389ad30251f44dfa9c388cf8c1cee18e5c1338 /app/src/main/java/org/connectbot/PortForwardListActivity.java | |
parent | 5d2ebeaa409fb2f74fe9eb799793cc004f9d9d29 (diff) | |
download | connectbot-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/PortForwardListActivity.java')
-rw-r--r-- | app/src/main/java/org/connectbot/PortForwardListActivity.java | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/app/src/main/java/org/connectbot/PortForwardListActivity.java b/app/src/main/java/org/connectbot/PortForwardListActivity.java index c3b3b8f..894eed4 100644 --- a/app/src/main/java/org/connectbot/PortForwardListActivity.java +++ b/app/src/main/java/org/connectbot/PortForwardListActivity.java @@ -68,6 +68,8 @@ public class PortForwardListActivity extends ListActivity { private static final int LISTENER_CYCLE_TIME = 500; + protected HostDatabase hostdb; + private List<PortForwardBean> portForwards; private ServiceConnection connection = null; @@ -81,6 +83,8 @@ public class PortForwardListActivity extends ListActivity { super.onStart(); this.bindService(new Intent(this, TerminalManager.class), connection, Context.BIND_AUTO_CREATE); + + hostdb = HostDatabase.get(this); } @Override @@ -88,6 +92,8 @@ public class PortForwardListActivity extends ListActivity { super.onStop(); this.unbindService(connection); + + hostdb = null; } @Override @@ -99,7 +105,7 @@ public class PortForwardListActivity extends ListActivity { setContentView(R.layout.act_portforwardlist); // connect with hosts database and populate list - HostDatabase hostdb = HostDatabase.get(this); + this.hostdb = HostDatabase.get(this); host = hostdb.findHostById(hostId); { @@ -338,7 +344,6 @@ public class PortForwardListActivity extends ListActivity { if (hostBridge != null) hostBridge.removePortForward(pfb); - HostDatabase hostdb = HostDatabase.get(PortForwardListActivity.this); hostdb.deletePortForward(pfb); } catch (Exception e) { Log.e(TAG, "Could not delete port forward", e); @@ -365,8 +370,8 @@ public class PortForwardListActivity extends ListActivity { if (hostBridge != null) { this.portForwards = hostBridge.getPortForwards(); } else { - HostDatabase hostdb = HostDatabase.get(this); - this.portForwards = hostdb.getPortForwardsForHost(host); + if (this.hostdb == null) return; + this.portForwards = this.hostdb.getPortForwardsForHost(host); } PortForwardAdapter adapter = new PortForwardAdapter(this, portForwards); |