Search in sources :

Example 1 with QueuePagerFragment

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

the class MainActivity method onServiceConnected.

@Override
public void onServiceConnected(ComponentName name, IBinder obj) {
    super.onServiceConnected(name, obj);
    supportInvalidateOptionsMenu();
    if (mIsSlidingEnabled) {
        PlayerFragment playerFragment = (PlayerFragment) getSupportFragmentManager().findFragmentById(R.id.player_container);
        if (playerFragment != null) {
            playerFragment.update();
            // If the QueuePagerFragment's adapter is empty, it's because it was created before the service
            // was connected. We need to recreate it now that we know the service is connected.
            Fragment fragment = playerFragment.getChildFragmentManager().findFragmentById(R.id.main_container);
            if (fragment instanceof QueueFragment) {
                ((QueueFragment) fragment).scrollToCurrentItem();
            } else if (fragment instanceof QueuePagerFragment) {
                ((QueuePagerFragment) fragment).resetAdapter();
                ((QueuePagerFragment) fragment).updateQueuePosition();
            }
        }
    }
    handlePendingPlaybackRequest();
    togglePanelVisibility(!(MusicServiceConnectionUtils.sServiceBinder == null || MusicUtils.getSongId() == -1));
}
Also used : QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) FolderFragment(com.simplecity.amp_library.ui.fragments.FolderFragment) Fragment(android.support.v4.app.Fragment) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) PlayerFragment(com.simplecity.amp_library.ui.fragments.PlayerFragment) QueueFragment(com.simplecity.amp_library.ui.fragments.QueueFragment) AlbumArtistFragment(com.simplecity.amp_library.ui.fragments.AlbumArtistFragment) NavigationDrawerFragment(com.simplecity.amp_library.ui.fragments.NavigationDrawerFragment) PlaylistFragment(com.simplecity.amp_library.ui.fragments.PlaylistFragment) GenreFragment(com.simplecity.amp_library.ui.fragments.GenreFragment) DetailFragment(com.simplecity.amp_library.ui.fragments.DetailFragment) SuggestedFragment(com.simplecity.amp_library.ui.fragments.SuggestedFragment) MainFragment(com.simplecity.amp_library.ui.fragments.MainFragment) AlbumFragment(com.simplecity.amp_library.ui.fragments.AlbumFragment) MiniPlayerFragment(com.simplecity.amp_library.ui.fragments.MiniPlayerFragment) PlayerFragment(com.simplecity.amp_library.ui.fragments.PlayerFragment) MiniPlayerFragment(com.simplecity.amp_library.ui.fragments.MiniPlayerFragment)

Example 2 with QueuePagerFragment

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

the class PlayerActivity method onServiceConnected.

@Override
public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
    super.onServiceConnected(componentName, iBinder);
    updateTrackInfo();
    setPauseButtonImage();
    QueuePagerFragment queuePagerFragment = (QueuePagerFragment) getSupportFragmentManager().findFragmentByTag(QUEUE_PAGER_FRAGMENT);
    if (queuePagerFragment != null) {
        queuePagerFragment.resetAdapter();
        queuePagerFragment.updateQueuePosition();
    }
}
Also used : QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment)

Example 3 with QueuePagerFragment

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

