Android Open Source - audioplayer Organisable Track Adapter






From Project

Back to project page audioplayer.

License

The source code is released under:

GNU General Public License

If you think the Android project audioplayer listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package fr.julien_dumortier.simplemusicplayer.item.itemadapter;
/*from   w  ww  .  ja va2 s  .  com*/
import java.util.List;

import fr.julien_dumortier.simplemusicplayer.MainActivity;
import fr.julien_dumortier.simplemusicplayer.R;
import fr.julien_dumortier.simplemusicplayer.browsemanager.BrowseCover;
import fr.julien_dumortier.simplemusicplayer.item.Track;
import fr.julien_dumortier.simplemusicplayer.item.Item.IOnPictureReady;
import fr.julien_dumortier.simplemusicplayer.playerview.TimeFormater;
import fr.julien_dumortier.simplemusicplayer.playlistview.MultiSelectManager;
import fr.julien_dumortier.simplemusicplayer.service.playlist.IMediaPlayerController;
import fr.julien_dumortier.simplemusicplayer.thememanager.DisplayManager2;
import android.content.Context;
import android.graphics.Color;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class OrganisableTrackAdapter extends BaseAdapter {
  private Context mContext;
  private LayoutInflater mInflater;
  private List<Track> mTracks;
  private CurrentPlayAnimationManager mCurrentPlayAnimationManager;
  private IMediaPlayerController mMediaPlayer;
  private Typeface mFont;
  private MultiSelectManager mMultiSelectManager;
  
  public OrganisableTrackAdapter(MultiSelectManager multiSelectManager, final Context c, List<Track> tracks, final IOnPictureReady listener, IMediaPlayerController mediaPlayer, CurrentPlayAnimationManager currentPlayAnimationManager) {
    mInflater = LayoutInflater.from(c);
    mMultiSelectManager = multiSelectManager;
    mMediaPlayer = mediaPlayer;
    mContext = c;
    mFont = Typeface.createFromAsset(c.getAssets(), MainActivity.ROBOTO_TTF);
    mCurrentPlayAnimationManager = currentPlayAnimationManager;
    mTracks = tracks;    new Thread("thumbnail") { public void run() {
      for(int i =0; i<mTracks.size();i++) {
        Track art = (Track) mTracks.get(i);
        if(art.isDefaultPicture && art.mStringPicture!=null && !art.mStringPicture.equals("")) {
          Drawable dr = BrowseCover.getDrawableFromUri(c, art.mStringPicture, art.getDefaultDrawable());
          if(dr!=null) {
            art.setPicture(dr);
            listener.onPictureReady(art.getPicture(), i);
          }
          art.isDefaultPicture=false;
        }
      }
    }}.start();
  }

  public int getCount() {
    return mTracks.size();
  }

  public Object getItem(int position) {
    return null;
  }
    
  public long getItemId(int position) {
    return 0;
  }

  static int nb;
  
  public View getView(int position, View view, ViewGroup parent) {
    if(view==null || mTracks.get(position) == mMediaPlayer.getCurrentTrack() || Integer.toString(mCurrentPlayAnimationManager.getPos()).equals(view.getTag())) 
    {
      if(DisplayManager2.doUseDarkTextColor(mContext)) {
        view = mInflater.inflate(R.layout.dark_layout_item_track, null);
      }
      else
        view = mInflater.inflate(R.layout.layout_item_track, null);
    }
    ((ImageView)view.findViewById(R.id.img)).setImageDrawable(mTracks.get(position).getPicture());
    ((TextView)view.findViewById(R.id.txt)).setText(mTracks.get(position).getTrackName());
    ((TextView)view.findViewById(R.id.txt)).setTypeface(mFont);
    String duration = TimeFormater.getFormatedTime(mTracks.get(position).getDuration());
    ((TextView)view.findViewById(R.id.duration_and_artist)).setText(duration+" - "+mTracks.get(position).getArtistName());
    ((TextView)view.findViewById(R.id.duration_and_artist)).setTypeface(mFont);
    AbsListView.LayoutParams params = new AbsListView.LayoutParams(AbsListView.LayoutParams.MATCH_PARENT, 135);
    view.setLayoutParams(params);
    if(mTracks.get(position) == mMediaPlayer.getCurrentTrack()) {
      mCurrentPlayAnimationManager.addViewAndstartAnimation(view, position);
      view.setTag(Integer.toString(position));
    }
    if(mMultiSelectManager.isActiveMultiSelect()) {
      if(mMultiSelectManager.contains(position))
        view.setBackgroundColor(Color.rgb(183, 183, 183));
      else
        view.setBackgroundColor(Color.TRANSPARENT);
    } else {
      if(DisplayManager2.getActiveColorAlternate(mContext)) {
        if(DisplayManager2.getNbColumn(mContext)==2) {
          if(nb==0||nb==3) {
            if(DisplayManager2.doUseDarkTextColor(mContext))
              view.setBackgroundColor(-11184811);
            else
              view.setBackgroundColor(-2171170);
          }
          else
            view.setBackgroundColor(Color.TRANSPARENT);
          if(++nb>3)
            nb=0;
        } else {
          if(position%2==0)
            if(DisplayManager2.doUseDarkTextColor(mContext))
              view.setBackgroundColor(-11184811);
            else
              view.setBackgroundColor(-2171170);
          else
            view.setBackgroundColor(Color.TRANSPARENT);
        }
      } else 
        view.setBackgroundColor(Color.TRANSPARENT);
    }
    return view;
  }
}




