コード例 #1
0
  @Override
  public void onClick(View v) {

    switch (v.getId()) {
      case R.id.bottombar_play:

      case R.id.btn_play:
        if (MediaController.getInstance().getPlayingSongDetail() != null) PlayPauseEvent(v);
        break;

      case R.id.btn_forward:
        if (MediaController.getInstance().getPlayingSongDetail() != null)
          MediaController.getInstance().playNextSong();
        break;

      case R.id.btn_backward:
        if (MediaController.getInstance().getPlayingSongDetail() != null)
          MediaController.getInstance().playPreviousSong();
        break;

      case R.id.btn_suffel:
        break;

      case R.id.btn_toggle:
        break;

      case R.id.bottombar_img_Favorite:
        if (MediaController.getInstance().getPlayingSongDetail() != null) {
          MediaController.getInstance()
              .storeFavoritePlay(
                  context,
                  MediaController.getInstance().getPlayingSongDetail(),
                  v.isSelected() ? 0 : 1);
          v.setSelected(!v.isSelected());
          DMPlayerUtility.animateHeartButton(v);
          findViewById(R.id.like).setSelected(!v.isSelected());
          DMPlayerUtility.animatePhotoLike(findViewById(R.id.big_like), findViewById(R.id.like));
        }
        break;

      default:
        break;
    }
  }
コード例 #2
0
    @Override
    public View getView(final int position, View convertView, ViewGroup parent) {

      ViewHolder mViewHolder;
      if (convertView == null) {
        mViewHolder = new ViewHolder();
        convertView = layoutInflater.inflate(R.layout.item_song, null);
        mViewHolder.song_row = (LinearLayout) convertView.findViewById(R.id.song_row);
        mViewHolder.textViewSongName = (TextView) convertView.findViewById(R.id.song_name);
        mViewHolder.textViewSongArtisNameAndDuration =
            (TextView) convertView.findViewById(R.id.song_details);
        mViewHolder.imageSongThm = (ImageView) convertView.findViewById(R.id.song_icon_art);
        mViewHolder.imagemore = (ImageView) convertView.findViewById(R.id.song_icon_option_more);
        convertView.setTag(mViewHolder);
      } else {
        mViewHolder = (ViewHolder) convertView.getTag();
      }
      SongDetail mDetail = songList.get(position);

      String audioDuration = "";
      try {
        audioDuration = DMPlayerUtility.getAudioDuration(Long.parseLong(mDetail.getDuration()));
      } catch (NumberFormatException e) {
        e.printStackTrace();
      }

      mViewHolder.textViewSongArtisNameAndDuration.setText(
          (audioDuration.isEmpty() ? "" : audioDuration + " | ") + mDetail.getArtist());
      mViewHolder.textViewSongName.setText(mDetail.getTitle());
      String contentURI = "content://media/external/audio/media/" + mDetail.getId() + "/albumart";
      imageLoader.displayImage(contentURI, mViewHolder.imageSongThm, options);

      convertView.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {

              SongDetail mDetail = songList.get(position);
              if (mDetail != null) {
                if (MediaController.getInstance().isPlayingAudio(mDetail)
                    && !MediaController.getInstance().isAudioPaused()) {
                  MediaController.getInstance().pauseAudio(mDetail);
                } else {
                  MediaController.getInstance()
                      .setPlaylist(songList, mDetail, (int) tagFor, (int) id);
                }
              }
            }
          });
      mViewHolder.imagemore.setColorFilter(Color.DKGRAY);
      mViewHolder.imagemore.setImageAlpha(255);

      mViewHolder.imagemore.setOnClickListener(
          new View.OnClickListener() {

            @Override
            public void onClick(View v) {
              try {
                PopupMenu popup = new PopupMenu(context, v);
                popup.getMenuInflater().inflate(R.menu.list_item_option, popup.getMenu());
                popup.show();
                popup.setOnMenuItemClickListener(
                    new PopupMenu.OnMenuItemClickListener() {
                      @Override
                      public boolean onMenuItemClick(MenuItem item) {

                        switch (item.getItemId()) {
                          case R.id.playnext:
                            break;
                          case R.id.addtoque:
                            break;
                          case R.id.addtoplaylist:
                            break;
                          case R.id.gotoartis:
                            break;
                          case R.id.gotoalbum:
                            break;
                          case R.id.delete:
                            break;
                          default:
                            break;
                        }

                        return true;
                      }
                    });
              } catch (Exception e) {
                e.printStackTrace();
              }
            }
          });
      return convertView;
    }
コード例 #3
0
 // Catch  theme changed from settings
 public void theme() {
   sp = getSharedPreferences("VALUES", Context.MODE_PRIVATE);
   int theme = sp.getInt("THEME", 0);
   DMPlayerUtility.settingTheme(context, theme);
 }