Shutter-Android icon indicating copy to clipboard operation
Shutter-Android copied to clipboard

Null pointer exceptions in Builders

Open levibostian opened this issue 8 years ago • 2 comments

I have been using the lib in a couple apps of mine and I have run into NPEs.

In the builder patterns where I am doing companion.getActivity()!!, for example, could have a null activity.

levibostian avatar Jul 26 '17 17:07 levibostian

One place in particular I am talking about here is:

            fun runOnUI(run: () -> Unit) {
                companion.getActivity()!!.runOnUiThread {
                    run.invoke()
                }
            }

Where companion.getActivity()!! is causing a NPE. Another way to run on background and UI thread? I would like to call from the thread that was called to me upon, doesn't have to be the UI thread.

levibostian avatar Jul 26 '17 19:07 levibostian

I fixed the above issue with companion.getActivity()!! being null via commit: https://github.com/levibostian/Shutter-Android/commit/2aa136874a596a358b68fd1639da87958d833fdd

levibostian avatar Jul 26 '17 19:07 levibostian