use of android.support.annotation.NonNull in project AndroidPicker by gzu-liyujiang.
the class ColorPicker method makeCenterView.
@Override
@NonNull
protected LinearLayout makeCenterView() {
LinearLayout rootLayout = new LinearLayout(activity);
rootLayout.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, MATCH_PARENT));
rootLayout.setOrientation(LinearLayout.VERTICAL);
multiColorView = new ColorPanelView(activity);
multiColorView.setId(MULTI_ID);
multiColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, 0, 1.0f));
Drawable cursorTopDrawable = ConvertUtils.toDrawable(ColorPickerIcon.getCursorTop());
multiColorView.setPointerDrawable(cursorTopDrawable);
multiColorView.setOnColorChangedListener(new ColorPanelView.OnColorChangedListener() {
@Override
public void onColorChanged(ColorPanelView view, int color) {
updateCurrentColor(color);
}
});
rootLayout.addView(multiColorView);
blackColorView = new ColorPanelView(activity);
blackColorView.setId(BLACK_ID);
blackColorView.setLayoutParams(new LinearLayout.LayoutParams(MATCH_PARENT, ConvertUtils.toPx(activity, 30)));
Drawable cursorBottomDrawable = ConvertUtils.toDrawable(ColorPickerIcon.getCursorBottom());
blackColorView.setPointerDrawable(cursorBottomDrawable);
blackColorView.setOnColorChangedListener(new ColorPanelView.OnColorChangedListener() {
@Override
public void onColorChanged(ColorPanelView view, int color) {
updateCurrentColor(color);
}
});
rootLayout.addView(blackColorView);
return rootLayout;
}
use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.
the class CreatePlaylistDialog method onCreateDialog.
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
return new MaterialDialog.Builder(getActivity()).title(R.string.create_new_playlist).positiveText(R.string.create).negativeText(R.string.cancel).input(getString(R.string.playlist_name), "", false, new MaterialDialog.InputCallback() {
@Override
public void onInput(@NonNull MaterialDialog dialog, CharSequence input) {
long[] songs = getArguments().getLongArray("songs");
long playistId = MusicPlayer.createPlaylist(getActivity(), input.toString());
if (playistId != -1) {
if (songs != null && songs.length != 0) {
MusicPlayer.addToPlaylist(getActivity(), songs, playistId);
} else {
Toast.makeText(getActivity(), R.string.create_playlist_success, Toast.LENGTH_SHORT).show();
}
RxBus.getInstance().post(new PlaylistUpdateEvent());
} else {
Toast.makeText(getActivity(), R.string.create_playlist_fail, Toast.LENGTH_SHORT).show();
}
}
}).build();
}
use of android.support.annotation.NonNull 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();
}
});
}
use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.
the class PlaylistSongAdapter method setOnPopupMenuListener.
private void setOnPopupMenuListener(final ItemHolder itemHolder, final int position) {
itemHolder.popupMenu.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
final PopupMenu menu = new PopupMenu(mContext, v);
final int adapterPosition = itemHolder.getAdapterPosition();
final Song song = arraylist.get(adapterPosition);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_song_play_next:
long[] ids = new long[1];
ids[0] = arraylist.get(adapterPosition).id;
MusicPlayer.playNext(mContext, ids, -1, ListenerUtil.IdType.NA);
break;
case R.id.popup_song_goto_album:
NavigationUtil.goToAlbum(mContext, song.albumId, song.title);
break;
case R.id.popup_song_goto_artist:
NavigationUtil.goToArtist(mContext, song.artistId, song.artistName);
break;
case R.id.popup_song_addto_queue:
long[] id = new long[1];
id[0] = song.id;
MusicPlayer.addToQueue(mContext, id, -1, ListenerUtil.IdType.Playlist);
break;
case R.id.popup_song_addto_playlist:
ListenerUtil.showAddPlaylistDialog(mContext, new long[] { song.id });
break;
case R.id.popup_song_delete:
new MaterialDialog.Builder(mContext).title(mContext.getResources().getString(R.string.delete_playlist_song) + "?").positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
PlaylistSongLoader.removeFromPlaylist(mContext, new long[] { song.id }, playlistId);
arraylist.remove(adapterPosition);
songIDs = getSongIds();
notifyItemRemoved(adapterPosition);
}
}).onNegative(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
dialog.dismiss();
}
}).show();
break;
}
return false;
}
});
menu.inflate(R.menu.popup_song);
menu.show();
}
});
}
use of android.support.annotation.NonNull in project ListenerMusicPlayer by hefuyicoder.
the class SearchAdapter method setArtistPopupMenu.
private void setArtistPopupMenu(ItemHolder itemHolder, final int position) {
final Artist artist = (Artist) 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_artist_addto_queue:
getSongListIdByArtist(artist.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_artist_addto_playlist:
getSongListIdByArtist(artist.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_artist_delete:
ArtistSongLoader.getSongsForArtist(mContext, artist.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, artist.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_artist);
menu.show();
}
});
}
Aggregations