use of android.support.v4.widget.DrawerLayout.DrawerListener in project double-espresso by JakeWharton.
the class DrawerActions method registerListener.
/**
* Returns a {@link ViewAction} that adds an {@link IdlingDrawerListener} as a drawer listener to
* the {@link DrawerLayout}. The idling drawer listener wraps any listener that already exists.
*/
private static ViewAction registerListener() {
return new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return isAssignableFrom(DrawerLayout.class);
}
@Override
public String getDescription() {
return "register idling drawer listener";
}
@Override
public void perform(UiController uiController, View view) {
DrawerLayout drawer = (DrawerLayout) view;
DrawerListener existingListener = getDrawerListener(drawer);
if (existingListener instanceof IdlingDrawerListener) {
// listener is already registered. No need to assign.
return;
}
drawer.setDrawerListener(IdlingDrawerListener.getInstance(existingListener));
}
};
}
use of android.support.v4.widget.DrawerLayout.DrawerListener in project Cangol-uiframe by Cangol.
the class DrawerMenuNavigationFragmentActivityDelegate method onCreate.
@Override
public void onCreate(Bundle savedInstanceState) {
mDrawerMenuLayout = (DrawerMenuLayout) LayoutInflater.from(mActivity).inflate(R.layout.navigation_drawer_main, null);
mDrawerMenuLayout.setDrawerListener(new DrawerListener() {
@Override
public void onDrawerClosed(View view) {
Log.d("onDrawerClosed");
if (mActivity.getCustomFragmentManager().size() <= 1) {
mDrawerMenuLayout.setDrawerLockMode(Gravity.LEFT, DrawerLayout.LOCK_MODE_LOCKED_CLOSED);
mActivity.getCustomActionBar().displayHomeIndicator();
} else {
mDrawerMenuLayout.setDrawerLockMode(Gravity.LEFT, DrawerLayout.LOCK_MODE_UNLOCKED);
mActivity.getCustomActionBar().displayUpIndicator();
}
// 通知menu onClose
mActivity.notifyMenuOnClose();
}
@Override
public void onDrawerOpened(View view) {
Log.d("onDrawerOpened");
// 通知menu onOpen
mActivity.notifyMenuOnOpen();
mActivity.getCustomActionBar().displayUpIndicator();
}
@Override
public void onDrawerSlide(View view, float slideOffset) {
mActivity.getCustomActionBar().displayIndicator(slideOffset);
}
@Override
public void onDrawerStateChanged(int arg0) {
}
});
}
use of android.support.v4.widget.DrawerLayout.DrawerListener in project Lightning-Browser by anthonycr.
the class BrowserActivity method closeDrawers.
/**
* This method closes any open drawer and executes
* the runnable after the drawers are completely closed.
*
* @param runnable an optional runnable to run after
* the drawers are closed.
*/
void closeDrawers(@Nullable final Runnable runnable) {
if (!mDrawerLayout.isDrawerOpen(mDrawerLeft) && !mDrawerLayout.isDrawerOpen(mDrawerRight)) {
if (runnable != null) {
runnable.run();
return;
}
}
mDrawerLayout.closeDrawers();
mDrawerLayout.addDrawerListener(new DrawerListener() {
@Override
public void onDrawerSlide(View drawerView, float slideOffset) {
}
@Override
public void onDrawerOpened(View drawerView) {
}
@Override
public void onDrawerClosed(View drawerView) {
if (runnable != null) {
runnable.run();
}
mDrawerLayout.removeDrawerListener(this);
}
@Override
public void onDrawerStateChanged(int newState) {
}
});
}
Aggregations