Search in sources :

Example 26 with Album

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();
}
Also used : R(com.simplecity.amp_library.R) CompletionListUpdateCallbackAdapter(com.simplecityapps.recycler_adapter.adapter.CompletionListUpdateCallbackAdapter) Bundle(android.os.Bundle) SongView(com.simplecity.amp_library.ui.modelviews.SongView) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) ImageView(android.widget.ImageView) ViewModel(com.simplecityapps.recycler_adapter.model.ViewModel) Random(java.util.Random) Drawable(android.graphics.drawable.Drawable) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) OnClick(butterknife.OnClick) BindView(butterknife.BindView) ColorStateList(android.content.res.ColorStateList) Song(com.simplecity.amp_library.model.Song) Aesthetic(com.afollestad.aesthetic.Aesthetic) Optional(com.annimon.stream.Optional) Priority(com.bumptech.glide.Priority) RequestManager(com.bumptech.glide.RequestManager) HorizontalAlbumView(com.simplecity.amp_library.ui.modelviews.HorizontalAlbumView) MenuUtils(com.simplecity.amp_library.utils.MenuUtils) View(android.view.View) ResourceUtils(com.simplecity.amp_library.utils.ResourceUtils) Schedulers(io.reactivex.schedulers.Schedulers) ViewCompat(android.support.v4.view.ViewCompat) Transition(android.transition.Transition) Unbinder(butterknife.Unbinder) ActionBarUtils(com.simplecity.amp_library.utils.ActionBarUtils) LogUtils(com.simplecity.amp_library.utils.LogUtils) ContextualToolbarHelper(com.simplecity.amp_library.utils.ContextualToolbarHelper) FloatingActionButton(android.support.design.widget.FloatingActionButton) SortManager(com.simplecity.amp_library.utils.SortManager) ObjectAnimator(android.animation.ObjectAnimator) PopupMenu(android.support.v7.widget.PopupMenu) SubMenu(android.view.SubMenu) ArtworkProvider(com.simplecity.amp_library.model.ArtworkProvider) ViewGroup(android.view.ViewGroup) MusicUtils(com.simplecity.amp_library.utils.MusicUtils) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) Disposable(io.reactivex.disposables.Disposable) ContextualToolbarHost(com.simplecity.amp_library.ui.views.ContextualToolbarHost) Nullable(android.support.annotation.Nullable) MaterialDialog(com.afollestad.materialdialogs.MaterialDialog) Album(com.simplecity.amp_library.model.Album) TypefaceManager(com.simplecity.amp_library.utils.TypefaceManager) Stream(com.annimon.stream.Stream) ContextualToolbar(com.simplecity.amp_library.ui.views.ContextualToolbar) RecyclerListener(com.simplecityapps.recycler_adapter.recyclerview.RecyclerListener) ButterKnife(butterknife.ButterKnife) EmptyView(com.simplecity.amp_library.ui.modelviews.EmptyView) DrawerLockManager(com.simplecity.amp_library.ui.drawer.DrawerLockManager) TransitionListenerAdapter(com.simplecity.amp_library.ui.fragments.TransitionListenerAdapter) ViewModelAdapter(com.simplecityapps.recycler_adapter.adapter.ViewModelAdapter) NonNull(android.support.annotation.NonNull) StringUtils(com.simplecity.amp_library.utils.StringUtils) SelectableViewModel(com.simplecity.amp_library.ui.modelviews.SelectableViewModel) Single(io.reactivex.Single) MenuItem(android.view.MenuItem) ArrayList(java.util.ArrayList) AnimationUtils(android.view.animation.AnimationUtils) Toast(android.widget.Toast) DiskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) AnimatorSet(android.animation.AnimatorSet) Observable(io.reactivex.Observable) UpgradeDialog(com.simplecity.amp_library.ui.dialog.UpgradeDialog) PlaceholderProvider(com.simplecity.amp_library.utils.PlaceholderProvider) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) Rx.distinctToMainThread(com.afollestad.aesthetic.Rx.distinctToMainThread) SharedElementCallback(android.support.v4.app.SharedElementCallback) AlwaysCrossFade(com.simplecity.amp_library.glide.utils.AlwaysCrossFade) TaggerDialog(com.simplecity.amp_library.tagger.TaggerDialog) Collectors(com.annimon.stream.Collectors) LayoutInflater(android.view.LayoutInflater) SubheaderView(com.simplecity.amp_library.ui.modelviews.SubheaderView) LinearLayoutManager(android.support.v7.widget.LinearLayoutManager) AlbumView(com.simplecity.amp_library.ui.modelviews.AlbumView) TimeUnit(java.util.concurrent.TimeUnit) RecyclerView(android.support.v7.widget.RecyclerView) CustomCollapsingToolbarLayout(android.support.design.widget.CustomCollapsingToolbarLayout) Glide(com.bumptech.glide.Glide) HorizontalRecyclerView(com.simplecity.amp_library.ui.modelviews.HorizontalRecyclerView) Toolbar(android.support.v7.widget.Toolbar) Pair(android.support.v4.util.Pair) TransitionInflater(android.transition.TransitionInflater) BaseFragment(com.simplecity.amp_library.ui.fragments.BaseFragment) Operators(com.simplecity.amp_library.utils.Operators) Collections(java.util.Collections) PopupMenu(android.support.v7.widget.PopupMenu)

