use of androidx.core.view.ActionProvider in project GreenHouse by utsanjan.
the class ActivityChooserView method showPopupUnchecked.
void showPopupUnchecked(int maxActivityCount) {
if (this.mAdapter.getDataModel() != null) {
getViewTreeObserver().addOnGlobalLayoutListener(this.mOnGlobalLayoutListener);
boolean defaultActivityButtonShown = this.mDefaultActivityButton.getVisibility() == 0;
int activityCount = this.mAdapter.getActivityCount();
int maxActivityCountOffset = defaultActivityButtonShown ? 1 : 0;
if (maxActivityCount == Integer.MAX_VALUE || activityCount <= maxActivityCount + maxActivityCountOffset) {
this.mAdapter.setShowFooterView(false);
this.mAdapter.setMaxActivityCount(maxActivityCount);
} else {
this.mAdapter.setShowFooterView(true);
this.mAdapter.setMaxActivityCount(maxActivityCount - 1);
}
ListPopupWindow popupWindow = getListPopupWindow();
if (!popupWindow.isShowing()) {
if (this.mIsSelectingDefaultActivity || !defaultActivityButtonShown) {
this.mAdapter.setShowDefaultActivity(true, defaultActivityButtonShown);
} else {
this.mAdapter.setShowDefaultActivity(false, false);
}
int contentWidth = Math.min(this.mAdapter.measureContentWidth(), this.mListPopupMaxWidth);
popupWindow.setContentWidth(contentWidth);
popupWindow.show();
ActionProvider actionProvider = this.mProvider;
if (actionProvider != null) {
actionProvider.subUiVisibilityChanged(true);
}
popupWindow.getListView().setContentDescription(getContext().getString(R.string.abc_activitychooserview_choose_application));
popupWindow.getListView().setSelector(new ColorDrawable(0));
return;
}
return;
}
throw new IllegalStateException("No data model. Did you call #setDataModel?");
}
use of androidx.core.view.ActionProvider in project GreenHouse by utsanjan.
the class MenuItemImpl method invoke.
public boolean invoke() {
MenuItem.OnMenuItemClickListener onMenuItemClickListener = this.mClickListener;
if (onMenuItemClickListener != null && onMenuItemClickListener.onMenuItemClick(this)) {
return true;
}
MenuBuilder menuBuilder = this.mMenu;
if (menuBuilder.dispatchMenuItemSelected(menuBuilder, this)) {
return true;
}
Runnable runnable = this.mItemCallback;
if (runnable != null) {
runnable.run();
return true;
}
if (this.mIntent != null) {
try {
this.mMenu.getContext().startActivity(this.mIntent);
return true;
} catch (ActivityNotFoundException e) {
Log.e(TAG, "Can't find activity to handle intent; ignoring", e);
}
}
ActionProvider actionProvider = this.mActionProvider;
return actionProvider != null && actionProvider.onPerformDefaultAction();
}
use of androidx.core.view.ActionProvider in project sesl-appcompat by OneUIProject.
the class ActionMenuPresenter method updateMenuView.
@Override
public void updateMenuView(boolean cleared) {
super.updateMenuView(cleared);
if (mMenuView != null) {
((View) mMenuView).requestLayout();
}
if (mMenu != null) {
final ArrayList<MenuItemImpl> actionItems = mMenu.getActionItems();
final int count = actionItems.size();
for (int i = 0; i < count; i++) {
final ActionProvider provider = actionItems.get(i).getSupportActionProvider();
if (provider != null) {
provider.setSubUiVisibilityListener(this);
}
}
}
final ArrayList<MenuItemImpl> nonActionItems = mMenu != null ? mMenu.getNonActionItems() : null;
boolean hasOverflow = false;
if (mReserveOverflow && nonActionItems != null) {
final int count = nonActionItems.size();
if (count == 1) {
hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
} else {
hasOverflow = count > 0;
}
}
if (hasOverflow) {
if (mOverflowButton == null) {
mOverflowButton = new OverflowMenuButton(mSystemContext);
mOverflowButton.setId(R.id.sesl_action_bar_overflow_button);
}
ViewGroup parent = (ViewGroup) mOverflowButton.getParent();
if (parent != mMenuView) {
if (parent != null) {
parent.removeView(mOverflowButton);
}
ActionMenuView menuView = (ActionMenuView) mMenuView;
if (menuView != null) {
menuView.addView(mOverflowButton, menuView.generateOverflowButtonLayoutParams());
}
}
} else if (mOverflowButton != null && mOverflowButton.getParent() == mMenuView) {
if (mMenuView != null) {
((ViewGroup) mMenuView).removeView(mOverflowButton);
}
if (isOverflowMenuShowing()) {
hideOverflowMenu();
}
}
if (mOverflowButton != null && mMenuView != null) {
mOverflowButton.setBadgeText(((ActionMenuView) mMenuView).getOverflowBadgeText(), ((ActionMenuView) mMenuView).getSumOfDigitsInBadges());
}
if ((mOverflowButton == null || mOverflowButton.getVisibility() != View.GONE) && isOverflowMenuShowing()) {
hideOverflowMenu();
}
if (mMenuView != null) {
((ActionMenuView) mMenuView).setOverflowReserved(mReserveOverflow);
}
}
use of androidx.core.view.ActionProvider in project GreenHouse by utsanjan.
the class ActionMenuPresenter method updateMenuView.
// androidx.appcompat.view.menu.BaseMenuPresenter, androidx.appcompat.view.menu.MenuPresenter
@Override
public void updateMenuView(boolean cleared) {
super.updateMenuView(cleared);
((View) this.mMenuView).requestLayout();
if (this.mMenu != null) {
ArrayList<MenuItemImpl> actionItems = this.mMenu.getActionItems();
int count = actionItems.size();
for (int i = 0; i < count; i++) {
ActionProvider provider = actionItems.get(i).getSupportActionProvider();
if (provider != null) {
provider.setSubUiVisibilityListener(this);
}
}
}
ArrayList<MenuItemImpl> nonActionItems = this.mMenu != null ? this.mMenu.getNonActionItems() : null;
boolean hasOverflow = false;
if (this.mReserveOverflow && nonActionItems != null) {
int count2 = nonActionItems.size();
hasOverflow = false;
if (count2 == 1) {
hasOverflow = !nonActionItems.get(0).isActionViewExpanded();
} else if (count2 > 0) {
hasOverflow = true;
}
}
if (hasOverflow) {
if (this.mOverflowButton == null) {
this.mOverflowButton = new OverflowMenuButton(this.mSystemContext);
}
ViewGroup parent = (ViewGroup) this.mOverflowButton.getParent();
if (parent != this.mMenuView) {
if (parent != null) {
parent.removeView(this.mOverflowButton);
}
ActionMenuView menuView = (ActionMenuView) this.mMenuView;
menuView.addView(this.mOverflowButton, menuView.generateOverflowButtonLayoutParams());
}
} else {
OverflowMenuButton overflowMenuButton = this.mOverflowButton;
if (overflowMenuButton != null && overflowMenuButton.getParent() == this.mMenuView) {
((ViewGroup) this.mMenuView).removeView(this.mOverflowButton);
}
}
((ActionMenuView) this.mMenuView).setOverflowReserved(this.mReserveOverflow);
}
use of androidx.core.view.ActionProvider in project GreenHouse by utsanjan.
the class MenuBuilder method performItemAction.
public boolean performItemAction(MenuItem item, MenuPresenter preferredPresenter, int flags) {
MenuItemImpl itemImpl = (MenuItemImpl) item;
if (itemImpl == null || !itemImpl.isEnabled()) {
return false;
}
boolean invoked = itemImpl.invoke();
ActionProvider provider = itemImpl.getSupportActionProvider();
boolean providerHasSubMenu = provider != null && provider.hasSubMenu();
if (itemImpl.hasCollapsibleActionView()) {
invoked |= itemImpl.expandActionView();
if (invoked) {
close(true);
}
} else if (itemImpl.hasSubMenu() || providerHasSubMenu) {
if ((flags & 4) == 0) {
close(false);
}
if (!itemImpl.hasSubMenu()) {
itemImpl.setSubMenu(new SubMenuBuilder(getContext(), this, itemImpl));
}
SubMenuBuilder subMenu = (SubMenuBuilder) itemImpl.getSubMenu();
if (providerHasSubMenu) {
provider.onPrepareSubMenu(subMenu);
}
invoked |= dispatchSubMenuSelected(subMenu, preferredPresenter);
if (!invoked) {
close(true);
}
} else if ((flags & 1) == 0) {
close(true);
}
return invoked;
}
Aggregations