Search in sources :

Example 46 with PopupMenu

use of android.widget.PopupMenu in project KISS by Neamar.

the class Result method inflatePopupMenu.

protected PopupMenu inflatePopupMenu(@MenuRes int menuId, Context context, View parentView) {
    PopupMenu menu = new PopupMenu(context, parentView);
    menu.getMenuInflater().inflate(menuId, menu.getMenu());
    // If app already pinned, do not display the "add to favorite" option
    // otherwise don't show the "remove favorite button"
    String favApps = PreferenceManager.getDefaultSharedPreferences(context).getString("favorite-apps-list", "");
    if (favApps.contains(this.pojo.id + ";")) {
        menu.getMenu().removeItem(R.id.item_favorites_add);
    } else {
        menu.getMenu().removeItem(R.id.item_favorites_remove);
    }
    return menu;
}
Also used : PopupMenu(android.widget.PopupMenu)

Example 47 with PopupMenu

use of android.widget.PopupMenu in project PersistentSearch by KieronQuinn.

the class SearchBox method setOverflowMenu.

public void setOverflowMenu(@MenuRes int overflowMenuResId) {
    overflow.setVisibility(VISIBLE);
    popupMenu = new PopupMenu(context, overflow);
    popupMenu.getMenuInflater().inflate(overflowMenuResId, popupMenu.getMenu());
}
Also used : PopupMenu(android.widget.PopupMenu)

Example 48 with PopupMenu

use of android.widget.PopupMenu in project muzei by romannurik.

the class MuzeiActivity method setupOverflowButton.

private void setupOverflowButton() {
    final View overflowButton = findViewById(R.id.overflow_button);
    mOverflowMenu = new PopupMenu(this, overflowButton);
    overflowButton.setOnTouchListener(mOverflowMenu.getDragToOpenListener());
    overflowButton.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View view) {
            mOverflowMenuVisible = true;
            mOverflowMenu.show();
        }
    });
    mOverflowMenu.setOnDismissListener(new PopupMenu.OnDismissListener() {

        @Override
        public void onDismiss(PopupMenu popupMenu) {
            mOverflowMenuVisible = false;
        }
    });
    mOverflowMenu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

        @Override
        public boolean onMenuItemClick(MenuItem menuItem) {
            int id = mOverflowSourceActionMap.get(menuItem.getItemId());
            if (id > 0) {
                SourceManager.sendAction(MuzeiActivity.this, id);
                return true;
            }
            switch(menuItem.getItemId()) {
                case R.id.action_settings:
                    FirebaseAnalytics.getInstance(MuzeiActivity.this).logEvent("settings_open", null);
                    startActivity(new Intent(MuzeiActivity.this, SettingsActivity.class));
                    return true;
            }
            return false;
        }
    });
}
Also used : MenuItem(android.view.MenuItem) Intent(android.content.Intent) ImageView(android.widget.ImageView) View(android.view.View) AnimatedMuzeiLoadingSpinnerView(com.google.android.apps.muzei.util.AnimatedMuzeiLoadingSpinnerView) TextView(android.widget.TextView) PanScaleProxyView(com.google.android.apps.muzei.util.PanScaleProxyView) PopupMenu(android.widget.PopupMenu)

Example 49 with PopupMenu

use of android.widget.PopupMenu in project double-espresso by JakeWharton.

the class MenuActivity method showPopup.

public void showPopup(View view) {
    if (Build.VERSION.SDK_INT < Build.VERSION_CODES.HONEYCOMB) {
        TextView text = (TextView) findViewById(R.id.text_menu_result);
        text.setText("Not supported in API " + Build.VERSION.SDK_INT);
    } else {
        PopupMenu popup = new PopupMenu(this, view);
        popup.setOnMenuItemClickListener(new PopupMenuListener());
        popup.getMenuInflater().inflate(R.menu.popupmenu, popup.getMenu());
        popup.show();
    }
}
Also used : TextView(android.widget.TextView) PopupMenu(android.widget.PopupMenu)

Example 50 with PopupMenu

use of android.widget.PopupMenu in project NetGuard by M66B.

the class ActivityForwarding method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    Util.setTheme(this);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.forwarding);
    running = true;
    getSupportActionBar().setTitle(R.string.setting_forwarding);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    lvForwarding = (ListView) findViewById(R.id.lvForwarding);
    adapter = new AdapterForwarding(this, DatabaseHelper.getInstance(this).getForwarding());
    lvForwarding.setAdapter(adapter);
    lvForwarding.setOnItemClickListener(new AdapterView.OnItemClickListener() {

        @Override
        public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
            Cursor cursor = (Cursor) adapter.getItem(position);
            final int protocol = cursor.getInt(cursor.getColumnIndex("protocol"));
            final int dport = cursor.getInt(cursor.getColumnIndex("dport"));
            final String raddr = cursor.getString(cursor.getColumnIndex("raddr"));
            final int rport = cursor.getInt(cursor.getColumnIndex("rport"));
            PopupMenu popup = new PopupMenu(ActivityForwarding.this, view);
            popup.inflate(R.menu.forward);
            popup.getMenu().findItem(R.id.menu_port).setTitle(Util.getProtocolName(protocol, 0, false) + " " + dport + " > " + raddr + "/" + rport);
            popup.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {

                @Override
                public boolean onMenuItemClick(MenuItem menuItem) {
                    if (menuItem.getItemId() == R.id.menu_delete) {
                        DatabaseHelper.getInstance(ActivityForwarding.this).deleteForward(protocol, dport);
                        ServiceSinkhole.reload("forwarding", ActivityForwarding.this);
                        adapter = new AdapterForwarding(ActivityForwarding.this, DatabaseHelper.getInstance(ActivityForwarding.this).getForwarding());
                        lvForwarding.setAdapter(adapter);
                    }
                    return false;
                }
            });
            popup.show();
        }
    });
}
Also used : MenuItem(android.view.MenuItem) Cursor(android.database.Cursor) View(android.view.View) AdapterView(android.widget.AdapterView) ListView(android.widget.ListView) AdapterView(android.widget.AdapterView) PopupMenu(android.widget.PopupMenu)

Aggregations

PopupMenu (android.widget.PopupMenu)99 MenuItem (android.view.MenuItem)60 View (android.view.View)44 TextView (android.widget.TextView)41 ImageView (android.widget.ImageView)30 RecyclerView (android.support.v7.widget.RecyclerView)22 TargetApi (android.annotation.TargetApi)20 SlowTest (io.github.hidroh.materialistic.test.suite.SlowTest)19 Test (org.junit.Test)19 ShadowPopupMenu (org.robolectric.shadows.ShadowPopupMenu)19 RoboMenuItem (org.robolectric.fakes.RoboMenuItem)18 Intent (android.content.Intent)14 Context (android.content.Context)12 DialogAction (com.afollestad.materialdialogs.DialogAction)12 MaterialDialog (com.afollestad.materialdialogs.MaterialDialog)12 MenuInflater (android.view.MenuInflater)10 AdapterView (android.widget.AdapterView)10 ListView (android.widget.ListView)10 Menu (android.view.Menu)9 NonNull (android.support.annotation.NonNull)8