summaryrefslogtreecommitdiffstats
path: root/remoting/android
diff options
context:
space:
mode:
authorrkjnsn <rkjnsn@chromium.org>2016-01-26 15:08:01 -0800
committerCommit bot <commit-bot@chromium.org>2016-01-26 23:09:10 +0000
commitcb4601ae1cecf4a7d33a65df53c5c35f180129fe (patch)
tree0a557caf14cd0ee4479bb07a0681ff68c8170f1b /remoting/android
parente599495acceac5953cb80dc76d9b50ad78412c69 (diff)
downloadchromium_src-cb4601ae1cecf4a7d33a65df53c5c35f180129fe.zip
chromium_src-cb4601ae1cecf4a7d33a65df53c5c35f180129fe.tar.gz
chromium_src-cb4601ae1cecf4a7d33a65df53c5c35f180129fe.tar.bz2
Ensure no-hosts view doesn't appear while loading
Update the code handling switching out the various host-list-related views to handle the three views (loading, no hosts, and host chooser) directly instead of setting the no-hosts view as the chooser's empty view. The two-state empty view functionality doesn't appear to be designed to be used along side a third modal loading state. This fixes an issue where both the loading spinner and the "There's nothing to connect to" message could appear simultaneously under certain conditions. BUG=566177 Review URL: https://codereview.chromium.org/1608093002 Cr-Commit-Position: refs/heads/master@{#371625}
Diffstat (limited to 'remoting/android')
-rw-r--r--remoting/android/java/src/org/chromium/chromoting/Chromoting.java45
1 files changed, 29 insertions, 16 deletions
diff --git a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
index 800be2e..b87c1a6 100644
--- a/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
+++ b/remoting/android/java/src/org/chromium/chromoting/Chromoting.java
@@ -78,9 +78,12 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
/** Refresh button. */
private MenuItem mRefreshButton;
- /** Host list as it appears to the user. */
+ /** Host list chooser view shown when at least one host is configured. */
private ListView mHostListView;
+ /** View shown when the user has no configured hosts or host list couldn't be retrieved. */
+ private View mEmptyView;
+
/** Progress view shown instead of the host list when the host list is loading. */
private View mProgressView;
@@ -148,15 +151,25 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
dialog.show();
}
- /** Shows or hides the progress indicator for loading the host list. */
- private void setHostListProgressVisible(boolean visible) {
- mHostListView.setVisibility(visible ? View.GONE : View.VISIBLE);
- mProgressView.setVisibility(visible ? View.VISIBLE : View.GONE);
+ /**
+ * Displays the loading indicator. Currently this also hides the host list, but that may
+ * change.
+ */
+ private void showHostListLoadingIndicator() {
+ mHostListView.setVisibility(View.GONE);
+ mEmptyView.setVisibility(View.GONE);
+ mProgressView.setVisibility(View.VISIBLE);
+ }
- // Hiding the host-list does not automatically hide the empty view, so do that here.
- if (visible) {
- mHostListView.getEmptyView().setVisibility(View.GONE);
- }
+ /**
+ * Shows the appropriate view for the host list and hides the loading indicator. Shows either
+ * the host list chooser or the host list empty view, depending on whether mHosts contains any
+ * hosts.
+ */
+ private void updateHostListView() {
+ mHostListView.setVisibility(mHosts.length == 0 ? View.GONE : View.VISIBLE);
+ mEmptyView.setVisibility(mHosts.length == 0 ? View.VISIBLE : View.GONE);
+ mProgressView.setVisibility(View.GONE);
}
/**
@@ -176,7 +189,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
// Get ahold of our view widgets.
mHostListView = (ListView) findViewById(R.id.hostList_chooser);
- mHostListView.setEmptyView(findViewById(R.id.hostList_empty));
+ mEmptyView = findViewById(R.id.hostList_empty);
mHostListView.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
@@ -352,7 +365,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
} else {
// User denied permission or cancelled the dialog, so cancel the request.
mWaitingForAuthToken = false;
- setHostListProgressVisible(false);
+ updateHostListView();
}
}
}
@@ -453,7 +466,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
}
mTriedNewAuthToken = false;
- setHostListProgressVisible(true);
+ showHostListLoadingIndicator();
// The refresh button simply makes use of the currently-chosen account.
requestAuthToken(false);
@@ -474,7 +487,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
@Override
public void onError(int errorResource) {
mWaitingForAuthToken = false;
- setHostListProgressVisible(false);
+ updateHostListView();
String explanation = getString(errorResource);
Toast.makeText(Chromoting.this, explanation, Toast.LENGTH_LONG).show();
}
@@ -513,7 +526,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
// Store a copy of the array, so that it can't be mutated by the HostListLoader. HostInfo
// is an immutable type, so a shallow copy of the array is sufficient here.
mHosts = Arrays.copyOf(hosts, hosts.length);
- setHostListProgressVisible(false);
+ updateHostListView();
updateUi();
}
@@ -538,7 +551,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
if (explanation != null) {
Toast.makeText(this, explanation, Toast.LENGTH_LONG).show();
- setHostListProgressVisible(false);
+ updateHostListView();
return;
}
@@ -556,7 +569,7 @@ public class Chromoting extends AppCompatActivity implements ConnectionListener,
Log.e(TAG, "Fresh auth token was rejected.");
explanation = getString(R.string.error_authentication_failed);
Toast.makeText(this, explanation, Toast.LENGTH_LONG).show();
- setHostListProgressVisible(false);
+ updateHostListView();
}
}