android.view.MenuItem.isVisible()方法的使用及代码示例

x33g5p2x  于2022-01-24 转载在 其他  
字(10.4k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中android.view.MenuItem.isVisible()方法的一些代码示例,展示了MenuItem.isVisible()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MenuItem.isVisible()方法的具体详情如下:
包路径:android.view.MenuItem
类名称:MenuItem
方法名:isVisible

暂无

代码示例

代码示例来源:origin: square/assertj-android

public MenuItemAssert isVisible() {
 isNotNull();
 assertThat(actual.isVisible()) //
   .overridingErrorMessage("Expected to be visible but was not visible.") //
   .isTrue();
 return this;
}

代码示例来源:origin: square/assertj-android

public MenuItemAssert isNotVisible() {
  isNotNull();
  assertThat(actual.isVisible()) //
    .overridingErrorMessage("Expected to not be visible but was visible.") //
    .isFalse();
  return this;
 }
}

代码示例来源:origin: k9mail/k-9

@Override
public void enableActionBarProgress(boolean enable) {
  if (menuButtonCheckMail == null) {
    return;
  }
  if (menuButtonCheckMail.isVisible()) {
    menuButtonCheckMail.setActionView(enable ? actionButtonIndeterminateProgress : null);
  } else {
    menuButtonCheckMail.setActionView(null);
  }
}

代码示例来源:origin: robolectric/robolectric

@Test
public void shouldAllowSettingVisible() throws Exception {
 assertThat(item.isVisible()).isTrue();
 item.setVisible(false);
 assertThat(item.isVisible()).isFalse();
}

代码示例来源:origin: wangdan/AisenWeiBo

origItem.setVisible(false);
if (origItem.isVisible()) {
  if (downloadMsg != null && !downloadMsg.isNull()) {
    long total = downloadMsg.getTotal() == 0 ? 1 : downloadMsg.getTotal();

代码示例来源:origin: Flipboard/bottomsheet

if (item.isVisible()) {
  if (item.hasSubMenu()) {
        if (subMenuItem.isVisible()) {
          items.add(SheetMenuItem.of(subMenuItem));

代码示例来源:origin: hidroh/materialistic

@Test
public void testFilter() {
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_search).isVisible());
  Intent intent = new Intent();
  intent.putExtra(SearchManager.QUERY, "blah");
  controller.newIntent(intent);
  verify(favoriteManager).attach(any(LocalItemManager.Observer.class), eq("blah"));
  intent = new Intent();
  intent.putExtra(SearchManager.QUERY, "ask");
  controller.newIntent(intent);
  verify(favoriteManager).attach(any(LocalItemManager.Observer.class), eq("ask"));
}

代码示例来源:origin: ZieIony/Carbon

public static Menu getMenu(Context context, android.view.Menu baseMenu) {
  Context contextWrapper = CarbonContextWrapper.wrap(context);
  Menu menu = new Menu(contextWrapper);
  for (int i = 0; i < baseMenu.size(); i++) {
    android.view.MenuItem menuItem = baseMenu.getItem(i);
    menu.add(menuItem.getGroupId(), menuItem.getItemId(), menuItem.getOrder(), menuItem.getTitle()).setIcon(menuItem.getIcon()).setVisible(menuItem.isVisible()).setEnabled(menuItem.isEnabled());
  }
  return menu;
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testCreateLand() {
  assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_share));
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_share).isVisible());
  assertNotNull(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_external));
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_external).isVisible());
  assertFalse(((ShadowFloatingActionButton) Shadow.extract(activity.findViewById(R.id.reply_button))).isVisible());
}