the class PlayerActivity method onCreate.

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void onCreate(Bundle savedInstanceState) {
    ThemeUtils.setTheme(this);
    if (!ShuttleUtils.hasLollipop() && ShuttleUtils.hasKitKat()) {
        getWindow().setFlags(FLAG_TRANSLUCENT_STATUS, FLAG_TRANSLUCENT_STATUS);
    }
    if (ShuttleUtils.hasLollipop()) {
        if (!ShuttleUtils.hasKitKat()) {
            getWindow().clearFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
        } else {
            getWindow().getDecorView().setSystemUiVisibility(View.SYSTEM_UI_FLAG_LAYOUT_STABLE | View.SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
            getWindow().setStatusBarColor(Color.TRANSPARENT);
        }
    }
    if (SettingsManager.getInstance().canTintNavBar()) {
        getWindow().setNavigationBarColor(ColorUtils.getPrimaryColorDark(this));
    }
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_player);
    mToolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(mToolbar);
    getSupportActionBar().setTitle(null);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);
    ThemeUtils.themeActionBar(this);
    ThemeUtils.themeStatusBar(this, null);
    if (!ShuttleUtils.isTablet() && ShuttleUtils.isLandscape()) {
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(ColorUtils.getPrimaryColor()));
    } else {
        getSupportActionBar().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.parseColor("#20000000")));
    }
    mTimeHandler = new TimeHandler(this);
    mTrack = (TextView) findViewById(R.id.text1);
    mAlbum = (TextView) findViewById(R.id.text2);
    mArtist = (TextView) findViewById(R.id.text3);
    mCurrentTime = (TextView) findViewById(R.id.current_time);
    mTotalTime = (TextView) findViewById(R.id.total_time);
    mQueuePosition = (TextView) findViewById(R.id.queue_position);
    mQueuePosition = (TextView) findViewById(R.id.queue_position);
    mPauseButton = (ImageButton) findViewById(R.id.play);
    mPauseButton.setOnClickListener(this);
    mNextButton = (RepeatingImageButton) findViewById(R.id.next);
    mNextButton.setOnClickListener(this);
    mNextButton.setRepeatListener(mFastForwardListener);
    mPrevButton = (RepeatingImageButton) findViewById(R.id.prev);
    mPrevButton.setOnClickListener(this);
    mPrevButton.setRepeatListener(mRewindListener);
    mRepeatButton = (ImageButton) findViewById(R.id.repeat);
    mRepeatButton.setOnClickListener(this);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffle);
    mShuffleButton.setOnClickListener(this);
    mTextViewContainer = findViewById(R.id.textContainer);
    mButtonContainer = findViewById(R.id.button_container);
    mSeekBar = (SizableSeekBar) findViewById(R.id.seekbar);
    mSeekBar.setMax(1000);
    mSeekBar.setOnSeekBarChangeListener(this);
    mBackgroundImage = (ImageView) findViewById(R.id.background);
    themeUIComponents();
    if (savedInstanceState == null) {
        FragmentTransaction ft = getSupportFragmentManager().beginTransaction();
        ft.setCustomAnimations(R.anim.abc_fade_in, R.anim.abc_fade_out);
        ft.replace(R.id.main_container, new QueuePagerFragment(), QUEUE_PAGER_FRAGMENT);
        if (ShuttleUtils.isTablet()) {
            ft.replace(R.id.queue_container, QueueFragment.newInstance(), QUEUE_FRAGMENT);
        }
        ft.commit();
    }
    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) FragmentTransaction(android.support.v4.app.FragmentTransaction) ColorDrawable(android.graphics.drawable.ColorDrawable) QueuePagerFragment(com.simplecity.amp_library.ui.fragments.QueuePagerFragment) TargetApi(android.annotation.TargetApi)

Aggregations

QueuePagerFragment (com.simplecity.amp_library.ui.fragments.QueuePagerFragment)3 TargetApi (android.annotation.TargetApi)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Fragment (android.support.v4.app.Fragment)1 FragmentTransaction (android.support.v4.app.FragmentTransaction)1 BlurTransformation (com.jp.wasabeef.glide.transformations.BlurTransformation)1 AlbumArtistFragment (com.simplecity.amp_library.ui.fragments.AlbumArtistFragment)1 AlbumFragment (com.simplecity.amp_library.ui.fragments.AlbumFragment)1 DetailFragment (com.simplecity.amp_library.ui.fragments.DetailFragment)1 FolderFragment (com.simplecity.amp_library.ui.fragments.FolderFragment)1 GenreFragment (com.simplecity.amp_library.ui.fragments.GenreFragment)1 MainFragment (com.simplecity.amp_library.ui.fragments.MainFragment)1 MiniPlayerFragment (com.simplecity.amp_library.ui.fragments.MiniPlayerFragment)1 NavigationDrawerFragment (com.simplecity.amp_library.ui.fragments.NavigationDrawerFragment)1 PlayerFragment (com.simplecity.amp_library.ui.fragments.PlayerFragment)1 PlaylistFragment (com.simplecity.amp_library.ui.fragments.PlaylistFragment)1 QueueFragment (com.simplecity.amp_library.ui.fragments.QueueFragment)1 SuggestedFragment (com.simplecity.amp_library.ui.fragments.SuggestedFragment)1