Java Code Examples for android.view.Menu#clear()

The following examples show how to use android.view.Menu#clear() . 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: MediaPreviewActivity.java    From mollyim-android with GNU General Public License v3.0 6 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
  super.onPrepareOptionsMenu(menu);

  menu.clear();
  MenuInflater inflater = this.getMenuInflater();
  inflater.inflate(R.menu.media_preview, menu);

  if (!isMediaInDb()) {
    menu.findItem(R.id.media_preview__overview).setVisible(false);
    menu.findItem(R.id.delete).setVisible(false);
  }

  if (cameFromAllMedia) {
    menu.findItem(R.id.media_preview__overview).setVisible(false);
  }

  return true;
}
 
Example 2
Source File: NewPostActivity.java    From BlackLight with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
       menu.clear();
	getMenuInflater().inflate(R.menu.new_post, menu);
       if (mBitmap != null){
           menu.findItem(R.id.post_pic)
                   .setTitle(R.string.delete_picture)
                   .setIcon(android.R.drawable.ic_menu_delete);
       }
	return true;
}
 
Example 3
Source File: DraftsFragment.java    From BuildmLearn-Toolkit-Android with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * {@inheritDoc}
 */
@Override
public void onPrepareOptionsMenu(Menu menu) {
    super.onPrepareOptionsMenu(menu);
    menu.clear();
    if (showTemplateSelectedMenu) {
        activity.getMenuInflater().inflate(R.menu.menu_project_selected, menu);
        menu.findItem(R.id.action_share).setVisible(false);
    } else if (mAdapter.getCount() > 0) {
        activity.getMenuInflater().inflate(R.menu.menu_draft, menu);
    }
}
 
Example 4
Source File: ThreadDetailFragment.java    From hipda with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.menu_thread_detail, menu);

    mShowAllMenuItem = menu.findItem(R.id.action_show_all);
    mShowAllMenuItem.setIcon(new IconicsDrawable(getActivity(), GoogleMaterial.Icon.gmd_eject)
            .color(HiSettingsHelper.getInstance().getToolbarTextColor()).sizeDp(16));

    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 5
Source File: PrivacyPreferences.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    MenuItem help = menu.add(
            Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help);
    help.setIcon(R.drawable.ic_help_and_feedback);
}
 
Example 6
Source File: ActionBarPlugin.java    From cordova-android-actionbar with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Object onMessage(String id, Object data)
{
	if("onCreateOptionsMenu".equals(id) || "onPrepareOptionsMenu".equals(id))
	{
		menu = (Menu)data;

		if(menu_definition != null && menu.size() != menu_definition.length())
		{
			menu.clear();
			menu_callbacks.clear();
			buildMenu(menu, menu_definition);
		}
	}
	else if("onOptionsItemSelected".equals(id))
	{
		MenuItem item = (MenuItem)data;
		if(item.getItemId() == android.R.id.home)
		{
			webView.sendJavascript("if(window.plugins.actionbar.home_callback) window.plugins.actionbar.home_callback();");
		}
		else if(menu_callbacks.containsKey(item))
		{
			final String callback = menu_callbacks.get(item);
			webView.sendJavascript(callback);
		}
	}
	
	return null;
}
 
Example 7
Source File: FragmentActivity.java    From adt-leanback-support with Apache License 2.0 5 votes vote down vote up
/**
 * Dispatch onPrepareOptionsMenu() to fragments.
 */
@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
        if (mOptionsMenuInvalidated) {
            mOptionsMenuInvalidated = false;
            menu.clear();
            onCreatePanelMenu(featureId, menu);
        }
        boolean goforit = onPrepareOptionsPanel(view, menu);
        goforit |= mFragments.dispatchPrepareOptionsMenu(menu);
        return goforit;
    }
    return super.onPreparePanel(featureId, view, menu);
}
 
