コード例 #1
0
 /** Sets the shuffle button icon based on the current shuffle mode. */
 private void setShuffleButtonIcon() {
   if (mApp.isServiceRunning())
     if (mApp.getService().isShuffleOn() == true) {
       mShuffleButton.setImageResource(R.drawable.shuffle_highlighted);
     } else {
       mShuffleButton.setImageResource(UIElementsHelper.getIcon(mContext, "shuffle"));
     }
   else mShuffleButton.setImageResource(UIElementsHelper.getIcon(mContext, "shuffle"));
 }
コード例 #2
0
 /** Sets the repeat button icon based on the current repeat mode. */
 private void setRepeatButtonIcon() {
   if (mApp.isServiceRunning())
     if (mApp.getService().getRepeatMode() == Common.REPEAT_OFF) {
       mRepeatButton.setImageResource(UIElementsHelper.getIcon(mContext, "repeat"));
     } else if (mApp.getService().getRepeatMode() == Common.REPEAT_PLAYLIST) {
       mRepeatButton.setImageResource(R.drawable.repeat_highlighted);
     } else if (mApp.getService().getRepeatMode() == Common.REPEAT_SONG) {
       mRepeatButton.setImageResource(R.drawable.repeat_song);
     } else if (mApp.getService().getRepeatMode() == Common.A_B_REPEAT) {
       mRepeatButton.setImageResource(R.drawable.repeat_song_range);
     } else mRepeatButton.setImageResource(UIElementsHelper.getIcon(mContext, "repeat"));
 }
コード例 #3
0
        @Override
        public void onClick(View arg0) {
          // Toggle shuffle on/off.
          boolean shuffleOn = mApp.getService().toggleShuffleMode();

          if (shuffleOn) mShuffleButton.setImageResource(R.drawable.shuffle_highlighted);
          else mShuffleButton.setImageResource(UIElementsHelper.getIcon(mContext, "shuffle"));
        }
コード例 #4
0
        @Override
        public void onClick(View arg0) {

          mApp.getService().clearABRepeatRange();
          if (mApp.getService().getRepeatMode() == Common.REPEAT_OFF) {
            mRepeatButton.setImageResource(R.drawable.repeat_highlighted);
            mApp.getService().setRepeatMode(Common.REPEAT_PLAYLIST);

          } else if (mApp.getService().getRepeatMode() == Common.REPEAT_PLAYLIST) {
            mRepeatButton.setImageResource(R.drawable.repeat_song);
            mApp.getService().setRepeatMode(Common.REPEAT_SONG);

          } else {
            mRepeatButton.setImageResource(UIElementsHelper.getIcon(mContext, "repeat"));
            mApp.getService().setRepeatMode(Common.REPEAT_OFF);
          }
        }
コード例 #5
0
 /** Sets the background for the control buttons based on the selected theme. */
 private void setControlButtonsBackground() {
   mControlsLayoutHeader.setBackgroundResource(
       UIElementsHelper.getGridViewCardBackground(mContext));
 }