Example 27 with Album

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);
}
Also used : R(com.simplecity.amp_library.R) WidgetProviderSmall(com.simplecity.amp_library.ui.widgets.WidgetProviderSmall) Bundle(android.os.Bundle) WebImage(com.google.android.gms.common.images.WebImage) PackageManager(android.content.pm.PackageManager) CrashlyticsCore(com.crashlytics.android.core.CrashlyticsCore) PlaylistUtils(com.simplecity.amp_library.utils.PlaylistUtils) Completable(io.reactivex.Completable) Uri(android.net.Uri) Random(java.util.Random) PendingIntent(android.app.PendingIntent) MediaSessionCompat(android.support.v4.media.session.MediaSessionCompat) Drawable(android.graphics.drawable.Drawable) AndroidSchedulers(io.reactivex.android.schedulers.AndroidSchedulers) IBinder(android.os.IBinder) WakeLock(android.os.PowerManager.WakeLock) Song(com.simplecity.amp_library.model.Song) Manifest(android.Manifest) SQLiteException(android.database.sqlite.SQLiteException) PowerManager(android.os.PowerManager) MediaMetadataCompat(android.support.v4.media.MediaMetadataCompat) Handler(android.os.Handler) Looper(android.os.Looper) MediaStore(android.provider.MediaStore) Map(java.util.Map) Schedulers(io.reactivex.schedulers.Schedulers) PreferenceManager(android.preference.PreferenceManager) PlaybackStateCompat(android.support.v4.media.session.PlaybackStateCompat) UnsafeAction(com.simplecity.amp_library.rx.UnsafeAction) Log(android.util.Log) WidgetProviderLarge(com.simplecity.amp_library.ui.widgets.WidgetProviderLarge) SimpleTarget(com.bumptech.glide.request.target.SimpleTarget) LogUtils(com.simplecity.amp_library.utils.LogUtils) Service(android.app.Service) IntentFilter(android.content.IntentFilter) ContextCompat(android.support.v4.content.ContextCompat) MediaStatus(com.google.android.gms.cast.MediaStatus) MediaButtonIntentReceiver(com.simplecity.amp_library.utils.MediaButtonIntentReceiver) NoConnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.NoConnectionException) AudioFocusRequest(android.media.AudioFocusRequest) VideoCastManager(com.google.android.libraries.cast.companionlibrary.cast.VideoCastManager) MusicNotificationHelper(com.simplecity.amp_library.notifications.MusicNotificationHelper) BroadcastReceiver(android.content.BroadcastReceiver) SettingsManager(com.simplecity.amp_library.utils.SettingsManager) List(java.util.List) CompositeDisposable(io.reactivex.disposables.CompositeDisposable) WidgetProviderMedium(com.simplecity.amp_library.ui.widgets.WidgetProviderMedium) GlideUtils(com.simplecity.amp_library.glide.utils.GlideUtils) ContentValues(android.content.ContentValues) Nullable(android.support.annotation.Nullable) ConcurrentModificationException(java.util.ConcurrentModificationException) Context(android.content.Context) Album(com.simplecity.amp_library.model.Album) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Intent(android.content.Intent) SystemClock(android.os.SystemClock) NonNull(android.support.annotation.NonNull) Single(io.reactivex.Single) AudioManager(android.media.AudioManager) ApplicationMetadata(com.google.android.gms.cast.ApplicationMetadata) HttpServer(com.simplecity.amp_library.http.HttpServer) ArrayList(java.util.ArrayList) GlideAnimation(com.bumptech.glide.request.animation.GlideAnimation) SuppressLint(android.annotation.SuppressLint) BluetoothHeadset(android.bluetooth.BluetoothHeadset) SleepTimer(com.simplecity.amp_library.utils.SleepTimer) Toast(android.widget.Toast) AudioAttributes(android.media.AudioAttributes) BluetoothA2dp(android.bluetooth.BluetoothA2dp) Equalizer(com.simplecity.amp_library.services.Equalizer) VideoCastConsumerImpl(com.google.android.libraries.cast.companionlibrary.cast.callbacks.VideoCastConsumerImpl) UnsafeConsumer(com.simplecity.amp_library.rx.UnsafeConsumer) PlaceholderProvider(com.simplecity.amp_library.utils.PlaceholderProvider) ShuttleUtils(com.simplecity.amp_library.utils.ShuttleUtils) TransientNetworkDisconnectionException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.TransientNetworkDisconnectionException) AlarmManager(android.app.AlarmManager) WidgetProviderExtraLarge(com.simplecity.amp_library.ui.widgets.WidgetProviderExtraLarge) Action(io.reactivex.functions.Action) ComponentName(android.content.ComponentName) MediaInfo(com.google.android.gms.cast.MediaInfo) TextUtils(android.text.TextUtils) CastException(com.google.android.libraries.cast.companionlibrary.cast.exceptions.CastException) AppWidgetManager(android.appwidget.AppWidgetManager) RemoteControlClient(android.media.RemoteControlClient) Glide(com.bumptech.glide.Glide) SharedPreferences(android.content.SharedPreferences) TreeMap(java.util.TreeMap) HandlerThread(android.os.HandlerThread) Bitmap(android.graphics.Bitmap) Crashlytics(com.crashlytics.android.Crashlytics) DataManager(com.simplecity.amp_library.utils.DataManager) OnAudioFocusChangeListener(android.media.AudioManager.OnAudioFocusChangeListener) Predicate(com.annimon.stream.function.Predicate) MediaMetadata(com.google.android.gms.cast.MediaMetadata) Collections(java.util.Collections) ContentUris(android.content.ContentUris) Song(com.simplecity.amp_library.model.Song) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent)

