QuadFlask / colorpicker

🍭color picker for android
1.22k stars 219 forks source link

Initialize colorCircleList earlier to avoid race condition NPE #57

Closed Nilhcem closed 8 years ago

Nilhcem commented 8 years ago

A race condition on ColorPickerView makes apps crash

How to reproduce

It may require many tries to reproduce. I personally had this crash a few times unintentionally.

com.flask.colorpicker.sample E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.flask.colorpicker.sample, PID: 22545
java.lang.NullPointerException: Attempt to invoke interface method 'java.util.Iterator java.util.List.iterator()' on a null object reference
    at com.flask.colorpicker.ColorPickerView.findNearestByPosition(ColorPickerView.java:261)
    at com.flask.colorpicker.ColorPickerView.onTouchEvent(ColorPickerView.java:210)
    at android.view.View.dispatchTouchEvent(View.java:9993)

This PR makes sure the AbsColorWheelRenderer.colorCircleList is never null