glomadrian / material-animated-switch

A material Switch with icon animations and color transitions
1.18k stars 158 forks source link

Getting error when trying to programmatic set it as checked or unchecked. #4

Closed EugeneHoran closed 9 years ago

EugeneHoran commented 9 years ago

Getting an error when calling .check(), unCheck();

06-17 15:24:41.684    4347-4347/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
    Process: com.eugene.fithealthmaingit, PID: 4347
    java.lang.RuntimeException: Unable to start activity ComponentInfo{com.eugene.fithealthmaingit/com.eugene.fithealthmaingit.UI.SaveSearchAddItemActivityMain}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.animation.ValueAnimator.reverse()' on a null object reference
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2298)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.animation.ValueAnimator.reverse()' on a null object reference
            at com.github.glomadrian.materialanimatedswitch.painter.BallPainter.setState(BallPainter.java:111)
            at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.setState(MaterialAnimatedSwitch.java:139)
            at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.unCheck(MaterialAnimatedSwitch.java:179)
            at com.eugene.fithealthmaingit.UI.SaveSearchItemFragment.findViewsById(SaveSearchItemFragment.java:250)
            at com.eugene.fithealthmaingit.UI.SaveSearchItemFragment.onCreateView(SaveSearchItemFragment.java:150)
            at android.support.v4.app.Fragment.performCreateView(Fragment.java:1789)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:955)
            at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1138)
            at android.support.v4.app.BackStackRecord.run(BackStackRecord.java:740)
            at android.support.v4.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:1501)
            at android.support.v4.app.FragmentActivity.onStart(FragmentActivity.java:551)
            at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1220)
            at android.app.Activity.performStart(Activity.java:5949)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
            at android.app.ActivityThread.access$800(ActivityThread.java:144)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
            at android.os.Handler.dispatchMessage(Handler.java:102)
            at android.os.Looper.loop(Looper.java:135)
            at android.app.ActivityThread.main(ActivityThread.java:5221)
            at java.lang.reflect.Method.invoke(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:372)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
mohamed-fareed commented 9 years ago

+1

mcguile commented 9 years ago

+1

glomadrian commented 9 years ago

The version 1.1 have a toggle() method that changes the state of the swicth, i'd like to add check() and unCheck() methods without trigger any animations in a future release.

MarsVard commented 9 years ago

the toggle method does not work, I get a nullpointer somewhere in the library

ddqd commented 9 years ago

I get a nullpointer

this

EugeneHoran commented 9 years ago

Hey.

I am working rite now. Once I get home I will send you all of the info. Cheers!

On Thu, Jul 23, 2015, 9:15 AM Dmitry Gureev notifications@github.com wrote:

I get a nullpointer

this

— Reply to this email directly or view it on GitHub https://github.com/glomadrian/material-animated-switch/issues/4#issuecomment-124093487 .

hongzhou85 commented 9 years ago

java.lang.RuntimeException: Unable to start activity ComponentInfo{co.yproject.bys/co.yproject.bys.beautyme.SettingsActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.animation.ValueAnimator.start()' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2693) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2758) at android.app.ActivityThread.access$900(ActivityThread.java:177) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1448) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:145) at android.app.ActivityThread.main(ActivityThread.java:5942) at java.lang.reflect.Method.invoke(Native Method) at java.lang.reflect.Method.invoke(Method.java:372) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1400) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1195) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.animation.ValueAnimator.start()' on a null object reference at com.github.glomadrian.materialanimatedswitch.painter.BallPainter.setState(BallPainter.java:108) at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.setState(MaterialAnimatedSwitch.java:139) at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.doActionDown(MaterialAnimatedSwitch.java:164) at com.github.glomadrian.materialanimatedswitch.MaterialAnimatedSwitch.toggle(MaterialAnimatedSwitch.java:178)

Xerosigma commented 8 years ago

I'm having the very same issue. has this been addressed?

com.github.glomadrian:MaterialAnimatedSwitch:1.1@aar

MrSMAK commented 8 years ago

I got the same issue.

Shaheedullah commented 6 years ago

i got the same issue

Shaheedullah commented 6 years ago

compile 'com.github.glomadrian:MaterialAnimatedSwitch:1.1@aar'

maven { url "http://dl.bintray.com/glomadrian/maven" } add this both but my problem is not solve