android.support.v7.view.menu.ActionMenuItemView Java Examples

The following examples show how to use android.support.v7.view.menu.ActionMenuItemView. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TransitionUtil.java    From android-transition with Apache License 2.0 6 votes vote down vote up
/**
 * Get the list of visible MenuItems
 *
 * @param toolbar
 * @return the list of visible MenuItems
 */
public static List<MenuItem> getVisibleMenuItemList(@NonNull Toolbar toolbar) {
    List<MenuItem> list = new ArrayList<>();
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        final View v = toolbar.getChildAt(i);
        if (v instanceof ActionMenuView) {
            int childCount = ((ActionMenuView) v).getChildCount();
            for (int j = 0; j < childCount; j++) {
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    list.add(((ActionMenuItemView) innerView).getItemData());
                }
            }
        }
    }
    return list;
}
 
Example #2
Source File: TransitionUtil.java    From android-transition with Apache License 2.0 6 votes vote down vote up
/**
 * Search for a particular menu
 *
 * @param toolbar
 * @param menuId
 * @return the corresponding MenuItem, or null if not found
 */
public static MenuItem getMenuItem(@NonNull Toolbar toolbar, @IdRes int menuId) {
    View v;
    int childCount;
    View innerView;
    MenuItem menuItem;
    for (int i = 0; i < toolbar.getChildCount(); i++) {
        v = toolbar.getChildAt(i);
        if (v instanceof ActionMenuView) {
            childCount = ((ActionMenuView) v).getChildCount();
            for (int j = 0; j < childCount; j++) {
                innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    menuItem = ((ActionMenuItemView) innerView).getItemData();
                    if (menuItem.getItemId() == menuId) {
                        return menuItem;
                    }
                }
            }
        }
    }
    return null;
}
 
Example #3
Source File: FragmentPlayer.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    View view = inflater.inflate(R.layout.fragment_player, container, false);
    btnPlay = (PlayPauseView) view.findViewById(R.id.btnPlay);
    btnRewindLeft = (ImageButton) view.findViewById(R.id.btnRewindLeft);
    btnRewindRight = (ImageButton) view.findViewById(R.id.btnRewindRight);
    btnPlay.setOnClickListener(btnPlayStopClickListener);
    btnRewindLeft.setOnClickListener(btnBackwardClickListener);
    btnRewindRight.setOnClickListener(btnForwardClickListener);
    rlTopSectionBckg = (RelativeLayout) view.findViewById(R.id.rlTopSectionBckg);
    imgPlayerCover = (ImageView) view.findViewById(R.id.imgPlayerCover);
    tvPlayerTitle = (TextView) view.findViewById(R.id.tvPlayerTitle);
    tvPlayserSubtitle = (TextView) view.findViewById(R.id.tvPlayserSubtitle);
    tvTrackInfo = (TextView) view.findViewById(R.id.tvTrackInfo);
    tvTrackDuration = (TextView) view.findViewById(R.id.tvTrackDuration);
    tvTrackCurrentTime = (TextView) view.findViewById(R.id.tvTrackCurrentTime);
    tvTrackNumbers = (TextView) view.findViewById(R.id.tvTrackNumbers);
    lnPlayerinfo = (LinearLayout) view.findViewById(R.id.lnPlayerInfo);
    sbPlayerProgress = (SeekBar) view.findViewById(R.id.sbPlayerProgress);
    itemFavorites = (ActionMenuItemView) ((IToolbarHolder) getActivity()).getToolbar().findViewById(R.id.action_favorites_player);
    universalPlayer = UniversalPlayer.getInstance();

    ((IToolbarHolder) getActivity()).getToolbar().setTitle(R.string.buffering);
    TextView toolbarTitle = UIHelper.getToolbarTextView(((IToolbarHolder) getActivity()).getToolbar());
    toolbarTitle.setTextSize(TOOLBAR_TEXT_SIZE);
    toolbarTitle.setTypeface(null, Typeface.NORMAL);

    if (playableMediaItem == null) {
        playableMediaItem = UniversalPlayer.getInstance().getPlayingMediaItem();
    }

    askPhoneStatePermissions();
    return view;
}
 