Example 28 with Album

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;
}
Also used : ReadOnlyFileException(org.jaudiotagger.audio.exceptions.ReadOnlyFileException) CannotReadException(org.jaudiotagger.audio.exceptions.CannotReadException) Album(com.simplecity.amp_library.model.Album) Stream(com.annimon.stream.Stream) Uri(android.net.Uri) NonNull(android.support.annotation.NonNull) ArrayList(java.util.ArrayList) Song(com.simplecity.amp_library.model.Song) AudioFile(org.jaudiotagger.audio.AudioFile) ByteArrayInputStream(java.io.ByteArrayInputStream) MediaStore(android.provider.MediaStore) NoSuchElementException(java.util.NoSuchElementException) Log(android.util.Log) Cursor(android.database.Cursor) IOException(java.io.IOException) Tag(org.jaudiotagger.tag.Tag) FileInputStream(java.io.FileInputStream) WorkerThread(android.support.annotation.WorkerThread) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) ShuttleApplication(com.simplecity.amp_library.ShuttleApplication) List(java.util.List) TagException(org.jaudiotagger.tag.TagException) AudioFileIO(org.jaudiotagger.audio.AudioFileIO) InvalidAudioFrameException(org.jaudiotagger.audio.exceptions.InvalidAudioFrameException) Pattern(java.util.regex.Pattern) Nullable(android.support.annotation.Nullable) ContentUris(android.content.ContentUris) InputStream(java.io.InputStream) Pattern(java.util.regex.Pattern) ArrayList(java.util.ArrayList) AudioFile(org.jaudiotagger.audio.AudioFile) File(java.io.File) WorkerThread(android.support.annotation.WorkerThread)

Aggregations

Album (com.simplecity.amp_library.model.Album)28 Song (com.simplecity.amp_library.model.Song)21 List (java.util.List)19 Stream (com.annimon.stream.Stream)18 AlbumArtist (com.simplecity.amp_library.model.AlbumArtist)18 ArrayList (java.util.ArrayList)18 Collections (java.util.Collections)17 Bundle (android.os.Bundle)16 PopupMenu (android.support.v7.widget.PopupMenu)16 R (com.simplecity.amp_library.R)16 MusicUtils (com.simplecity.amp_library.utils.MusicUtils)16 View (android.view.View)15 Toast (android.widget.Toast)15 RequestManager (com.bumptech.glide.RequestManager)14 Context (android.content.Context)13 LayoutInflater (android.view.LayoutInflater)13 ViewGroup (android.view.ViewGroup)13 Playlist (com.simplecity.amp_library.model.Playlist)13 DataManager (com.simplecity.amp_library.utils.DataManager)13 MenuUtils (com.simplecity.amp_library.utils.MenuUtils)13