コード例 #6
0
  @SuppressLint("NewApi")
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    mContext = getApplicationContext();
    mApp = (Common) getApplicationContext();
    mApp.setNowPlayingActivity(this);
    setNowPlayingActivityListener(mApp.getPlaybackKickstarter());

    // Set the UI theme.
    setTheme();

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_now_playing);

    // Set the volume stream for this activity.
    this.setVolumeControlStream(AudioManager.STREAM_MUSIC);

    // Drawer layout.
    if (!mApp.isTabletInLandscape()) {
      mDrawerLayout = (DrawerLayout) findViewById(R.id.main_activity_drawer_root);
      mDrawerParentLayout = (FrameLayout) findViewById(R.id.now_playing_drawer_frame_root);
      mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
      mDrawerLayout.setDrawerListener(mDrawerListener);
      mDrawerLayout.setBackgroundColor(UIElementsHelper.getBackgroundColor(mContext));

    } else {
      mCurrentQueueLayout = (RelativeLayout) findViewById(R.id.queue_drawer);
    }

    // ViewPager.
    mViewPager = (VelocityViewPager) findViewById(R.id.nowPlayingPlaylistPager);

    // Seekbar indicator.
    mSeekbarIndicatorLayoutParent = (RelativeLayout) findViewById(R.id.seekbarIndicatorParent);
    mSeekbarIndicatorLayout = (RelativeLayout) findViewById(R.id.seekbarIndicator);
    mSeekbarIndicatorText = (TextView) findViewById(R.id.seekbarIndicatorText);

    mSeekbarIndicatorLayoutParent.setVisibility(View.GONE);
    mSeekbarIndicatorLayout.setBackgroundResource(
        UIElementsHelper.getGridViewCardBackground(mContext));
    mSeekbarIndicatorText.setTypeface(TypefaceHelper.getTypeface(mContext, "Roboto-Regular"));
    mSeekbarIndicatorText.setTextColor(UIElementsHelper.getThemeBasedTextColor(mContext));

    // Playback Controls.
    mControlsLayoutHeaderParent =
        (RelativeLayout) findViewById(R.id.now_playing_controls_header_parent);
    mControlsLayoutHeader = (RelativeLayout) findViewById(R.id.now_playing_controls_header);
    mPlayPauseButtonBackground = (RelativeLayout) findViewById(R.id.playPauseButtonBackground);
    mPlayPauseButton = (ImageButton) findViewById(R.id.playPauseButton);
    mNextButton = (ImageButton) findViewById(R.id.nextButton);
    mPreviousButton = (ImageButton) findViewById(R.id.previousButton);
    mShuffleButton = (ImageButton) findViewById(R.id.shuffleButton);
    mRepeatButton = (ImageButton) findViewById(R.id.repeatButton);

    // Song info/seekbar elements.
    mSeekbar = (SeekBar) findViewById(R.id.nowPlayingSeekBar);
    mStreamingProgressBar = (ProgressBar) findViewById(R.id.startingStreamProgressBar);
    mStreamingProgressBar.setVisibility(View.GONE);

    try {
      mSeekbar.setThumb(getResources().getDrawable(R.drawable.transparent_drawable));
    } catch (Exception e) {
      e.printStackTrace();
    }

    mPlayPauseButtonBackground.setBackgroundResource(UIElementsHelper.getShadowedCircle(mContext));
    mPlayPauseButton.setImageResource(R.drawable.pause_light);
    mPlayPauseButton.setId(R.drawable.pause_light);
    mNextButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_next"));
    mPreviousButton.setImageResource(UIElementsHelper.getIcon(mContext, "btn_playback_previous"));

    if (mApp.getCurrentTheme() == Common.DARK_THEME) {
      mNextButton.setAlpha(1f);
      mPreviousButton.setAlpha(1f);
    }

    // KitKat specific layout code.
    setKitKatTranslucentBars();

    // Set the control buttons and background.
    setControlButtonsBackground();
    setPlayPauseButton();
    setShuffleButtonIcon();
    setRepeatButtonIcon();

    // Set the click listeners.
    mSeekbar.setOnSeekBarChangeListener(seekBarChangeListener);
    mNextButton.setOnClickListener(mOnClickNextListener);
    mPreviousButton.setOnClickListener(mOnClickPreviousListener);
    mPlayPauseButton.setOnClickListener(playPauseClickListener);
    mPlayPauseButtonBackground.setOnClickListener(playPauseClickListener);
    mShuffleButton.setOnClickListener(shuffleButtonClickListener);
    mRepeatButton.setOnClickListener(repeatButtonClickListener);

    // Apply haptic feedback to the play/pause button.
    mPlayPauseButtonBackground.setHapticFeedbackEnabled(true);
    mPlayPauseButton.setHapticFeedbackEnabled(true);
  }