oli107 / material-range-bar

Android widget for selecting a range of values.
Apache License 2.0
1.68k stars 370 forks source link

rangeBar throws NullPointer exception when it crosses an index #13

Closed joaodias closed 9 years ago

joaodias commented 9 years ago

Hi, I'm using the rangeBar with a single value. I have a bar with 24 indexes and whenever the pin crosses the index 3 the application throws a NullPointerException. Anyone having the same problem? I already try to play with some xml properties but I still have the problem.

Below is my xml code:

<com.appyvet.rangebar.RangeBar
                xmlns:custom="http://schemas.android.com/apk/res-auto"
                android:id="@+id/slider"
                android:layout_width="wrap_content"
                android:layout_height="64dp"
                custom:tickStart="0"
                custom:tickInterval="1"
                custom:tickEnd="24"
                custom:pinColor="#ec3852"
                custom:pinRadius="10dp"
                custom:selectorColor="#ec3852"
                custom:tickColor="#00ffffff"
                custom:selectorSize="4dp"
                custom:connectingLineColor="#ec3852"
                custom:connectingLineWeight="1dp"
                custom:pinMaxFont="10sp"
                custom:barWeight="1dp"
                custom:rangeBar="false"
                android:layout_alignTop="@+id/search_radius"
                android:layout_alignEnd="@+id/slider2"
                android:layout_toEndOf="@+id/auto"
                android:layout_alignStart="@+id/slider2"
                android:layout_marginTop="8dp" />
oli107 commented 9 years ago

Can you post the exception with the NPE?

joaodias commented 9 years ago

Thanks for answer @oli107. Here is the exception:

10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime: FATAL EXCEPTION: main
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime: java.lang.NullPointerException
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.appyvet.rangebar.RangeBar.movePin(RangeBar.java:1426)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.appyvet.rangebar.RangeBar.onActionMove(RangeBar.java:1305)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.appyvet.rangebar.RangeBar.onTouchEvent(RangeBar.java:440)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.View.dispatchTouchEvent(View.java:7317)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTransformedTouchEvent(ViewGroup.java:2259)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:1964)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:2063)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1443)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.app.Activity.dispatchTouchEvent(Activity.java:2429)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.support.v7.internal.view.WindowCallbackWrapper.dispatchTouchEvent(WindowCallbackWrapper.java:60)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:2011)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.View.dispatchPointerEvent(View.java:7508)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl.deliverPointerEvent(ViewRootImpl.java:3655)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl.deliverInputEvent(ViewRootImpl.java:3580)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl.doProcessInputEvents(ViewRootImpl.java:4850)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl.enqueueInputEvent(ViewRootImpl.java:4810)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl$WindowInputEventReceiver.onInputEvent(ViewRootImpl.java:4966)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.InputEventReceiver.dispatchInputEvent(InputEventReceiver.java:179)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.InputEventReceiver.nativeConsumeBatchedInputEvents(Native Method)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.InputEventReceiver.consumeBatchedInputEvents(InputEventReceiver.java:171)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl.doConsumeBatchedInput(ViewRootImpl.java:4934)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.ViewRootImpl$ConsumeBatchedInputRunnable.run(ViewRootImpl.java:4988)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:776)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.Choreographer.doCallbacks(Choreographer.java:579)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:546)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:762)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:800)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:100)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:194)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5434)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:525)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:834)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
10-29 13:30:45.091 14510-14510/meta.onme E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
oli107 commented 9 years ago

Check you are using the latest version, this was fixed in v1.2 with a null check at line 1426