Search in sources :

Example 6 with DrawerListener

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));
        }
    };
}
Also used : ViewAction(com.google.android.apps.common.testing.ui.espresso.ViewAction) UiController(com.google.android.apps.common.testing.ui.espresso.UiController) DrawerLayout(android.support.v4.widget.DrawerLayout) Espresso.onView(com.google.android.apps.common.testing.ui.espresso.Espresso.onView) View(android.view.View) DrawerListener(android.support.v4.widget.DrawerLayout.DrawerListener)

Example 7 with DrawerListener

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) {
        }
    });
}
Also used : View(android.view.View) DrawerListener(android.support.v4.widget.DrawerLayout.DrawerListener)

Example 8 with DrawerListener

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) {
        }
    });
}
Also used : ImageView(android.widget.ImageView) BookmarksView(acr.browser.lightning.browser.BookmarksView) BrowserView(acr.browser.lightning.browser.BrowserView) SearchView(acr.browser.lightning.view.SearchView) AutoCompleteTextView(android.widget.AutoCompleteTextView) LightningView(acr.browser.lightning.view.LightningView) BindView(butterknife.BindView) View(android.view.View) AdapterView(android.widget.AdapterView) WebView(android.webkit.WebView) TextView(android.widget.TextView) VideoView(android.widget.VideoView) TabsView(acr.browser.lightning.browser.TabsView) DrawerListener(android.support.v4.widget.DrawerLayout.DrawerListener)

Aggregations

View (android.view.View)7 DrawerListener (android.support.v4.widget.DrawerLayout.DrawerListener)6 TextView (android.widget.TextView)4 ImageView (android.widget.ImageView)3 BookmarksView (acr.browser.lightning.browser.BookmarksView)2 BrowserView (acr.browser.lightning.browser.BrowserView)2 TabsView (acr.browser.lightning.browser.TabsView)2 LightningView (acr.browser.lightning.view.LightningView)2 SearchView (acr.browser.lightning.view.SearchView)2 DrawerLayout (android.support.v4.widget.DrawerLayout)2 WebView (android.webkit.WebView)2 AdapterView (android.widget.AdapterView)2 AutoCompleteTextView (android.widget.AutoCompleteTextView)2 VideoView (android.widget.VideoView)2 BindView (butterknife.BindView)2 BookmarksFragment (acr.browser.lightning.fragment.BookmarksFragment)1 TabsFragment (acr.browser.lightning.fragment.TabsFragment)1 SuppressLint (android.annotation.SuppressLint)1 Intent (android.content.Intent)1 Resources (android.content.res.Resources)1