use of com.simplecity.amp_library.model.Album in project Shuttle by timusus.
the class BaseDetailFragment method onAlbumOverflowClicked.
@Override
public void onAlbumOverflowClicked(View v, Album album) {
PopupMenu popupMenu = new PopupMenu(getContext(), v);
MenuUtils.setupAlbumMenu(popupMenu);
popupMenu.setOnMenuItemClickListener(MenuUtils.getAlbumMenuClickListener(getContext(), album, taggerDialog -> taggerDialog.show(getChildFragmentManager()), deleteDialog -> deleteDialog.show(getChildFragmentManager()), () -> UpgradeDialog.getUpgradeDialog(getActivity()).show(), null));
popupMenu.show();
}
use of com.simplecity.amp_library.model.Album in project Shuttle by timusus.
the class MusicService method notifyChange.
private void notifyChange(String what, boolean fromUser) {
if (what.equals(InternalIntents.TRACK_ENDING)) {
// We're just about to change tracks, so 'current song' is the song that just finished
Song finishedSong = currentSong;
if (finishedSong != null) {
if (finishedSong.hasPlayed()) {
Completable.fromAction(() -> ShuttleUtils.incrementPlayCount(this, finishedSong)).subscribeOn(Schedulers.io()).subscribe(() -> {
// Nothing to do
}, error -> LogUtils.logException(TAG, "Error incrementing play count", error));
}
scrobbleBroadcast(Status.COMPLETE, finishedSong);
}
return;
}
if (what.equals(InternalIntents.FAVORITE_CHANGED)) {
updateNotification();
Intent intent = new Intent(what);
sendBroadcast(intent);
return;
}
updateMediaSession(what);
if (what.equals(InternalIntents.POSITION_CHANGED)) {
return;
}
getExtras(fromUser).subscribeOn(Schedulers.io()).subscribe(extras -> {
final Intent intent = new Intent(what);
intent.putExtras(extras);
sendBroadcast(intent);
}, error -> LogUtils.logException(TAG, "Error sending broadcast", error));
// Tasker intent
Intent taskerIntent = new Intent(ExternalIntents.TASKER);
// Pebble intent
Intent pebbleIntent = new Intent(ExternalIntents.PEBBLE);
pebbleIntent.putExtra("artist", getArtistName());
pebbleIntent.putExtra("album", getAlbumName());
pebbleIntent.putExtra("track", getSongName());
if (what.equals(InternalIntents.PLAY_STATE_CHANGED)) {
updateNotification();
// Bluetooth intent
getExtras(fromUser).subscribeOn(Schedulers.io()).subscribe(extras -> {
final Intent intent = new Intent(ExternalIntents.AVRCP_PLAY_STATE_CHANGED);
intent.putExtras(extras);
sendBroadcast(intent);
}, error -> LogUtils.logException(TAG, "Error sending bluetooth intent", error));
if (isPlaying()) {
if (currentSong != null) {
currentSong.setResumed();
}
// Last.fm scrobbler intent
scrobbleBroadcast(Status.RESUME, currentSong);
// Tasker intent
taskerIntent.putExtra("%MTRACK", getSongName());
// Pebble intent
sendBroadcast(pebbleIntent);
} else {
if (currentSong != null) {
currentSong.setPaused();
}
// Last.fm scrobbler intent
scrobbleBroadcast(Status.PAUSE, currentSong);
// Tasker intent
taskerIntent.putExtra("%MTRACK", "");
}
sendBroadcast(taskerIntent);
} else if (what.equals(InternalIntents.META_CHANGED)) {
if (currentSong != null) {
currentSong.setStartTime();
}
// Tasker intent
taskerIntent.putExtra("%MTRACK", getSongName());
sendBroadcast(taskerIntent);
// Bluetooth intent
getExtras(fromUser).subscribeOn(Schedulers.io()).subscribe(extras -> {
final Intent intent = new Intent(ExternalIntents.AVRCP_META_CHANGED);
intent.putExtras(extras);
sendBroadcast(intent);
}, error -> LogUtils.logException(TAG, "Error AVRCP meta changed event", error));
// Pebble intent
sendBroadcast(pebbleIntent);
// Last.fm scrobbler intent
scrobbleBroadcast(Status.START, currentSong);
}
if (what.equals(InternalIntents.QUEUE_CHANGED)) {
saveQueue(true);
if (isPlaying()) {
setNextTrack();
}
} else {
saveQueue(false);
}
mWidgetProviderLarge.notifyChange(MusicService.this, what);
mWidgetProviderMedium.notifyChange(MusicService.this, what);
mWidgetProviderSmall.notifyChange(MusicService.this, what);
mWidgetProviderExtraLarge.notifyChange(MusicService.this, what);
}
use of com.simplecity.amp_library.model.Album in project Shuttle by timusus.
the class ArtworkUtils method getAllFolderArtwork.
/**
* Searches the parent directory of the passed in path for [cover/album/artwork].[png/jpg/jpeg]
* using regex and returns a {@link List<File>} representing the artwork
*/
@WorkerThread
public static List<File> getAllFolderArtwork(@Nullable final String path) {
List<File> fileArray = new ArrayList<>();
if (path != null) {
File[] files;
File parent = new File(path).getParentFile();
if (parent.exists() && parent.isDirectory()) {
final Pattern pattern = Pattern.compile("(folder|cover|album).*\\.(jpg|jpeg|png)", Pattern.CASE_INSENSITIVE);
files = parent.listFiles(file1 -> pattern.matcher(file1.getName()).matches());
if (files.length != 0) {
for (File file : files) {
if (file.exists()) {
fileArray.add(file);
}
}
}
}
}
return fileArray;
}
Aggregations