Search in sources :

Example 1 with MenuView

use of android.support.v7.internal.view.menu.MenuView in project HoloEverywhere by Prototik.

the class ActionBarView method setMenu.

public void setMenu(SupportMenu menu, MenuPresenter.Callback cb) {
    if (menu == mOptionsMenu) {
        return;
    }
    if (mOptionsMenu != null) {
        mOptionsMenu.removeMenuPresenter(mActionMenuPresenter);
        mOptionsMenu.removeMenuPresenter(mExpandedMenuPresenter);
    }
    MenuBuilder builder = (MenuBuilder) menu;
    mOptionsMenu = builder;
    if (mMenuView != null) {
        final ViewGroup oldParent = (ViewGroup) mMenuView.getParent();
        if (oldParent != null) {
            oldParent.removeView(mMenuView);
        }
    }
    if (mActionMenuPresenter == null) {
        mActionMenuPresenter = new ActionMenuPresenter(mContext);
        mActionMenuPresenter.setCallback(cb);
        mActionMenuPresenter.setId(R.id.action_menu_presenter);
        mExpandedMenuPresenter = new ExpandedActionViewMenuPresenter();
    }
    ActionMenuView menuView;
    final LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.FILL_PARENT);
    if (!mSplitActionBar) {
        mActionMenuPresenter.setExpandedActionViewsExclusive(getResources().getBoolean(R.bool.abc_action_bar_expanded_action_views_exclusive));
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        final ViewGroup oldParent = (ViewGroup) menuView.getParent();
        if (oldParent != null && oldParent != this) {
            oldParent.removeView(menuView);
        }
        addView(menuView, layoutParams);
    } else {
        mActionMenuPresenter.setExpandedActionViewsExclusive(false);
        // Allow full screen width in split mode.
        mActionMenuPresenter.setWidthLimit(getContext().getResources().getDisplayMetrics().widthPixels, true);
        // No limit to the item count; use whatever will fit.
        mActionMenuPresenter.setItemLimit(Integer.MAX_VALUE);
        // Span the whole width
        layoutParams.width = LayoutParams.FILL_PARENT;
        configPresenters(builder);
        menuView = (ActionMenuView) mActionMenuPresenter.getMenuView(this);
        if (mSplitView != null) {
            final ViewGroup oldParent = (ViewGroup) menuView.getParent();
            if (oldParent != null && oldParent != mSplitView) {
                oldParent.removeView(menuView);
            }
            menuView.setVisibility(getAnimatedVisibility());
            mSplitView.addView(menuView, layoutParams);
        } else {
            // We'll add this later if we missed it this time.
            menuView.setLayoutParams(layoutParams);
        }
    }
    mMenuView = menuView;
}
Also used : ViewGroup(android.view.ViewGroup) ActionMenuView(android.support.v7.internal.view.menu.ActionMenuView) MenuBuilder(android.support.v7.internal.view.menu.MenuBuilder) SubMenuBuilder(android.support.v7.internal.view.menu.SubMenuBuilder) ActionMenuPresenter(android.support.v7.internal.view.menu.ActionMenuPresenter)

Example 2 with MenuView

use of android.support.v7.internal.view.menu.MenuView in project material by rey5137.

the class ToolbarManager method animateOut.

