Coder Social home page Coder Social logo

Trying to start CircularReveal animation got Runtime error: "Cannot start this animator on a detached view" about fab-speed-dial HOT 7 CLOSED

yavski avatar yavski commented on June 18, 2024
Trying to start CircularReveal animation got Runtime error: "Cannot start this animator on a detached view"

from fab-speed-dial.

Comments (7)

yavski avatar yavski commented on June 18, 2024

If I read your stack trace correctly it seems that it pops because (exitTransitionView == null || exitTransitionView.atachInfo == null). Have you confirmed if that's not the case? If you can provide me with a sample app, I'm happy to look into it.

from fab-speed-dial.

yytsui avatar yytsui commented on June 18, 2024

I did try to reproduce the crash with a simple example in my circularReveal branch:
https://github.com/yytsui/fab-speed-dial/tree/circularReveal
However, it worked well and did not crash :).
At the meantime, for the case in xbmc/Kore#301
@poisdeux found that just set app:touchGuard="false" then the Kore app works fine without crash. Not sure does this give some hint about the cause of crash while app:touchGuard="true"? Maybe I should also mention clearly that animator was started from an asynchronous call back:

FabSpeedDial fabSpeedDial = (FabSpeedDial) findViewById(R.id.fab_speed_dial);
fabSpeedDial.setMenuListener(new SimpleMenuListenerAdapter() {
    @Override
    public boolean onMenuItemSelected(MenuItem menuItem) {
        switch (menuItem.getItemId()) {
            case R.id.play_on_osmc:
                async_request(url, new ApiCallback<String>(){
                    @Override
                    public void onSuccess(String result) {
                        //exitTransitionView is a hidden view that has already been inflated.
                        // Runtime Error here while app:touchGuard="true" !!!
                        ViewAnimationUtils.createCircularReveal(exitTransitionView, centerX, >centerY, 0, endRadius); 
                    }
                });
                break;
        }
    }
});

I will investigate further to see if I can reproduce the crash by modifying my simple example to start the animator from an an asynchronous callback.

from fab-speed-dial.

yavski avatar yavski commented on June 18, 2024

It sounds like between the click event and the api callback, exitTransitionView gets detached if the touch guard is enabled. I can't think of how the library could cause that, I'll investigate it tonight.

from fab-speed-dial.

yytsui avatar yytsui commented on June 18, 2024

I think I found the cause, it's not related to async callback. The problem is in case touchGuard is used, the origin view next to FabSpeedDial is going to lost it's mAttachInfo, i.e. exitTransitionView.atachInfo == null as you mentioned above, which in turn throw the Runtime IllegalState Exception.
You can checkout my circularReveal branch:
https://github.com/yytsui/fab-speed-dial/tree/circularReveal
to see that happen by setting a break point inside CirularRevealAcitivity#hide before the animator was created.
It can be fixed by

  1. exchange order of <io.github.yavski.fabspeeddial.FabSpeedDial> and in activity_circular_reveal.xml. That is ,make sure FabSpeedDial is the last one of the layout children.
    or
  2. In library/src/main/java/io/github/yavski/fabspeeddial/FabSpeedDial.java (line 312)
    change
    coordinatorLayout.addView(touchGuard, coordinatorLayout.indexOfChild(this));
    to
    coordinatorLayout.addView(touchGuard)
    (the same for FrameLayout and RelativeLayout I guess)
    but I am not sure if this going to cause problem if touchGuardDrawable is used ??

In short, addView(view, index) caused the original view next to FabSpeedDial in layout nullify it's mAttachInfo!

from fab-speed-dial.

yavski avatar yavski commented on June 18, 2024

@yytsui Thank you for the feedback. Just had a look at your branch. This was such a bummer! The intention at L312 (as well as with the same call for the other view group types) was to make sure the touch guard view is added as the last child view of the view group, i.e. it is first to intercept touch events. The issue was that in fact it was replacing whatever is at index viewGroup. indexOfChild(FabSpeedDial.this). That was a silly assumption that the fab view would be the last child view in its view group. In your case you happened to have something else and effectively the touch guard view was replacing your image view hence the image view was being detached at the point of starting the circular animation. Although you can see the image being rendered if you took a snapshot of the view hierarchy you would see the image view wasn't there. To me this seems a bug in the application framework too. Anyway, I will release a fix in a couple of hours. Cheers.

from fab-speed-dial.

yytsui avatar yytsui commented on June 18, 2024

I am sorry that I gave you incorrect formation on my last comment:

2.change
coordinatorLayout.addView(touchGuard, coordinatorLayout.indexOfChild(this));
to
coordinatorLayout.addView(touchGuard)

may not fix this issue, because after this change, the menu item listeners are NOT triggered, then of course there won't be Runtime error.
I guess because I have another vanilla toggle button on the same activity to trigger animation, so
I mixed up the testing steps.

To reproduce this issue in version 1.0.7:
In your samples, set app:touchGouad="true" in activity_events_sample.xml and try the EventsSampleActivity, then all the menu item listeners callbacks won't get triggered!!!

I agree with you that this seems to be an Android SDK bug. Who will expect addView(view, index) "replace" the views[index]??

Anyway I would suggest to reopen this ticket or open a new ticket for this issue. Maybe revert 8848713 and add a reminder

FabSpeedDial should be the last view in ViewGroup if app:touchGouad="true"

in ReadMe until a workaround is figured out or the Android SDK bug is fixed?
Thanks!

from fab-speed-dial.

EjaYF avatar EjaYF commented on June 18, 2024

So this component in version 1.0.7 is in a non-working state, so we are reverting to 1.0.6. Is there any update on this yet?

from fab-speed-dial.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.