Java Source Code List

fr.julien_dumortier.simplemusicplayer.DevInfo.java
fr.julien_dumortier.simplemusicplayer.DrawerListAdapter.java
fr.julien_dumortier.simplemusicplayer.IMusicMediaControllerGetter.java
fr.julien_dumortier.simplemusicplayer.MainActivity.java
fr.julien_dumortier.simplemusicplayer.browsemanager.BrowseCover.java
fr.julien_dumortier.simplemusicplayer.browsemanager.BrowseManager.java
fr.julien_dumortier.simplemusicplayer.coveralbumeditor.CoverAlbumEditor.java
fr.julien_dumortier.simplemusicplayer.coveralbumeditor.CoverAlbumGetter.java
fr.julien_dumortier.simplemusicplayer.coveralbumeditor.PromptCovers.java
fr.julien_dumortier.simplemusicplayer.equalizer.EqualizerActivity.java
fr.julien_dumortier.simplemusicplayer.equalizer.EqualizerConfigurationDataBase.java
fr.julien_dumortier.simplemusicplayer.equalizer.VerticalSeekBar.java
fr.julien_dumortier.simplemusicplayer.equalizer.preset.Preset.java
fr.julien_dumortier.simplemusicplayer.item.Album.java
fr.julien_dumortier.simplemusicplayer.item.Artist.java
fr.julien_dumortier.simplemusicplayer.item.Genre.java
fr.julien_dumortier.simplemusicplayer.item.Item.java
fr.julien_dumortier.simplemusicplayer.item.Playlist.java
fr.julien_dumortier.simplemusicplayer.item.Track.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.AlbumAdapter.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.ArtistAdapter.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.CurrentPlayAnimationManager.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.GenreAdapter.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.ItemAdapter.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.ItemClicManager.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.OrganisableTrackAdapter.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.PlayListAdapter.java
fr.julien_dumortier.simplemusicplayer.item.itemadapter.TrackAdapter.java
fr.julien_dumortier.simplemusicplayer.notifynews.NotifyNews.java
fr.julien_dumortier.simplemusicplayer.playerview.FullScreenPlayerViewController.java
fr.julien_dumortier.simplemusicplayer.playerview.IPlayerViewController.java
fr.julien_dumortier.simplemusicplayer.playerview.MiniPlayerViewController.java
fr.julien_dumortier.simplemusicplayer.playerview.TimeFormater.java
fr.julien_dumortier.simplemusicplayer.playlistview.MultiSelectManager.java
fr.julien_dumortier.simplemusicplayer.playlistview.PlayListManagerActivity.java
fr.julien_dumortier.simplemusicplayer.playlistview.SaveManagerView.java
fr.julien_dumortier.simplemusicplayer.playlistview.SavedPlaylistManager.java
fr.julien_dumortier.simplemusicplayer.service.BackgroundBinder.java
fr.julien_dumortier.simplemusicplayer.service.MusicPlayerService.java
fr.julien_dumortier.simplemusicplayer.service.bluetoohactionmanager.BluetoothReceiver.java
fr.julien_dumortier.simplemusicplayer.service.notificationplayer.NotificationManagerService.java
fr.julien_dumortier.simplemusicplayer.service.notificationplayer.NotificationPlayer.java
fr.julien_dumortier.simplemusicplayer.service.phonestatemanager.PhoneCallStateManager.java
fr.julien_dumortier.simplemusicplayer.service.playlist.EndOfPlayListException.java
fr.julien_dumortier.simplemusicplayer.service.playlist.IMediaPlayerController.java
fr.julien_dumortier.simplemusicplayer.service.playlist.MusicMediaPlayer.java
fr.julien_dumortier.simplemusicplayer.service.playlist.PlayListManager.java
fr.julien_dumortier.simplemusicplayer.thememanager.ColorPreferences.java
fr.julien_dumortier.simplemusicplayer.thememanager.DisplayManager2.java
fr.julien_dumortier.simplemusicplayer.thememanager.ManageDisplayView.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptActionByType.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptActionPlaylist.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptConfirmAddInNew.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptConfirmDeletePlaylist.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptConfirmExit.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptConfirmReplacePlaylist.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptDefineCoverAlbum.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptGetTextName.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptMoveTrack.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptPlaylistName.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptShowText.java
fr.julien_dumortier.simplemusicplayer.uiprompt.PromptSuppressConfirm.java
fr.julien_dumortier.simplemusicplayer.widget.AudioPlayerApplication.java
fr.julien_dumortier.simplemusicplayer.widget.AudioPlayerWidgetProvider.java
fr.julien_dumortier.simplemusicplayer.widget.AudioPlayerWidgetViewController.java
fr.julien_dumortier.simplemusicplayer.widget.WidgetView.java