Search in sources :

Example 1 with LyricsFragment

use of com.simplecity.amp_library.ui.fragments.LyricsFragment in project Shuttle by timusus.

the class PlayerActivity method onOptionsItemSelected.

@Override
public boolean onOptionsItemSelected(MenuItem item) {
    if (item.getItemId() == android.R.id.home) {
        finish();
        return true;
    }
    if (item.getItemId() == R.id.menu_favorite) {
        PlaylistUtils.toggleFavorite(this);
        supportInvalidateOptionsMenu();
        return true;
    }
    if (item.getItemId() == R.id.menu_list) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out, R.anim.abc_fade_in, R.anim.abc_fade_out);
        //Remove the lyrics fragment
        Fragment lyricsFragment = getSupportFragmentManager().findFragmentByTag(LYRICS_FRAGMENT);
        if (lyricsFragment != null) {
            ft.remove(lyricsFragment);
        }
        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.queue_container);
        if (fragment instanceof QueueFragment) {
            ft.remove(getSupportFragmentManager().findFragmentByTag(QUEUE_FRAGMENT));
        } else {
            ft.add(R.id.queue_container, QueueFragment.newInstance(), QUEUE_FRAGMENT);
        }
        ft.commit();
        return true;
    }
    switch(item.getItemId()) {
        case EQUALIZER:
            {
                final Intent equalizerIntent = new Intent(this, EqualizerActivity.class);
                startActivity(equalizerIntent);
                return true;
            }
        case OPTIONS:
            {
                startActivity(new Intent(this, SettingsActivity.class));
                return true;
            }
        case TIMER:
            {
                SleepTimer.createTimer(this, MusicUtils.getTimerActive(), MusicUtils.getTimeRemaining());
                return true;
            }
        case DELETE_ITEM:
            {
                new DialogUtils.DeleteDialogBuilder().context(this).singleMessageId(R.string.delete_song_desc).multipleMessage(R.string.delete_song_desc_multiple).itemNames(Collections.singletonList(MusicUtils.getSongName())).songsToDelete(Observable.just(Collections.singletonList(MusicUtils.getSong()))).build().show();
                return true;
            }
        case NEW_PLAYLIST:
            {
                PlaylistUtils.createPlaylistDialog(this, MusicUtils.getQueue());
                return true;
            }
        case PLAYLIST_SELECTED:
            {
                List<Song> songs = MusicUtils.getQueue();
                Playlist playlist = (Playlist) item.getIntent().getSerializableExtra(ShuttleUtils.ARG_PLAYLIST);
                PlaylistUtils.addToPlaylist(this, playlist, songs);
                return true;
            }
        case CLEAR_QUEUE:
            {
                MusicUtils.clearQueue();
                Intent intent = new Intent(this, MainActivity.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK);
                intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
                startActivity(intent);
                finish();
                return true;
            }
        case TAGGER:
            {
                TaggerDialog.newInstance(MusicUtils.getSong()).show(getSupportFragmentManager());
                return true;
            }
        case VIEW_INFO:
            {
                DialogUtils.showSongInfoDialog(this, MusicUtils.getSong());
                return true;
            }
    }
    if (item.getItemId() == R.id.menu_share) {
        String path = MusicUtils.getFilePath();
        if (!TextUtils.isEmpty(path)) {
            DialogUtils.showShareDialog(PlayerActivity.this, MusicUtils.getSong());
        }
        return true;
    }
    return false;
}
Also used : Playlist(com.simplecity.amp_library.model.Playlist) FragmentTransaction(android.support.v4.app.FragmentTransaction) Intent(android.content.Intent) List(java.util.List) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) LyricsFragment(com.simplecity.amp_library.ui.fragments.LyricsFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment)

Example 2 with LyricsFragment

use of com.simplecity.amp_library.ui.fragments.LyricsFragment in project Shuttle by timusus.

the class PlayerActivity method updateTrackInfo.

public void updateTrackInfo() {
    String totalTime = StringUtils.makeTimeString(this, MusicUtils.getDuration() / 1000);
    String trackName = MusicUtils.getSongName();
    String albumName = MusicUtils.getAlbumName();
    String artistName = MusicUtils.getAlbumArtistName();
    String currentQueuePos = String.valueOf(MusicUtils.getQueuePosition() + 1);
    String queueLength = String.valueOf(MusicUtils.getQueue().size());
    if (totalTime != null && totalTime.length() != 0) {
        mTotalTime.setText(" / " + totalTime);
    }
    if (trackName != null && trackName.length() != 0) {
        mTrack.setText(trackName);
        mTrack.setSelected(true);
    }
    if (albumName != null && artistName != null && albumName.length() != 0 && artistName.length() != 0) {
        if (mArtist == null) {
            mAlbum.setText(artistName + " - " + albumName);
        } else {
            mAlbum.setText(albumName);
            mArtist.setText(artistName);
        }
    }
    mQueuePosition.setText(currentQueuePos + " / " + queueLength);
    queueNextRefresh(1);
    supportInvalidateOptionsMenu();
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_container);
    if (fragment != null && fragment instanceof LyricsFragment) {
        ((LyricsFragment) fragment).updateLyrics();
    }
    Glide.with(this).load(MusicUtils.getAlbumArtist()).diskCacheStrategy(DiskCacheStrategy.ALL).bitmapTransform(new BlurTransformation(this)).override(500, 500).into(mBackgroundImage);
}
Also used : BlurTransformation(com.jp.wasabeef.glide.transformations.BlurTransformation) LyricsFragment(com.simplecity.amp_library.ui.fragments.LyricsFragment) LyricsFragment(com.simplecity.amp_library.ui.fragments.LyricsFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment)

Example 3 with LyricsFragment

use of com.simplecity.amp_library.ui.fragments.LyricsFragment in project Shuttle by timusus.

the class PlayerActivity method toggleLyrics.

public void toggleLyrics() {
    FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
    ft.setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out);
    if (!ShuttleUtils.isTablet()) {
        Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.queue_container);
        if (fragment instanceof LyricsFragment) {
            ft.remove(fragment);
        } else {
            ft.replace(R.id.queue_container, new LyricsFragment(), LYRICS_FRAGMENT);
        }
        ft.commit();
        return;
    }
    Fragment fragment = getSupportFragmentManager().findFragmentById(R.id.main_container);
    if (fragment instanceof LyricsFragment) {
        ft.remove(fragment);
    } else {
        ft.add(R.id.main_container, new LyricsFragment(), LYRICS_FRAGMENT);
    }
    ft.commit();
}
Also used : FragmentTransaction(android.support.v4.app.FragmentTransaction) LyricsFragment(com.simplecity.amp_library.ui.fragments.LyricsFragment) LyricsFragment(com.simplecity.amp_library.ui.fragments.LyricsFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment)

Aggregations

Fragment (android.support.v4.app.Fragment)3 LyricsFragment (com.simplecity.amp_library.ui.fragments.LyricsFragment)3 QueueFragment (com.simplecity.amp_library.ui.fragments.QueueFragment)3 QueuePagerFragment (com.simplecity.amp_library.ui.fragments.QueuePagerFragment)3 FragmentTransaction (android.support.v4.app.FragmentTransaction)2 Intent (android.content.Intent)1 BlurTransformation (com.jp.wasabeef.glide.transformations.BlurTransformation)1 Playlist (com.simplecity.amp_library.model.Playlist)1 List (java.util.List)1