Android Open Source - pi-android-player Image Adapter






From Project

Back to project page pi-android-player.

License

The source code is released under:

Apache License

If you think the Android project pi-android-player 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 edu.ptit.xbmc.adapter;
/*from   www  .j  ava2  s.c om*/
import edu.ptit.xbmc.R;
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;

 
public class ImageAdapter extends BaseAdapter {
    private Context mContext;
 
    // Keep all Images in array
    public Integer[] mThumbIds = {
          R.drawable.allsong,R.drawable.album,R.drawable.artist
          ,R.drawable.setting
    };
    public String[] mLabels = {
            "All Song","Albums","Artists","Settings"
      };
 
    // Constructor
    public ImageAdapter(Context c){
        mContext = c;
    }
 
    @Override
    public int getCount() {
        return mThumbIds.length;
    }
 
    @Override
    public Object getItem(int position) {
        return mThumbIds[position];
    }
 
    @Override
    public long getItemId(int position) {
        return 0;
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
      LayoutInflater inflater = (LayoutInflater) mContext
          .getSystemService(Context.LAYOUT_INFLATER_SERVICE);
     
        View gridView;
     
        if (convertView == null) {
     
          gridView = new View(mContext);
     
          // get layout from mobile.xml
          gridView = inflater.inflate(R.layout.grid_view_cell, null);
     
          // set value into textview
          TextView textView = (TextView) gridView
              .findViewById(R.id.grid_item_label);
          textView.setText(mLabels[position]);
     
          // set image based on selected text
          ImageView imageView = (ImageView) gridView
              .findViewById(R.id.grid_item_image);
     
          String mobile = mLabels[position];
//     /"All Song","Albums","Artists","Settings"
          if (mobile.equals("All Song")) {
            imageView.setImageResource(R.drawable.allsong);
          } else if (mobile.equals("Albums")) {
            imageView.setImageResource(R.drawable.album);
          } else if (mobile.equals("Artists")) {
            imageView.setImageResource(R.drawable.artist);
          } else {
            imageView.setImageResource(R.drawable.setting);
          }
     
        } else {
          gridView = (View) convertView;
        }
     
        return gridView;
    }
 
}




Java Source Code List

.FragmentAlbum.java
.FragmentArtist.java
.MyTabListener.java
.TabListenerForAlbum.java
edu.ptit.xbmc.activities.MainActivity.java
edu.ptit.xbmc.adapter.AllAlbumAdapter.java
edu.ptit.xbmc.adapter.AllArtistAdapter.java
edu.ptit.xbmc.adapter.AllSongAdapter2.java
edu.ptit.xbmc.adapter.ImageAdapter.java
edu.ptit.xbmc.fragments.FragmentAlbumDetail.java
edu.ptit.xbmc.fragments.FragmentAlbumList.java
edu.ptit.xbmc.fragments.FragmentAllSong.java
edu.ptit.xbmc.fragments.FragmentArtistDetail.java
edu.ptit.xbmc.fragments.FragmentArtistList.java
edu.ptit.xbmc.fragments.FragmentDirectRemote.java
edu.ptit.xbmc.fragments.FragmentNowPlaying.java
edu.ptit.xbmc.fragments.FragmentSettings.java
edu.ptit.xbmc.model.Album.java
edu.ptit.xbmc.model.Artist.java
edu.ptit.xbmc.model.Settings.java
edu.ptit.xbmc.model.Song.java
edu.ptit.xbmc.sp.Constants.java
edu.ptit.xbmc.sp.SPUtils.java
edu.ptit.xbmc.tablistener.TabListenerForArtist.java
edu.ptit.xbmc.tools.PiConnector.java
edu.ptit.xbmc.tools.Utils.java