-
Notifications
You must be signed in to change notification settings - Fork 224
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
NullPointerException in findNearestByColor #32
Comments
The problem is that this.renderer.initWith(colorWheelRenderOption) in ColorPickerView is not called and colorCircleList is therefore null. The reason for this is that onWindowFocusChanged which updates the color wheel is not called( e.g. the colorpicker is in a fragment and the fragment is replaced). One workaround that seems to work is: ViewTreeObserver vto = colorPickerView.getViewTreeObserver();
vto.addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
colorPickerView.onWindowFocusChanged(true);
ViewTreeObserver obs = colorPickerView.getViewTreeObserver();
obs.removeGlobalOnLayoutListener(this);
}
}); |
Where I need to apply this code?I have applied to my Fragment and as well as ColorPickerView. at com.flask.colorpicker.ColorPickerView.findNearestByColor(ColorPickerView.java:281) |
Calling it in onStart() in a Fragment worked for me. |
I am not showing that color picker in Alert Dialog. I am loading that view to my Linear layout. will it work fine with it ? public ColorPickerDemo(Context context, LinearLayout layout) {
|
@fxlex Thanks! I has already resolve my problem ! |
java.lang.NullPointerException
at com.flask.colorpicker.ColorPickerView.findNearestByColor(ColorPickerView.java:266)
at com.flask.colorpicker.ColorPickerView.onWindowFocusChanged(ColorPickerView.java:123)
at android.view.View.dispatchWindowFocusChanged(View.java:7900)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:972)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:972)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:972)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:972)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:972)
at android.view.ViewGroup.dispatchWindowFocusChanged(ViewGroup.java:972)
at android.view.ViewRootImpl$ViewRootHandler.handleMessage(ViewRootImpl.java:3133)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5001)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
at dalvik.system.NativeStart.main(Native Method)
The text was updated successfully, but these errors were encountered: