use of android.view.MenuItem in project androidannotations by androidannotations.
the class OptionsMenuActivityTest method subclassTakesPrecedenceInMenuItemHandling.
@Test
public void subclassTakesPrecedenceInMenuItemHandling() {
MenuItem item = mock(MenuItem.class);
when(item.getItemId()).thenReturn(R.id.menu_refresh);
activity.onOptionsItemSelected(item);
assertThat(activity.menuRefreshSelected).isTrue();
assertThat(activity.menuRefreshSelectedFromAnnotatedClass).isFalse();
}
use of android.view.MenuItem in project androidannotations by androidannotations.
the class OptionsMenuActivityTest method defaultIdUnderscore.
@Test
public void defaultIdUnderscore() {
MenuItem item = mock(MenuItem.class);
when(item.getItemId()).thenReturn(R.id.menu_add);
activity.onOptionsItemSelected(item);
assertThat(activity.menuAdd).isTrue();
}
use of android.view.MenuItem in project simplefacebook by androidquery.
the class MenuActivity method onCreateOptionsMenu.
@Override
public boolean onCreateOptionsMenu(Menu menu) {
int id = getMenu();
try {
if (id != 0) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(id, menu);
if (!PrefUtility.isTestDevice()) {
menu.removeItem(R.id.debug);
}
if (isActionBar()) {
MenuItem mi = menu.findItem(R.id.refresh);
if (mi != null) {
refreshView = mi.getActionView();
aq2.recycle(refreshView);
aq2.id(R.id.button_action_refresh).clicked(this, "refreshClicked");
if (isBusy()) {
showActionProgress(true);
}
}
}
}
} catch (Exception e) {
AQUtility.report(e);
}
return true;
}
use of android.view.MenuItem in project platform_frameworks_base by android.
the class Activity method onProvideKeyboardShortcuts.
@Override
public void onProvideKeyboardShortcuts(List<KeyboardShortcutGroup> data, Menu menu, int deviceId) {
if (menu == null) {
return;
}
KeyboardShortcutGroup group = null;
int menuSize = menu.size();
for (int i = 0; i < menuSize; ++i) {
final MenuItem item = menu.getItem(i);
final CharSequence title = item.getTitle();
final char alphaShortcut = item.getAlphabeticShortcut();
if (title != null && alphaShortcut != MIN_VALUE) {
if (group == null) {
final int resource = mApplication.getApplicationInfo().labelRes;
group = new KeyboardShortcutGroup(resource != 0 ? getString(resource) : null);
}
group.addItem(new KeyboardShortcutInfo(title, alphaShortcut, KeyEvent.META_CTRL_ON));
}
}
if (group != null) {
data.add(group);
}
}
use of android.view.MenuItem in project ListenerMusicPlayer by hefuyicoder.
the class AlbumAdapter method setOnPopupMenuListener.
private void setOnPopupMenuListener(final AlbumAdapter.ItemHolder itemHolder, final int position) {
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
int adapterPosition = itemHolder.getAdapterPosition();
final Album album = arraylist.get(adapterPosition);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_album_addto_queue:
getSongListIdByAlbum(arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.NA);
}
});
break;
case R.id.popup_album_addto_playlist:
getSongListIdByAlbum(arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showAddPlaylistDialog(mContext, ids);
}
});
break;
case R.id.popup_album_goto_artist:
NavigationUtil.goToArtist(mContext, arraylist.get(position).artistId, arraylist.get(position).artistName);
break;
case R.id.popup_artist_delete:
switch(action) {
case Constants.NAVIGATE_PLAYLIST_FAVOURATE:
getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showDeleteFromFavourate(mContext, ids);
}
});
break;
case Constants.NAVIGATE_PLAYLIST_RECENTPLAY:
getSongListIdByAlbum(album.id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.showDeleteFromRecentlyPlay(mContext, ids);
}
});
break;
default:
AlbumSongLoader.getSongsForAlbum(mContext, arraylist.get(position).id).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<List<Song>>() {
@Override
public void call(List<Song> songs) {
long[] ids = new long[songs.size()];
int i = 0;
for (Song song : songs) {
ids[i] = song.id;
i++;
}
if (ids.length == 1) {
ListenerUtil.showDeleteDialog(mContext, songs.get(0).title, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
arraylist.remove(position);
notifyDataSetChanged();
}
});
} else {
String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, arraylist.get(position).songCount);
ListenerUtil.showDeleteDialog(mContext, songCount, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
arraylist.remove(position);
notifyDataSetChanged();
}
});
}
}
});
break;
}
break;
}
return false;
}
});
menu.inflate(R.menu.popup_album);
menu.show();
}
});
}
Aggregations