FATAL EXCEPTION: main
Process: co.krypt.kryptonite, PID: 6365
java.lang.NullPointerException: Attempt to invoke virtual method 'void android.view.View.setVisibility(int)' on a null object reference
at co.krypt.kryptonite.devices.DevicesFragment.populateDevices(DevicesFragment.java:146)
at co.krypt.kryptonite.devices.DevicesFragment.onSharedPreferenceChanged(DevicesFragment.java:139)
at android.app.SharedPreferencesImpl$EditorImpl.notifyListeners(SharedPreferencesImpl.java:479)
at android.app.SharedPreferencesImpl$EditorImpl.-wrap0(SharedPreferencesImpl.java)
at android.app.SharedPreferencesImpl$EditorImpl$3.run(SharedPreferencesImpl.java:487)
at android.os.Handler.handleCallback(Handler.java:751)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:241)
at android.app.ActivityThread.main(ActivityThread.java:6217)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
The problem appears to be that DevicesFragment is registered as a OnSharedPreferenceChangeListener onAttach. The change listener, which can end up called immediately, expects state to be ready that is not configured before onCreateView, which is called after onAttach. See https://developer.android.com/reference/android/app/Fragment.html.
The problem appears to be that DevicesFragment is registered as a OnSharedPreferenceChangeListener onAttach. The change listener, which can end up called immediately, expects state to be ready that is not configured before onCreateView, which is called after onAttach. See https://developer.android.com/reference/android/app/Fragment.html.