diogobernardino / williamchart

Android Library to rapidly develop attractive and insightful charts in android applications.
5.1k stars 800 forks source link

Animation restart #222

Closed JohannesDev closed 4 years ago

JohannesDev commented 6 years ago

I'm really sorry to ask this (probably) stupid question but I just seem to be stuck on this issue. How can I control the Animation? I learned from your sample application that show() and dismiss() are used. But when I use them more than once my Application crashes. I would like to restart the animation every time my switch gets clicked.

I'm defining my LineChartView and then in my Switch OnCheckedChangeListener I want to control the animation (show & dismiss)

@Override
    public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
        Animation bounceAnim = new Animation(1800).setInterpolator(new BounceInterpolator());

        switch (buttonView.getId()) {
            case R.id.switchAnimate:

                if(isChecked == true){
                    lineChartView.show(bounceAnim);
                }
                else{
                    lineChartView.dismiss(bounceAnim);
                }
                break;
        }
    }
diogobernardino commented 6 years ago

What is the exception you get with the crash?

JohannesDev commented 6 years ago

Thanks for your response. My exception:

E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.johannes.chartapp, PID: 4029
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
          at java.util.ArrayList.get(ArrayList.java:411)
          at com.db.chart.renderer.AxisRenderer.extractLabels(AxisRenderer.java:327)
          at com.db.chart.renderer.AxisRenderer.init(AxisRenderer.java:132)
          at com.db.chart.view.ChartView$1.onPreDraw(ChartView.java:171)
          at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
          at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2201)
          at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246)
          at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301)
          at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871)
          at android.view.Choreographer.doCallbacks(Choreographer.java:683)
          at android.view.Choreographer.doFrame(Choreographer.java:619)
          at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857)
          at android.os.Handler.handleCallback(Handler.java:751)
          at android.os.Handler.dispatchMessage(Handler.java:95)
          at android.os.Looper.loop(Looper.java:154)
          at android.app.ActivityThread.main(ActivityThread.java:6077)
          at java.lang.reflect.Method.invoke(Native Method)
          at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
          at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
JohannesDev commented 6 years ago

@diogobernardino Any updates on this?

tanujkucp commented 6 years ago

I am also having the same problem but in a different scenario. I get in only some devices and not on all devices, and that too not always. Please help if you have got the solution to this

diogobernardino commented 4 years ago

Not supporting v2 anymore.