use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.
the class SearchAdapter method setAlbumPopupMenu.
private void setAlbumPopupMenu(ItemHolder itemHolder, final int position) {
final Album album = (Album) searchResults.get(position);
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_album_addto_queue:
getSongListIdByAlbum(album.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(album.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, album.artistId, album.artistName);
break;
case R.id.popup_artist_delete:
AlbumSongLoader.getSongsForAlbum(mContext, album.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) {
searchResults.remove(position);
notifyDataSetChanged();
}
});
} else {
String songCount = ListenerUtil.makeLabel(mContext, R.plurals.Nsongs, album.songCount);
ListenerUtil.showDeleteDialog(mContext, songCount, ids, new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
searchResults.remove(position);
notifyDataSetChanged();
}
});
}
}
});
break;
}
return false;
}
});
menu.inflate(R.menu.popup_album);
menu.show();
}
});
}
use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.
the class PlaylistDetailFragment method showRenamePlaylistDialog.
private void showRenamePlaylistDialog(String oldName) {
new MaterialDialog.Builder(getActivity()).title(R.string.rename_playlist).positiveText("确定").negativeText(R.string.cancel).input(null, oldName, false, new MaterialDialog.InputCallback() {
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
MusicPlayer.renamePlaylist(getActivity(), playlistID, input.toString());
collapsingToolbarLayout.setTitle(input.toString());
playlistName = input.toString();
RxBus.getInstance().post(new PlaylistUpdateEvent());
Toast.makeText(getActivity(), R.string.rename_playlist_success, Toast.LENGTH_SHORT).show();
}
}).show();
}
use of android.support.annotation.NonNull in project cameraview by google.
the class AspectRatioFragment method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final Bundle args = getArguments();
final AspectRatio[] ratios = (AspectRatio[]) args.getParcelableArray(ARG_ASPECT_RATIOS);
if (ratios == null) {
throw new RuntimeException("No ratios");
}
final AspectRatio current = args.getParcelable(ARG_CURRENT_ASPECT_RATIO);
final AspectRatioAdapter adapter = new AspectRatioAdapter(ratios, current);
return new AlertDialog.Builder(getActivity()).setAdapter(adapter, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int position) {
mListener.onAspectRatioSelected(ratios[position]);
}
}).create();
}
use of android.support.annotation.NonNull in project flexbox-layout by google.
the class FlexboxLayout method createOrders.
@NonNull
private List<Order> createOrders(int childCount) {
List<Order> orders = new ArrayList<>(childCount);
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
LayoutParams params = (LayoutParams) child.getLayoutParams();
Order order = new Order();
order.order = params.order;
order.index = i;
orders.add(order);
}
return orders;
}
use of android.support.annotation.NonNull in project react-native-image-picker by marcshilling.
the class ButtonsHelper method getCustomButtons.
@NonNull
private static LinkedList<Item> getCustomButtons(@NonNull final ReadableMap options) {
LinkedList<Item> result = new LinkedList<>();
if (!options.hasKey("customButtons")) {
return result;
}
final ReadableArray customButtons = options.getArray("customButtons");
for (int i = 0; i < customButtons.size(); i++) {
final ReadableMap button = customButtons.getMap(i);
final String title = button.getString("title");
final String action = button.getString("name");
result.add(new Item(title, action));
}
return result;
}
Aggregations