代码示例来源:origin: hidroh/materialistic

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Test
public void testVoteItem() {
  verify(itemManager).getItem(any(), eq(ItemManager.MODE_DEFAULT), itemListener.capture());
  itemListener.getValue().onResponse(item);
  adapter.getViewHolder(0).itemView.performLongClick();
  PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
  assertNotNull(popupMenu);
  assertThat(popupMenu.getMenu().findItem(R.id.menu_contextual_vote).isVisible()).isFalse();
  shadowOf(popupMenu).getOnMenuItemClickListener()
      .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_vote));
  verify(userServices).voteUp(any(Context.class), eq(item.getId()), voteCallback.capture());
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testOptionsMenuClear() {
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_clear).isVisible());
  shadowOf(activity).clickMenuItem(R.id.menu_clear);
  AlertDialog dialog = ShadowAlertDialog.getLatestAlertDialog();
  dialog.getButton(DialogInterface.BUTTON_NEGATIVE).performClick();
  assertEquals(2, adapter.getItemCount());
  shadowOf(activity).clickMenuItem(R.id.menu_clear);
  dialog = ShadowAlertDialog.getLatestAlertDialog();
  dialog.getButton(DialogInterface.BUTTON_POSITIVE).performClick();
  verify(favoriteManager).clear(any(Context.class), any());
  when(favoriteManager.getSize()).thenReturn(0);
  observerCaptor.getValue().onChanged();
  assertEquals(0, adapter.getItemCount());
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testSendFailed() {
  doSend();
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_send).isEnabled());
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_quote).isVisible());
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_save_draft).isEnabled());
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_discard_draft).isEnabled());
  replyCallback.getValue().onError(new IOException());
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_send).isEnabled());
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_quote).isVisible());
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_save_draft).isEnabled());
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_discard_draft).isEnabled());
  assertThat(activity).isNotFinishing();
  assertEquals(activity.getString(R.string.comment_failed), ShadowToast.getTextOfLatestToast());
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testQuote() {
  assertTrue(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_quote).isVisible());
  ((EditText) activity.findViewById(R.id.edittext_body)).setText("Reply");
  shadowOf(activity).clickMenuItem(R.id.menu_quote);
  assertThat((EditText) activity.findViewById(R.id.edittext_body))
      .hasTextString("> Paragraph 1\n\n> Paragraph 2\n\nReply");
}

代码示例来源:origin: hidroh/materialistic

@Test
public void testEmptyQuote() {
  Intent intent = new Intent();
  intent.putExtra(ComposeActivity.EXTRA_PARENT_ID, "1");
  controller = Robolectric.buildActivity(ComposeActivity.class, intent)
      .create().start().resume().visible();
  activity = controller.get();
  assertThat((View) activity.findViewById(R.id.quote)).isNotVisible();
  assertFalse(shadowOf(activity).getOptionsMenu().findItem(R.id.menu_quote).isVisible());
}

代码示例来源:origin: arimorty/floatingsearchview

@Override
public boolean onSubMenuSelected(SubMenuBuilder subMenu) {
  if (subMenu.hasVisibleItems()) {
    MenuPopupHelper subPopup = new MenuPopupHelper(mContext, subMenu, mAnchorView);
    subPopup.setCallback(mPresenterCallback);
    boolean preserveIconSpacing = false;
    final int count = subMenu.size();
    for (int i = 0; i < count; i++) {
      MenuItem childItem = subMenu.getItem(i);
      if (childItem.isVisible() && childItem.getIcon() != null) {
        preserveIconSpacing = true;
        break;
      }
    }
    subPopup.setForceShowIcon(preserveIconSpacing);
    if (subPopup.tryShow()) {
      if (mPresenterCallback != null) {
        mPresenterCallback.onOpenSubMenu(subMenu);
      }
      return true;
    }
  }
  return false;
}
@Override

代码示例来源:origin: hidroh/materialistic

PopupMenu popupMenu = ShadowPopupMenu.getLatestPopupMenu();
assertNotNull(popupMenu);
assertThat(popupMenu.getMenu().findItem(R.id.menu_contextual_save).isVisible()).isFalse();
shadowOf(popupMenu).getOnMenuItemClickListener()
    .onMenuItemClick(new RoboMenuItem(R.id.menu_contextual_save));