Example #4
Source File: ActivityPlayer.java    From uPods-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);

    toolbar = (Toolbar) findViewById(R.id.toolbar_player);
    toolbar.setTitleTextColor(getResources().getColor(R.color.white));
    toolbar.inflateMenu(R.menu.menu_activity_player);
    toolbar.setOnMenuItemClickListener(this);
    toolbar.setVisibility(View.VISIBLE);
    itemFavorites = (ActionMenuItemView) toolbar.findViewById(R.id.action_favorites_player);

    currentMediaItem = UniversalPlayer.getInstance().getPlayingMediaItem();
    if (currentMediaItem == null) {
        Toast.makeText(this, getString(R.string.error_cant_play), Toast.LENGTH_SHORT).show();
        onBackPressed();
        return;
    }

    if (getFragmentManager().getBackStackEntryCount() == 0) {
        if (currentMediaItem instanceof Podcast && MediaUtils.isVideoUrl(currentMediaItem.getAudeoLink())) {
            setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
            FragmentVideoPlayer fragmentVideoPlayer = new FragmentVideoPlayer();
            fragmentVideoPlayer.setOnPlayingFailedCallback(MediaUtils.getPlayerFailCallback(this, currentMediaItem));
            showFragment(R.id.fl_window, fragmentVideoPlayer, FragmentVideoPlayer.TAG);
        } else {
            fragmentPlayer = new FragmentPlayer();
            fragmentPlayer.setPlayableItem(currentMediaItem);
            showFragment(R.id.fl_window, fragmentPlayer, FragmentMainFeatured.TAG);
        }
    }
}
 
Example #5
Source File: ToolbarColorizeHelper.java    From IdeaTrackerPlus with MIT License 4 votes vote down vote up
/**
 * Use this method to colorize toolbar icons to the desired target color
 *
 * @param toolbarView       toolbar view being colored
 * @param toolbarIconsColor the target color of toolbar icons
 * @param activity          reference to activity needed to register observers
 */
public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor, Activity activity) {
    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, PorterDuff.Mode.MULTIPLY);

    for (int i = 0; i < toolbarView.getChildCount(); i++) {
        final View v = toolbarView.getChildAt(i);

        //Step 1 : Changing the color of back button (or open drawer button).
        if (v instanceof ImageButton) {
            //Action Bar back button
            ((ImageButton) v).getDrawable().setColorFilter(colorFilter);
        }


        if (v instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {

                //Step 2: Changing the color of any ActionMenuViews - icons that are not back button, nor text, nor overflow menu icon.
                //Colorize the ActionViews -> all icons that are NOT: back button | overflow menu
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    for (int k = 0; k < ((ActionMenuItemView) innerView).getCompoundDrawables().length; k++) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            final int finalK = k;

                            //Important to set the color filter in seperate thread, by adding it to the message queue
                            //Won't work otherwise.
                            innerView.post(new Runnable() {
                                @Override
                                public void run() {
                                    ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                                }
                            });
                        }
                    }
                }
            }
        }

        //Step 3: Changing the color of title and subtitle.
        toolbarView.setTitleTextColor(toolbarIconsColor);
        toolbarView.setSubtitleTextColor(toolbarIconsColor);

        //Step 4: Changing the color of the Overflow Menu icon.
        setOverflowButtonColor(activity, colorFilter);
    }
}
 
Example #6
Source File: ToolbarColorizeHelper.java    From RetroMusicPlayer with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Use this method to colorize toolbar icons to the desired target color
 *
 * @param toolbarView       toolbar view being colored
 * @param toolbarIconsColor the target color of toolbar icons
 * @param activity          reference to activity needed to register observers
 */
public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor, Activity activity) {
    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, PorterDuff.Mode.MULTIPLY);

    for (int i = 0; i < toolbarView.getChildCount(); i++) {
        final View v = toolbarView.getChildAt(i);

        //Step 1 : Changing the color of back button (or open drawer button).
        if (v instanceof ImageButton) {
            //Action Bar back button
            ((ImageButton) v).getDrawable().setColorFilter(colorFilter);
        }


        if (v instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {

                //Step 2: Changing the color of any ActionMenuViews - icons that are not back button, nor text, nor overflow menu icon.
                //Colorize the ActionViews -> all icons that are NOT: back button | overflow menu
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    for (int k = 0; k < ((ActionMenuItemView) innerView).getCompoundDrawables().length; k++) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            final int finalK = k;

                            //Important to set the color filter in seperate thread, by adding it to the message queue
                            //Won't work otherwise.
                            innerView.post(new Runnable() {
                                @Override
                                public void run() {
                                    ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                                }
                            });
                        }
                    }
                }
            }
        }

        //Step 3: Changing the color of title and subtitle.
        toolbarView.setTitleTextColor(toolbarIconsColor);
        toolbarView.setSubtitleTextColor(toolbarIconsColor);

        //Step 4: Changing the color of the Overflow Menu icon.
        setOverflowButtonColor(activity, colorFilter);
    }
}
 
