aboutsummaryrefslogtreecommitdiffstats
path: root/app/src/main/java/org/connectbot/HostListActivity.java
diff options
context:
space:
mode:
authorKenny Root <kenny@the-b.org>2015-09-23 17:37:47 -0700
committerKenny Root <kenny@the-b.org>2015-09-23 17:37:50 -0700
commite169dd914f99c4a0253b578c044f8d17714210e7 (patch)
treefab1c67fd08c6e667c7ddc6852e49fbd743652d7 /app/src/main/java/org/connectbot/HostListActivity.java
parente1ecc6308b3713b940f5e8d1270734d7d1401dfe (diff)
downloadconnectbot-e169dd914f99c4a0253b578c044f8d17714210e7.tar.gz
connectbot-e169dd914f99c4a0253b578c044f8d17714210e7.tar.bz2
connectbot-e169dd914f99c4a0253b578c044f8d17714210e7.zip
Only use host if it is not null
Since we null check the host, we should make sure not to dereference it later on.
Diffstat (limited to 'app/src/main/java/org/connectbot/HostListActivity.java')
-rw-r--r--app/src/main/java/org/connectbot/HostListActivity.java17
1 files changed, 9 insertions, 8 deletions
diff --git a/app/src/main/java/org/connectbot/HostListActivity.java b/app/src/main/java/org/connectbot/HostListActivity.java
index fe5207a..d844c50 100644
--- a/app/src/main/java/org/connectbot/HostListActivity.java
+++ b/app/src/main/java/org/connectbot/HostListActivity.java
@@ -500,14 +500,17 @@ public class HostListActivity extends AppCompatListActivity implements OnHostSta
*/
private int getConnectedState(HostBean host) {
// always disconnected if we don't have backend service
- if (this.manager == null)
+ if (this.manager == null || host == null) {
return STATE_UNKNOWN;
+ }
- if (manager.getConnectedBridge(host) != null)
+ if (manager.getConnectedBridge(host) != null) {
return STATE_CONNECTED;
+ }
- if (manager.disconnected.contains(host))
+ if (manager.disconnected.contains(host)) {
return STATE_DISCONNECTED;
+ }
return STATE_UNKNOWN;
}
@@ -525,16 +528,14 @@ public class HostListActivity extends AppCompatListActivity implements OnHostSta
HostViewHolder hostHolder = (HostViewHolder) holder;
HostBean host = hosts.get(position);
+ hostHolder.host = host;
if (host == null) {
// Well, something bad happened. We can't continue.
Log.e("HostAdapter", "Host bean is null!");
-
hostHolder.nickname.setText("Error during lookup");
- hostHolder.caption.setText("see 'adb logcat' for more");
+ } else {
+ hostHolder.nickname.setText(host.getNickname());
}
- hostHolder.host = host;
-
- hostHolder.nickname.setText(host.getNickname());
switch (this.getConnectedState(host)) {
case STATE_UNKNOWN: