Fix crash when CMS dies and user returns to app view activity and taps a game

This commit is contained in:
Cameron Gutman 2018-10-30 20:21:11 -07:00
parent a7e65b47f9
commit 977215a098
2 changed files with 9 additions and 2 deletions

View File

@ -346,7 +346,8 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
} }
private void doPair(final ComputerDetails computer) { private void doPair(final ComputerDetails computer) {
if (computer.state == ComputerDetails.State.OFFLINE) { if (computer.state == ComputerDetails.State.OFFLINE ||
ServerHelper.getCurrentAddressFromComputer(computer) == null) {
Toast.makeText(PcView.this, getResources().getString(R.string.pair_pc_offline), Toast.LENGTH_SHORT).show(); Toast.makeText(PcView.this, getResources().getString(R.string.pair_pc_offline), Toast.LENGTH_SHORT).show();
return; return;
} }
@ -478,7 +479,8 @@ public class PcView extends Activity implements AdapterFragmentCallbacks {
} }
private void doUnpair(final ComputerDetails computer) { private void doUnpair(final ComputerDetails computer) {
if (computer.state == ComputerDetails.State.OFFLINE) { if (computer.state == ComputerDetails.State.OFFLINE ||
ServerHelper.getCurrentAddressFromComputer(computer) == null) {
Toast.makeText(PcView.this, getResources().getString(R.string.error_pc_offline), Toast.LENGTH_SHORT).show(); Toast.makeText(PcView.this, getResources().getString(R.string.error_pc_offline), Toast.LENGTH_SHORT).show();
return; return;
} }

View File

@ -37,6 +37,11 @@ public class ServerHelper {
public static void doStart(Activity parent, NvApp app, ComputerDetails computer, public static void doStart(Activity parent, NvApp app, ComputerDetails computer,
ComputerManagerService.ComputerManagerBinder managerBinder) { ComputerManagerService.ComputerManagerBinder managerBinder) {
if (computer.state == ComputerDetails.State.OFFLINE ||
ServerHelper.getCurrentAddressFromComputer(computer) == null) {
Toast.makeText(parent, parent.getResources().getString(R.string.pair_pc_offline), Toast.LENGTH_SHORT).show();
return;
}
parent.startActivity(createStartIntent(parent, app, computer, managerBinder)); parent.startActivity(createStartIntent(parent, app, computer, managerBinder));
} }