Example #7
Source File: ActorToolbar.java    From actor-platform with GNU Affero General Public License v3.0 4 votes vote down vote up
public static void doColorizing(View v, final ColorFilter colorFilter, int toolbarIconsColor) {
        if (v instanceof ImageButton) {
            ((ImageButton) v).getDrawable().setAlpha(255);
            ((ImageButton) v).getDrawable().setColorFilter(colorFilter);
        }

        if (v instanceof ImageView && !(v instanceof AvatarView)) {
            ((ImageView) v).getDrawable().setAlpha(255);
            ((ImageView) v).getDrawable().setColorFilter(colorFilter);
        }

        if (v instanceof AutoCompleteTextView) {
            ((AutoCompleteTextView) v).setTextColor(toolbarIconsColor);
        }

        if (v instanceof TextView) {
            ((TextView) v).setTextColor(toolbarIconsColor);
        }

        if (v instanceof EditText) {
            ((EditText) v).setTextColor(toolbarIconsColor);
        }

        if (v instanceof ViewGroup) {
            for (int lli = 0; lli < ((ViewGroup) v).getChildCount(); lli++) {
                doColorizing(((ViewGroup) v).getChildAt(lli), colorFilter, toolbarIconsColor);
            }
        }

        if (v instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {

                //Step 2: Changing the color of any ActionMenuViews - icons that
                //are not back button, nor text, nor overflow menu icon.
                final View innerView = ((ActionMenuView) v).getChildAt(j);

                if (innerView instanceof ActionMenuItemView) {
                    int drawablesCount = ((ActionMenuItemView) innerView).getCompoundDrawables().length;
                    for (int k = 0; k < drawablesCount; k++) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            final int finalK = k;

                            //Important to set the color filter in seperate thread,
                            //by adding it to the message queue
                            //Won't work otherwise.
                            //Works fine for my case but needs more testing

                            ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);

//                              innerView.post(new Runnable() {
//                                  @Override
//                                  public void run() {
//                                      ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
//                                  }
//                              });
                        }
                    }
                }
            }
        }
    }
 
Example #8
Source File: AppCompatv7DSL.java    From anvil with MIT License 4 votes vote down vote up
public static BaseDSL.ViewClassResult actionMenuItemView() {
  return BaseDSL.v(ActionMenuItemView.class);
}
 
Example #9
Source File: AppCompatv7DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void actionMenuItemView(Anvil.Renderable r) {
  return BaseDSL.v(ActionMenuItemView.class, r);
}
 
Example #10
Source File: AppCompatv7DSL.java    From anvil with MIT License 4 votes vote down vote up
public static Void popupCallback(ActionMenuItemView.PopupCallback arg) {
  return BaseDSL.attr("popupCallback", arg);
}
 
Example #11
Source File: ToolbarColorizeHelper.java    From Slide with GNU General Public License v3.0 4 votes vote down vote up
/**
 * Use this method to colorize toolbar icons to the desired target color
 *
 * @param toolbarView       toolbar view being colored
 * @param toolbarIconsColor the target color of toolbar icons
 * @param activity          reference to activity needed to register observers
 */
public static void colorizeToolbar(Toolbar toolbarView, int toolbarIconsColor, Activity activity) {
    final PorterDuffColorFilter colorFilter = new PorterDuffColorFilter(toolbarIconsColor, PorterDuff.Mode.MULTIPLY);

    for (int i = 0; i < toolbarView.getChildCount(); i++) {
        final View v = toolbarView.getChildAt(i);

        //Step 1 : Changing the color of back button (or open drawer button).
        if (v instanceof ImageButton) {
            //Action Bar back button
            ((ImageButton) v).getDrawable().setColorFilter(colorFilter);
        }


        if (v instanceof ActionMenuView) {
            for (int j = 0; j < ((ActionMenuView) v).getChildCount(); j++) {

                //Step 2: Changing the color of any ActionMenuViews - icons that are not back button, nor text, nor overflow menu icon.
                //Colorize the ActionViews -> all icons that are NOT: back button | overflow menu
                final View innerView = ((ActionMenuView) v).getChildAt(j);
                if (innerView instanceof ActionMenuItemView) {
                    for (int k = 0; k < ((ActionMenuItemView) innerView).getCompoundDrawables().length; k++) {
                        if (((ActionMenuItemView) innerView).getCompoundDrawables()[k] != null) {
                            final int finalK = k;

                            //Important to set the color filter in seperate thread, by adding it to the message queue
                            //Won't work otherwise.
                            innerView.post(new Runnable() {
                                @Override
                                public void run() {
                                    ((ActionMenuItemView) innerView).getCompoundDrawables()[finalK].setColorFilter(colorFilter);
                                }
                            });
                        }
                    }
                }
            }
        }

        //Step 3: Changing the color of title and subtitle.
        toolbarView.setTitleTextColor(toolbarIconsColor);
        toolbarView.setSubtitleTextColor(toolbarIconsColor);

        //Step 4: Changing the color of the Overflow Menu icon.
        setOverflowButtonColor(activity, colorFilter);
    }
}