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