Example 8
Source File: LanguagePreferences.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    MenuItem help = menu.add(
            Menu.NONE, R.id.menu_id_targeted_help, Menu.NONE, R.string.menu_help);
    help.setIcon(R.drawable.ic_help_and_feedback);
    help.setShowAsAction(MenuItem.SHOW_AS_ACTION_IF_ROOM);

    menu.add(Menu.NONE, R.id.menu_id_reset, Menu.NONE, R.string.reset_translate_defaults);
}
 
Example 9
Source File: NavigationActivity.java    From MTweaks-KernelAdiutorMOD with GNU General Public License v3.0 5 votes vote down vote up
private void appendFragments(boolean setShortcuts) {
    mActualFragments.clear();
    Menu menu = mNavigationView.getMenu();
    menu.clear();

    SubMenu lastSubMenu = null;
    for (NavigationFragment navigationFragment : mFragments) {
        Class<? extends Fragment> fragmentClass = navigationFragment.mFragmentClass;
        int id = navigationFragment.mId;

        Drawable drawable = ContextCompat.getDrawable(this,
                    AppSettings.isSectionIcons(this)
                    && navigationFragment.mDrawable != 0 ? navigationFragment.mDrawable :
                    R.drawable.ic_blank);

        if (fragmentClass == null) {
            lastSubMenu = menu.addSubMenu(id);
            mActualFragments.put(id, null);
        } else if (AppSettings.isFragmentEnabled(fragmentClass, this)) {
            MenuItem menuItem = lastSubMenu == null ? menu.add(0, id, 0, id) :
                    lastSubMenu.add(0, id, 0, id);
            menuItem.setIcon(drawable);
            menuItem.setCheckable(true);
            if (mSelection != 0) {
                mNavigationView.setCheckedItem(mSelection);
            }
            mActualFragments.put(id, fragmentClass);
        }
    }
    if (setShortcuts) {
        setShortcuts();
    }
}
 
Example 10
Source File: EdictEntryDetailActivity.java    From aedict with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
	menu.clear();
	showRomaji.register(this, menu);
	AbstractActivity.addMenuItems(this, menu);
	return true;
}
 
Example 11
Source File: ModelDetailActivity.java    From Synapse with Apache License 2.0 5 votes vote down vote up
@Override
public boolean onCreateOptionsMenu(Menu menu) {
    menu.clear();

    getMenuInflater()
            .inflate(R.menu.ac_model_detail_menu, menu);

    return super.onCreateOptionsMenu(menu);
}
 
Example 12
Source File: TrainingActivity.java    From privacy-friendly-pedometer with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean onPrepareOptionsMenu(Menu menu) {
    // Add the walking modes to option menu
    menu.clear();
    menuWalkingModes = new HashMap<>();
    List<WalkingMode> walkingModes = WalkingModePersistenceHelper.getAllItems(this);
    int i = 0;
    for (WalkingMode walkingMode : walkingModes) {
        int id = Menu.FIRST + (i++);
        menuWalkingModes.put(id, walkingMode);
        menu.add(0, id, Menu.NONE, walkingMode.getName()).setChecked(walkingMode.isActive());
    }
    menu.setGroupCheckable(0, true, true);
    return super.onPrepareOptionsMenu(menu);
}
 
Example 13
Source File: FragmentActivity.java    From guideshow with MIT License 5 votes vote down vote up
/**
 * Dispatch onPrepareOptionsMenu() to fragments.
 */
@Override
public boolean onPreparePanel(int featureId, View view, Menu menu) {
    if (featureId == Window.FEATURE_OPTIONS_PANEL && menu != null) {
        if (mOptionsMenuInvalidated) {
            mOptionsMenuInvalidated = false;
            menu.clear();
            onCreatePanelMenu(featureId, menu);
        }
        boolean goforit = onPrepareOptionsPanel(view, menu);
        goforit |= mFragments.dispatchPrepareOptionsMenu(menu);
        return goforit;
    }
    return super.onPreparePanel(featureId, view, menu);
}
 
