Android Open Source - easympsd Music List Adapter






From Project

Back to project page easympsd.

License

The source code is released under:

GNU General Public License

If you think the Android project easympsd 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

/*
Copyright 2014-2015 Francesco Palumbo <franzodev@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.//from  w  w  w.j  a  v a  2 s. c  om

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

package com.franz.easympsd;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

public class MusicListAdapter extends ArrayAdapter<Mp3File> {
  private Mp3File[] mlist;
  private Context cont;
  private int lres_id;
  private LayoutInflater inflater;
  private  MusicItemHolder mholder;
  
  @SuppressLint("NewApi")
  public MusicListAdapter(Context context, int view_res, Mp3File[] music_list) {
    super(context, view_res, music_list);
    
    cont = context;
    lres_id = view_res;
    mlist = music_list;
    
    mholder = new MusicItemHolder();
  }
  
  @SuppressLint("NewApi")
  @Override
  public View getView(int pos, View conv_view, ViewGroup parent) {
    View row = conv_view;
    
    if (row == null) {
      inflater = ((Activity) cont).getLayoutInflater();
      row = inflater.inflate(lres_id, parent, false);
    
      mholder.icon   = (ImageView) row.findViewById(R.id.music_icon);
      mholder.tname  = (TextView)  row.findViewById(R.id.track_name);
      mholder.brinfo = (TextView)  row.findViewById(R.id.bitrate_info);
      
      row.setTag(mholder);
    } else {
      mholder = (MusicItemHolder) row.getTag();
    }
    
    mholder.tname.setText(mlist[pos].getName());
    mholder.brinfo.setText(mlist[pos].getBr());
    
    return row;
  }
  
  public static class MusicItemHolder {
    ImageView icon;
    TextView tname;
    TextView brinfo;
  }
}




Java Source Code List

com.franz.easympsd.MainActivity.java
com.franz.easympsd.Mp3File.java
com.franz.easympsd.MusicListAdapter.java
com.franz.easympsd.MusicReader.java
com.franz.easympsd.Playlist.java