package com.neeplayer;

import android.content.Context;
import android.os.AsyncTask;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import org.json.JSONArray;
import org.json.JSONObject;

import java.io.InputStream;
import java.net.URI;
import java.net.URL;
import java.util.ArrayList;
import java.util.Scanner;

public class ArtistAdapter extends BaseAdapter{

    private ArrayList<Artist> artists;
    private LayoutInflater songInf;
    private ImageLoader imageLoader;

    public ArtistAdapter(Context context, ArrayList<Artist> artists) {
        this.artists = artists;
        songInf= LayoutInflater.from(context);
        ImageLoaderConfiguration config = new ImageLoaderConfiguration.Builder(context).build();
        imageLoader = ImageLoader.getInstance();
        imageLoader.init(config);
    }

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

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

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

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LinearLayout artistLayout = (LinearLayout) songInf.inflate(R.layout.artist, parent, false);

        TextView nameView = (TextView) artistLayout.findViewById(R.id.artist_name);
        TextView descriptionView = (TextView) artistLayout.findViewById(R.id.artist_description);
        ImageView imageView = (ImageView) artistLayout.findViewById(R.id.artist_image);

        Artist artist = artists.get(position);

        nameView.setText(artist.getName());
        descriptionView.setText(String.format("%d albums, %d songs", artist.getNumberOfAlbums(), artist.getNumberOfSongs()));

        imageLoader.displayImage(artist.getImageURL(), imageView);

        artistLayout.setTag(position);

        return artistLayout;
    }

}

@@ -1357,32 +1357,159 @@
 eturn 0;%0A    %7D%0A%0A
+    static class ViewHolder %7B%0A        TextView nameView;%0A        TextView descriptionView;%0A        ImageView imageView;%0A    %7D%0A%0A
     @Override%0A  
@@ -1594,50 +1594,87 @@
     
-LinearLayout artistLayout = (LinearLayout)
+ViewHolder holder;%0A        if (convertView == null) %7B%0A            convertView =
  son
@@ -1719,34 +1719,75 @@
 false);%0A
-%0A
+     
        
- TextView 
+holder = new ViewHolder();%0A%0A            holder.
 nameView
@@ -1796,36 +1796,35 @@
  (TextView) 
-artistLayout
+convertView
 .findViewByI
@@ -1848,33 +1848,35 @@
 e);%0A        
-TextView 
+    holder.
 descriptionV
@@ -1888,36 +1888,35 @@
  (TextView) 
-artistLayout
+convertView
 .findViewByI
@@ -1947,34 +1947,35 @@
 n);%0A        
-ImageView 
+    holder.
 imageView = 
@@ -1986,28 +1986,27 @@
 geView) 
-artistLayout
+convertView
 .findVie
@@ -2028,24 +2028,148 @@
 st_image);%0A%0A
+            convertView.setTag(holder);%0A        %7D else %7B%0A            holder = (ViewHolder) convertView.getTag();%0A        %7D%0A%0A
         Arti
@@ -2212,16 +2212,23 @@
         
+holder.
 nameView
@@ -2263,16 +2263,23 @@
         
+holder.
 descript
@@ -2444,16 +2444,23 @@
 eURL(), 
+holder.
 imageVie
@@ -2476,67 +2476,26 @@
     
-artistLayout.setTag(position);%0A%0A        return artistLayout
+return convertView
 ;%0A  

Implement view holder pattern for ArtistAdapter