Android Open Source - fooplayer-android Tracks Adapter






From Project

Back to project page fooplayer-android.

License

The source code is released under:

GNU General Public License

If you think the Android project fooplayer-android 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 com.mauriciogiordano.fooplayer.adapter;
/*from  w  w w  .j av a2 s.  c  o  m*/
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.mauriciogiordano.fooplayer.R;
import com.mauriciogiordano.fooplayer.database.Artist;
import com.mauriciogiordano.fooplayer.database.Track;

import java.util.List;

/**
 * Created by mauricio on 10/31/14.
 */
public class TracksAdapter extends BaseAdapter {

    private Context context;
    private List<Track> tracks;
    private LayoutInflater inflater;

    public TracksAdapter(Context context, List<Track> tracks) {
        this.context = context;
        this.tracks = tracks;
        this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
    }

    public static class ViewHolder
    {
        public TextView trackName;
        public TextView artistName;
        public ImageView cover;
        public Track track;
    }

    @Override
    public int getCount() {
        return tracks.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int i, View convertView, ViewGroup viewGroup) {

        ViewHolder holder;

        if(convertView == null)
        {
            convertView = inflater.inflate(R.layout.adapter_tracks, null);
            holder = new ViewHolder();

            holder.trackName = (TextView) convertView.findViewById(R.id.track_name);
            holder.artistName = (TextView) convertView.findViewById(R.id.artist_name);

            convertView.setTag(holder);
        }
        else
        {
            holder = (ViewHolder) convertView.getTag();
        }

        holder.track = tracks.get(i);

        holder.trackName.setText(holder.track.getName());

        Artist artist = holder.track.getArtist(context);

        if(artist != null)
            holder.artistName.setText(artist.getName());

        return convertView;
    }
}




Java Source Code List

com.mauriciogiordano.fooplayer.AlbumsActivity.java
com.mauriciogiordano.fooplayer.ApplicationTest.java
com.mauriciogiordano.fooplayer.FooActivity.java
com.mauriciogiordano.fooplayer.TracksActivity.java
com.mauriciogiordano.fooplayer.adapter.AlbumsAdapter.java
com.mauriciogiordano.fooplayer.adapter.ArtistsAdapter.java
com.mauriciogiordano.fooplayer.adapter.TracksAdapter.java
com.mauriciogiordano.fooplayer.config.Constants.java
com.mauriciogiordano.fooplayer.database.Album.java
com.mauriciogiordano.fooplayer.database.Artist.java
com.mauriciogiordano.fooplayer.database.Bean.java
com.mauriciogiordano.fooplayer.database.DatabaseHelper.java
com.mauriciogiordano.fooplayer.database.Track.java
com.mauriciogiordano.fooplayer.fragment.AlbumsFragment.java
com.mauriciogiordano.fooplayer.fragment.ArtistsFragment.java
com.mauriciogiordano.fooplayer.fragment.TracksFragment.java
com.mauriciogiordano.fooplayer.network.Delegate.java
com.mauriciogiordano.fooplayer.network.Endpoints.java
com.mauriciogiordano.fooplayer.network.HttpClientHelper.java
com.mauriciogiordano.fooplayer.network.ImageHelper.java
com.mauriciogiordano.fooplayer.network.Network.java
com.mauriciogiordano.fooplayer.network.YouTubeUtility.java
com.mauriciogiordano.fooplayer.view.TextView.java