Example 14
Source File: OtherStoriesFragment.java    From ZhihuDaily with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.menu_other_story, menu);
    if (SharedPreferencesUtils.contains(App.getContext(), Integer.toString(id))
            && (boolean) SharedPreferencesUtils.get(App.getContext(), Integer.toString(id), false)) {
        menu.findItem(R.id.action_follow).setIcon(R.drawable.ic_remove_follow);
    } else {
        menu.findItem(R.id.action_follow).setIcon(R.drawable.ic_add_follow);
    }
    super.onCreateOptionsMenu(menu, inflater);
}
 
Example 15
Source File: AccAboutFragment.java    From tindroid with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
    menu.clear();
}
 
Example 16
Source File: CacheListFragment.java    From ShoppingList with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    super.onCreateOptionsMenu(menu, inflater);
    menu.clear();
}
 
Example 17
Source File: BlankFragment.java    From MultiView with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
}
 
Example 18
Source File: MainPreferences.java    From openScale with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
}
 
Example 19
Source File: BasicFragment.java    From MultiView with Apache License 2.0 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
    menu.clear();
    inflater.inflate(R.menu.basic, menu);

}
 
Example 20
Source File: ChatActivity.java    From Yahala-Messenger with MIT License 4 votes vote down vote up
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {

    if (parentActivity == null) {
        return;
    }

    menu.clear();

    inflater.inflate(R.menu.chat_menu, menu);

    //SupportMenuItem timeItem = (SupportMenuItem) menu.findItem(R.id.chat_enc_timer);


    // actionBar.setTitle(LocaleController.getString("AppName", R.string.AppName));

    SupportMenuItem avatarItem = (SupportMenuItem) menu.findItem(R.id.chat_menu_avatar);
    View avatarLayout = avatarItem.getActionView();
    avatarImageView = (CircleImageView) avatarLayout.findViewById(R.id.chat_avatar_image);
    avatarImageView.setBorderWidth(OSUtilities.dp(0));

    avatarImageView.setBorderColor(0x00000000);
    avatarImageView.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            if (parentActivity == null) {
                return;
            }
            if (currentUser != null) {
                UserProfileActivity fragment = new UserProfileActivity();
                Bundle args = new Bundle();
                args.putString("user_id", currentUser.jid);

                fragment.setArguments(args);
                ((LaunchActivity) parentActivity).presentFragment(fragment, "user_" + currentUser.jid, swipeOpening);
            } else if (currentChat != null) {
                /*if (info != null) {
                    if (info instanceof TLRPC.TL_chatParticipantsForbidden) {
                        return;
                    }
                    NotificationCenter.getInstance().addToMemCache(5, info);
                }
                if (currentChat.participants_count == 0 || currentChat.left || currentChat instanceof TLRPC.TL_chatForbidden) {
                    return;
                }
                ChatProfileActivity fragment = new ChatProfileActivity();
                Bundle args = new Bundle();
                args.putInt("chat_id", currentChat.id);
                fragment.setArguments(args);
                ((LaunchActivity) parentActivity).presentFragment(fragment, "chat_" + currentChat.id, swipeOpening);*/
            }
        }
    });
    TLRPC.FileLocation photo = null;
    int placeHolderId = 0;
    if (currentUser != null) {
        if (currentUser.photo != null) {
            photo = currentUser.photo.photo_small;
        }
        placeHolderId = Utilities.getUserAvatarForId(currentUser.id);
    } else if (currentChat != null) {
        /*if (currentChat.photo != null) {
            photo = currentChat.photo.photo_small;
        }*/
        placeHolderId = Utilities.getGroupAvatarForId(currentChat.id);
        //      }
        //    avatarImageView.setImage(photo, "50_50",

    }
    ImageLoaderInitializer.getInstance().initImageLoader(R.drawable.user_blue, 400, 400);
    ImageTag tag = ImageLoaderInitializer.getInstance().imageTagFactory.build(currentUser.avatarUrl, ApplicationLoader.applicationContext);
    avatarImageView.setTag(tag);
    ImageLoaderInitializer.getInstance().getImageLoader().getLoader().load(avatarImageView);
    //com.yahala.ui.lazylist.ImageLoader.getInstance().DisplayImage(currentUser.avatarUrl, avatarImageView);
    // avatarImageView.setImageBitmap(currentUser.avatar);

}