use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.
the class ArtistFragment method subscribeMediaUpdateEvent.
private void subscribeMediaUpdateEvent() {
Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {
@Override
public void call(MediaUpdateEvent event) {
mPresenter.loadArtists(action);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
}
});
RxBus.getInstance().addSubscription(this, subscription);
}
use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.
the class SearchFragment method subscribeMediaUpdateEvent.
private void subscribeMediaUpdateEvent() {
Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {
@Override
public void call(MediaUpdateEvent event) {
mPresenter.search(queryString);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
}
});
RxBus.getInstance().addSubscription(this, subscription);
}
use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.
the class SongsFragment method subscribeMediaUpdateEvent.
private void subscribeMediaUpdateEvent() {
Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {
@Override
public void call(MediaUpdateEvent event) {
mPresenter.loadSongs(action);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
}
});
RxBus.getInstance().addSubscription(this, subscription);
}
use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.
the class FolderAdapter 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);
int adapterPosition = itemHolder.getAdapterPosition();
final FolderInfo folderInfo = arraylist.get(adapterPosition);
menu.setOnMenuItemClickListener(new PopupMenu.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.popup_folder_addto_queue:
getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
MusicPlayer.addToQueue(mContext, ids, -1, ListenerUtil.IdType.Folder);
}
});
break;
case R.id.popup_folder_addto_playlist:
getSongListIdByFolder(folderInfo.folderPath).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_folder_delete:
new MaterialDialog.Builder(mContext).title(mContext.getResources().getString(R.string.delete_folder)).content("删除文件夹下" + folderInfo.songCount + "首歌曲?").positiveText(R.string.delete).negativeText(R.string.cancel).onPositive(new MaterialDialog.SingleButtonCallback() {
@Override
public void onClick(@NonNull MaterialDialog dialog, @NonNull DialogAction which) {
getSongListIdByFolder(folderInfo.folderPath).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Action1<long[]>() {
@Override
public void call(long[] ids) {
ListenerUtil.deleteTracks(mContext, ids);
RxBus.getInstance().post(new MediaUpdateEvent());
}
});
}
}).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_folder);
menu.show();
}
});
}
use of io.hefuyi.listener.event.MediaUpdateEvent in project ListenerMusicPlayer by hefuyicoder.
the class AlbumFragment method subscribeMediaUpdateEvent.
private void subscribeMediaUpdateEvent() {
Subscription subscription = RxBus.getInstance().toObservable(MediaUpdateEvent.class).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).debounce(1, TimeUnit.SECONDS).subscribe(new Action1<MediaUpdateEvent>() {
@Override
public void call(MediaUpdateEvent event) {
mPresenter.loadAlbums(action);
}
}, new Action1<Throwable>() {
@Override
public void call(Throwable throwable) {
}
});
RxBus.getInstance().addSubscription(this, subscription);
}
Aggregations