So I want to animate my DrawerLayout in such a way that it is opened, an item is added to the menu in it, then it is closed.
I tried a great deal of things, but the problem is that there is no delay between the "Open" and "Close" commands (or at least not a noticeable one) and so the animation never triggers.
I really don't want to use a 'post delayed' with an arbitrary length because that seems dirty. I've tried manually overriding "onDrawerOpened()" in the listener - which WORKED, but then I can't CLOSE it AFTER the action is performed because you can't close it from within itself (meaning, if the 'closeDrawer(layout)' method is invoked from any sub-thread of the listener itself, it'll get a runtime error).
So what I have is:
_drawerToggle = new ActionBarDrawerToggle(MainActivity.this, _drawerLayout, R.drawable.ic_drawer, R.string.drawerOpen, R.string.drawerClose)
{
/** Called when a drawer has settled in a completely closed state. */
public void onDrawerClosed(View view) {
getActionBar().setTitle(_title);
}
/** Called when a drawer has settled in a completely open state. */
public void onDrawerOpened(View drawerView) {
myAction(); //My action
//If I try to invoke 'drawerClose()' here or in my action, a runtime error occurs
}
};
_drawerLayout.setDrawerListener(_drawerToggle);
_drawerLayout.openDrawer(_mainFrame);
//If I invoke 'drawerClose()' the entire thing is just too fast and the animations don't trigger
I even tried 'getAnimation()' on the DrawerLayout but it returns null so I can't use it to post a delayed action.
Anyone have an idea how to approach this? Should I just used an arbitrary delay and hope it looks the same on all devices? Is there a way to close the drawer from within the listener? Thanks in advance!