コード例 #1
0
        @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;
          }
        }
コード例 #2
0
  private void playAllList(List<? extends MusicItem> list) {
    if (musicService == null) {
      return;
    }

    musicService.processAllList(list);
  }
コード例 #3
0
  @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);
    }
  }
コード例 #4
0
 @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);
     }
   }
 }
コード例 #5
0
 public static void bindToMe(Context context, ServiceConnection musicServiceConnection) {
   context.bindService(
       MusicService.getService(context), musicServiceConnection, Context.BIND_AUTO_CREATE);
 }
コード例 #6
0
 @Override
 public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
   MusicService.LocalBinder localBinder = (MusicService.LocalBinder) iBinder;
   musicService = localBinder.getService();
   musicService.setMusicPlayBackCallback(musicPlayBackCallback);
 }