Fix race condition on AppView activity startup

This commit is contained in:
Cameron Gutman 2018-10-30 17:52:46 -07:00
parent 7126055ad6
commit a7e65b47f9

View File

@ -81,11 +81,8 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
// Wait for the binder to be ready // Wait for the binder to be ready
localBinder.waitForReady(); localBinder.waitForReady();
// Now make the binder visible
managerBinder = localBinder;
// Get the computer object // Get the computer object
computer = managerBinder.getComputer(UUID.fromString(uuidString)); computer = localBinder.getComputer(UUID.fromString(uuidString));
if (computer == null) { if (computer == null) {
finish(); finish();
return; return;
@ -95,13 +92,18 @@ public class AppView extends Activity implements AdapterFragmentCallbacks {
appGridAdapter = new AppGridAdapter(AppView.this, appGridAdapter = new AppGridAdapter(AppView.this,
PreferenceConfiguration.readPreferences(AppView.this).listMode, PreferenceConfiguration.readPreferences(AppView.this).listMode,
PreferenceConfiguration.readPreferences(AppView.this).smallIconMode, PreferenceConfiguration.readPreferences(AppView.this).smallIconMode,
computer, managerBinder.getUniqueId()); computer, localBinder.getUniqueId());
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
finish(); finish();
return; return;
} }
// Now make the binder visible. We must do this after appGridAdapter
// is set to prevent us from reaching updateUiWithServerinfo() and
// touching the appGridAdapter prior to initialization.
managerBinder = localBinder;
// Load the app grid with cached data (if possible). // Load the app grid with cached data (if possible).
// This must be done _before_ startComputerUpdates() // This must be done _before_ startComputerUpdates()
// so the initial serverinfo response can update the running // so the initial serverinfo response can update the running