代码示例来源:origin: willowtreeapps/Hyperion-Android

public static Collection<ViewAttribute> createMenuAttributes(@NonNull Context context, @NonNull Menu menu) {
  final Resources res = context.getResources();
  List<ViewAttribute> attributes = new ArrayList<>();
  attributes.add(new ViewAttribute<>("MenuSize", menu.size()));
  attributes.add(new ViewAttribute<>("MenuHasVisibleItems", menu.hasVisibleItems()));
  for (int i = 0; i < menu.size(); i++) {
    MenuItem item = menu.getItem(i);
    String prefix = "Item " + i + ": ";
    attributes.add(new ViewAttribute<>(prefix + "Title", item.getTitle()));
    attributes.add(new ViewAttribute<>(prefix + "ContentDescription",
        MenuItemCompat.getContentDescription(item)));
    attributes.add(new ViewAttribute<>(prefix + "TooltipText", MenuItemCompat.getTooltipText(item)));
    attributes.add(new ViewAttribute<>(prefix + "Checkable", item.isCheckable()));
    attributes.add(new ViewAttribute<>(prefix + "Checked", item.isChecked()));
    attributes.add(new ViewAttribute<>(prefix + "Enabled", item.isEnabled()));
    attributes.add(new ViewAttribute<>(prefix + "Visible", item.isVisible()));
    attributes.add(new ViewAttribute<>(prefix + "Order", item.getOrder()));
    attributes.add(new ViewAttribute<Void>(prefix + "Icon", item.getIcon()));
    attributes.add(createColorAttribute("IconTint",
        MenuItemCompat.getIconTintList(item)));
    attributes.add(new ViewAttribute<>("IconTintMode",
        new PorterDuffModeValue(MenuItemCompat.getIconTintMode(item))));
    attributes.add(new ViewAttribute<>(prefix + "Id", new ResourceValue(res, item.getItemId())));
    attributes.add(new ViewAttribute<>(prefix + "GroupId", new ResourceValue(res, item.getGroupId())));
  }
  return attributes;
}

代码示例来源:origin: rubensousa/FloatingToolbar

/**
 * Place the menu items with icons inside a horizontal LinearLayout
 */
private void addMenuItems() {
  if (mMenu == null) {
    mMenu = new MenuBuilder(getContext());
    new SupportMenuInflater(getContext()).inflate(mMenuRes, mMenu);
  }
  LinearLayoutCompat.LayoutParams layoutParams
      = new LinearLayoutCompat.LayoutParams(LayoutParams.WRAP_CONTENT,
      LayoutParams.MATCH_PARENT, 1);
  setWeightSum(mMenu.size());
  for (int i = 0; i < mMenu.size(); i++) {
    MenuItem item = mMenu.getItem(i);
    if (item.isVisible()) {
      AppCompatImageButton imageButton = new AppCompatImageButton(getContext());
      //noinspection ResourceType
      imageButton.setId(item.getItemId() == Menu.NONE ? genViewId() : item.getItemId());
      imageButton.setBackgroundResource(mItemBackground);
      imageButton.setImageDrawable(item.getIcon());
      imageButton.setOnClickListener(this);
      imageButton.setOnLongClickListener(this);
      imageButton.setTag(item);
      mMenuLayout.addView(imageButton, layoutParams);
    }
  }
}

代码示例来源:origin: com.squareup.assertj/assertj-android

public MenuItemAssert isNotVisible() {
  isNotNull();
  assertThat(actual.isVisible()) //
    .overridingErrorMessage("Expected to not be visible but was visible.") //
    .isFalse();
  return this;
 }
}

代码示例来源:origin: VREMSoftwareDevelopment/WiFiAnalyzer

@Test
public void testApplyWithWiFiBandVisible() {
  // execute
  fixture.apply(mainActivity);
  // validate
  Menu menu = mainActivity.getOptionMenu().getMenu();
  assertTrue(menu.findItem(R.id.action_wifi_band).isVisible());
}

相关文章