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());
}
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();
}
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;
}
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);
}
}
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;
}
}
Aggregations