Search in sources :

Example 1 with MenuView

use of android.support.v7.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 2 with MenuView

use of android.support.v7.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.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 4 with MenuView

use of android.support.v7.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)

Example 5 with MenuView

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

the class ToolbarManager method onGlobalLayout.

private void onGlobalLayout() {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN)
        mToolbar.getViewTreeObserver().removeOnGlobalLayoutListener(mOnGlobalLayoutListener);
    else
        mToolbar.getViewTreeObserver().removeGlobalOnLayoutListener(mOnGlobalLayoutListener);
    ActionMenuView menuView = getMenuView();
    for (int i = 0, count = menuView == null ? 0 : menuView.getChildCount(); i < count; i++) {
        View child = menuView.getChildAt(i);
        if (mRippleStyle != 0) {
            if (child.getBackground() == null || !(child.getBackground() instanceof ToolbarRippleDrawable))
                ViewUtil.setBackground(child, getBackground());
        }
    }
    if (mGroupChanged) {
        animateIn();
        mGroupChanged = false;
    }
}
Also used : ToolbarRippleDrawable(com.rey.material.drawable.ToolbarRippleDrawable) ActionMenuView(android.support.v7.widget.ActionMenuView) View(android.view.View) ActionMenuView(android.support.v7.widget.ActionMenuView)

Aggregations

View (android.view.View)5 ActionMenuView (android.support.v7.widget.ActionMenuView)4 SuppressLint (android.annotation.SuppressLint)2 Intent (android.content.Intent)2 GridLayoutManager (android.support.v7.widget.GridLayoutManager)2 LinearLayoutManager (android.support.v7.widget.LinearLayoutManager)2 SearchView (android.support.v7.widget.SearchView)2 Toolbar (android.support.v7.widget.Toolbar)2 Animation (android.view.animation.Animation)2 TranslateAnimation (android.view.animation.TranslateAnimation)2 AdapterView (android.widget.AdapterView)2 SimpleDateFormat (java.text.SimpleDateFormat)2 PendingIntent (android.app.PendingIntent)1 SearchManager (android.app.SearchManager)1 TypedArray (android.content.res.TypedArray)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 BottomSheetDialog (android.support.design.widget.BottomSheetDialog)1 TabLayout (android.support.design.widget.TabLayout)1 ActionMenuPresenter (android.support.v7.internal.view.menu.ActionMenuPresenter)1 ActionMenuView (android.support.v7.internal.view.menu.ActionMenuView)1