@Override
        public void onClick(View view) {
          switch (view.getId()) {
            case R.id.full_play:
              switch (statePlay) {
                case None:
                  statePlay = StatePlay.Playing;
                  playButton.setImageDrawable(
                      ContextCompat.getDrawable(getContext(), R.mipmap.ic_pause));
                  playAllList(list);
                  break;
                case Playing:
                  statePlay = StatePlay.Paused;
                  playButton.setImageDrawable(
                      ContextCompat.getDrawable(getContext(), R.mipmap.ic_play));
                  if (musicService != null) {
                    musicService.processTogglePlayback();
                  }
                  break;
                case Paused:
                  statePlay = StatePlay.Playing;
                  playButton.setImageDrawable(
                      ContextCompat.getDrawable(getContext(), R.mipmap.ic_pause));
                  if (musicService != null) {
                    musicService.processTogglePlayback();
                  }
                  break;
              }

              break;
          }
        }
  private void playAllList(List<? extends MusicItem> list) {
    if (musicService == null) {
      return;
    }

    musicService.processAllList(list);
  }
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setHasOptionsMenu(true);

    MusicService.bindToMe(getContext(), musicServiceConnection);

    if (getArguments() != null) {
      mParam1 = getArguments().getString(ARG_PARAM1);
      mParam2 = getArguments().getString(ARG_PARAM2);
    }
  }
 @Subscribe
 public void GoFullItemClick(GoFullItemClick goFullItemClick) {
   if (goFullItemClick.isMore) {
     if (mListener != null) {
       mListener.onMore((HelloChaoDaily) goFullItemClick.musicItem);
     }
   } else {
     statePlay = StatePlay.None;
     if (musicService != null) {
       musicService.processAddRequest(goFullItemClick.musicItem);
     }
   }
 }
Example #5
0
 public static void bindToMe(Context context, ServiceConnection musicServiceConnection) {
   context.bindService(
       MusicService.getService(context), musicServiceConnection, Context.BIND_AUTO_CREATE);
 }
 @Override
 public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
   MusicService.LocalBinder localBinder = (MusicService.LocalBinder) iBinder;
   musicService = localBinder.getService();
   musicService.setMusicPlayBackCallback(musicPlayBackCallback);
 }