diff --git a/app/app.iml b/app/app.iml index 4bffb70..f15f948 100644 --- a/app/app.iml +++ b/app/app.iml @@ -83,8 +83,8 @@ - + diff --git a/app/src/main/java/me/datenknoten/tueroeffner/DerivBroadcastReceiver.java b/app/src/main/java/me/datenknoten/tueroeffner/DerivBroadcastReceiver.java index 9123269..eca2843 100644 --- a/app/src/main/java/me/datenknoten/tueroeffner/DerivBroadcastReceiver.java +++ b/app/src/main/java/me/datenknoten/tueroeffner/DerivBroadcastReceiver.java @@ -21,24 +21,24 @@ public class DerivBroadcastReceiver extends BroadcastReceiver { final String action = intent.getAction(); if (action.equals(WifiManager.NETWORK_STATE_CHANGED_ACTION)) { NetworkInfo nwInfo = intent.getParcelableExtra(WifiManager.EXTRA_NETWORK_INFO); - if (nwInfo.getExtraInfo().equals(MainActivity.networkSSID) && nwInfo.isConnected()) { - View rootView = ((Activity)context).getWindow().getDecorView().findViewById(android.R.id.content); - Button button = (Button) rootView.findViewById(R.id.button_buzzer); - button.setEnabled(true); - button = (Button) rootView.findViewById(R.id.button_door_unlock); - button.setEnabled(true); - button = (Button) rootView.findViewById(R.id.button_door_open); - button.setEnabled(true); - Toast.makeText(context, context.getString(R.string.wlan_connected), Toast.LENGTH_SHORT).show(); - } else { - View rootView = ((Activity)context).getWindow().getDecorView().findViewById(android.R.id.content); - Button button = (Button) rootView.findViewById(R.id.button_buzzer); - button.setEnabled(false); - button = (Button) rootView.findViewById(R.id.button_door_unlock); - button.setEnabled(false); - button = (Button) rootView.findViewById(R.id.button_door_open); - button.setEnabled(false); - } + if (nwInfo.getExtraInfo() != null && nwInfo.getExtraInfo().equals(MainActivity.networkSSID) && nwInfo.isConnected()) { + View rootView = ((Activity)context).getWindow().getDecorView().findViewById(android.R.id.content); + Button button = (Button) rootView.findViewById(R.id.button2); + button.setEnabled(true); + button = (Button) rootView.findViewById(R.id.button3); + button.setEnabled(true); + button = (Button) rootView.findViewById(R.id.button); + button.setEnabled(true); + Toast.makeText(context, context.getString(R.string.wlan_connected), Toast.LENGTH_SHORT).show(); + } else { + View rootView = ((Activity)context).getWindow().getDecorView().findViewById(android.R.id.content); + Button button = (Button) rootView.findViewById(R.id.button2); + button.setEnabled(false); + button = (Button) rootView.findViewById(R.id.button3); + button.setEnabled(false); + button = (Button) rootView.findViewById(R.id.button); + button.setEnabled(false); + } } } }