geftimov / android-pathview

Android view with both path from constructed path or from svg.
Apache License 2.0
2.91k stars 513 forks source link

divide by zero #40

Open moeindev opened 6 years ago

moeindev commented 6 years ago

hi, thank for this great library but I have a problem I get this error when I'm trying to run it my splash activity

here is the error : 02-02 14:24:17.101 15421-15421/? E/AndroidRuntime: FATAL EXCEPTION: main Process: telegram.abdi.messangerbot, PID: 15421 java.lang.RuntimeException: Unable to start activity ComponentInfo{telegram.abdi.messangerbot/telegram.abdi.messangerbot.Activities.SplashActivity}: java.lang.ArithmeticException: divide by zero at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2666) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2727) at android.app.ActivityThread.-wrap12(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1478) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:154) at android.app.ActivityThread.main(ActivityThread.java:6121) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) Caused by: java.lang.ArithmeticException: divide by zero at com.eftimoff.androipathview.PathView$AnimatorSetBuilder.duration(PathView.java:620) at telegram.abdi.messangerbot.Activities.SplashActivity.onCreate(SplashActivity.java:35) at android.app.Activity.performCreate(Activity.java:6723) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1119) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2619)

and here is my code : splash_view.setSvgResource(R.drawable.ic_splash_bot); splash_view.getSequentialPathAnimator() .delay(500) .duration(500) .listenerStart(new StartListener()) .listenerEnd(new EndListener()) .interpolator(new AccelerateDecelerateInterpolator()) .start(); splash_view.useNaturalColors(); splash_view.setFillAfter(true);

MaxMyalkin commented 6 years ago

It's because paths are loaded asynchronously in PathView. image

and there is no paths when you try to set duration.

You can try to run animation after delay: Handler(Looper.getMainLooper()).postDelayed({ pathView.sequentialPathAnimator .duration(500) .listenerEnd({}) .interpolator(AccelerateDecelerateInterpolator()) .start() }, 300)