private void animateOut() {
    ActionMenuView menuView = getMenuView();
    int count = menuView == null ? 0 : menuView.getChildCount();
    Animation slowestAnimation = null;
    mAnimations.clear();
    mAnimations.ensureCapacity(count);
    for (int i = 0; i < count; i++) {
        View child = menuView.getChildAt(i);
        Animation anim = mAnimator.getOutAnimation(child, i);
        mAnimations.add(anim);
        if (anim != null)
            if (slowestAnimation == null || slowestAnimation.getStartOffset() + slowestAnimation.getDuration() < anim.getStartOffset() + anim.getDuration())
                slowestAnimation = anim;
    }
    if (slowestAnimation == null)
        mOutAnimationEndListener.onAnimationEnd(null);
    else {
        slowestAnimation.setAnimationListener(mOutAnimationEndListener);
        for (int i = 0; i < count; i++) {
            Animation anim = mAnimations.get(i);
            if (anim != null)
                menuView.getChildAt(i).startAnimation(anim);
        }
    }
    mAnimations.clear();
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ActionMenuView(android.support.v7.widget.ActionMenuView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView)

Example 3 with MenuView

use of android.support.v7.internal.view.menu.MenuView in project WordPress-Android by wordpress-mobile.

the class MediaBrowserActivity method setupAddMenuPopup.

/** Setup the popup that allows you to add new media from camera, video camera or local files **/
private void setupAddMenuPopup() {
    String capturePhoto = getString(R.string.media_add_popup_capture_photo);
    String captureVideo = getString(R.string.media_add_popup_capture_video);
    String pickPhotoFromGallery = getString(R.string.select_photo);
    String pickVideoFromGallery = getString(R.string.select_video);
    String[] items = new String[] { capturePhoto, captureVideo, pickPhotoFromGallery, pickVideoFromGallery };
    @SuppressLint("InflateParams") View menuView = getLayoutInflater().inflate(R.layout.actionbar_add_media, null, false);
    final ArrayAdapter<String> adapter = new ArrayAdapter<>(this, R.layout.actionbar_add_media_cell, items);
    ListView listView = (ListView) menuView.findViewById(R.id.actionbar_add_media_listview);
    listView.setAdapter(adapter);
    listView.setOnItemClickListener(new OnItemClickListener() {

        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            adapter.notifyDataSetChanged();
            if (position == 0) {
                MediaBrowserActivity enclosingActivity = MediaBrowserActivity.this;
                WordPressMediaUtils.launchCamera(enclosingActivity, BuildConfig.APPLICATION_ID, enclosingActivity);
            } else if (position == 1) {
                WordPressMediaUtils.launchVideoCamera(MediaBrowserActivity.this);
            } else if (position == 2) {
                WordPressMediaUtils.launchPictureLibrary(MediaBrowserActivity.this);
            } else if (position == 3) {
                WordPressMediaUtils.launchVideoLibrary(MediaBrowserActivity.this);
            }
            mAddMediaPopup.dismiss();
        }
    });
    int width = getResources().getDimensionPixelSize(R.dimen.action_bar_spinner_width);
    mAddMediaPopup = new PopupWindow(menuView, width, ViewGroup.LayoutParams.WRAP_CONTENT, true);
    mAddMediaPopup.setBackgroundDrawable(new ColorDrawable());
}
Also used : OnItemClickListener(android.widget.AdapterView.OnItemClickListener) PopupWindow(android.widget.PopupWindow) SearchView(android.support.v7.widget.SearchView) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) SuppressLint(android.annotation.SuppressLint) ListView(android.widget.ListView) ColorDrawable(android.graphics.drawable.ColorDrawable) SuppressLint(android.annotation.SuppressLint) ArrayAdapter(android.widget.ArrayAdapter)

Example 4 with MenuView

use of android.support.v7.internal.view.menu.MenuView in project HoloEverywhere by Prototik.

the class ActionBarActivityDelegateBase method getListMenuView.

private MenuView getListMenuView(Context context, MenuPresenter.Callback cb) {
    if (mMenu == null) {
        return null;
    }
    if (mListMenuPresenter == null) {
        TypedArray a = context.obtainStyledAttributes(R.styleable.Theme);
        final int listPresenterTheme = a.getResourceId(R.styleable.Theme_panelMenuListTheme, R.style.Theme_AppCompat_CompactMenu);
        a.recycle();
        mListMenuPresenter = new ListMenuPresenter(R.layout.abc_list_menu_item_layout, listPresenterTheme);
        mListMenuPresenter.setCallback(cb);
        mMenu.addMenuPresenter(mListMenuPresenter);
    } else {
        // Make sure we update the ListView
        mListMenuPresenter.updateMenuView(false);
    }
    return mListMenuPresenter.getMenuView(new FrameLayout(context));
}
Also used : TypedArray(android.content.res.TypedArray) FrameLayout(org.holoeverywhere.widget.FrameLayout) ListMenuPresenter(android.support.v7.internal.view.menu.ListMenuPresenter)

Example 5 with MenuView

use of android.support.v7.internal.view.menu.MenuView in project material by rey5137.

the class ToolbarManager method animateIn.

private void animateIn() {
    ActionMenuView menuView = getMenuView();
    for (int i = 0, count = menuView == null ? 0 : menuView.getChildCount(); i < count; i++) {
        View child = menuView.getChildAt(i);
        Animation anim = mAnimator.getInAnimation(child, i);
        if (anim != null)
            child.startAnimation(anim);
    }
}
Also used : TranslateAnimation(android.view.animation.TranslateAnimation) Animation(android.view.animation.Animation) ActionMenuView(android.support.v7.widget.ActionMenuView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView)

Aggregations

View (android.view.View)4 ActionMenuView (android.support.v7.widget.ActionMenuView)3 Animation (android.view.animation.Animation)2 TranslateAnimation (android.view.animation.TranslateAnimation)2 SuppressLint (android.annotation.SuppressLint)1 TypedArray (android.content.res.TypedArray)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 ActionMenuPresenter (android.support.v7.internal.view.menu.ActionMenuPresenter)1 ActionMenuView (android.support.v7.internal.view.menu.ActionMenuView)1 ListMenuPresenter (android.support.v7.internal.view.menu.ListMenuPresenter)1 MenuBuilder (android.support.v7.internal.view.menu.MenuBuilder)1 SubMenuBuilder (android.support.v7.internal.view.menu.SubMenuBuilder)1 SearchView (android.support.v7.widget.SearchView)1 ViewGroup (android.view.ViewGroup)1 AdapterView (android.widget.AdapterView)1 OnItemClickListener (android.widget.AdapterView.OnItemClickListener)1 ArrayAdapter (android.widget.ArrayAdapter)1 ListView (android.widget.ListView)1 PopupWindow (android.widget.PopupWindow)1 ToolbarRippleDrawable (com.rey.material.drawable.ToolbarRippleDrawable)1