/**
 * Copyright 2008 Joe LaPenna
 */

package com.joelapenna.foursquared.widget;

import com.joelapenna.foursquare.types.Group;
import com.joelapenna.foursquare.types.Venue;
import com.joelapenna.foursquared.FoursquaredSettings;
import com.joelapenna.foursquared.R;
import com.joelapenna.foursquared.util.StringFormatters;

import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

/**
 * @author Joe LaPenna (joe@joelapenna.com)
 */
public class VenueListAdapter extends BaseVenueAdapter {
    private static final String TAG = "VenueListAdapter";
    private static final boolean DEBUG = FoursquaredSettings.DEBUG;

    private LayoutInflater mInflater;

    public VenueListAdapter(Context context, Group venues) {
        super(context, venues);
        mInflater = LayoutInflater.from(context);
    }

    /**
     * Make a view to hold each row.
     *
     * @see android.widget.ListAdapter#getView(int, android.view.View, android.view.ViewGroup)
     */
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        if (DEBUG) Log.d(TAG, "getView() called for position: " + position);
        // A ViewHolder keeps references to children views to avoid unnecessary
        // calls to findViewById() on each row.
        ViewHolder holder;

        // When convertView is not null, we can reuse it directly, there is no
        // need to re-inflate it. We only inflate a new View when the
        // convertView supplied by ListView is null.
        if (convertView == null) {
            convertView = mInflater.inflate(R.layout.venue_list_item, null);

            // Creates a ViewHolder and store references to the two children
            // views we want to bind data to.
            holder = new ViewHolder();
            holder.venueName = (TextView)convertView.findViewById(R.id.venueName);
            holder.locationLine1 = (TextView)convertView.findViewById(R.id.venueLocationLine1);
            holder.locationLine2 = (TextView)convertView.findViewById(R.id.venueLocationLine2);

            convertView.setTag(holder);
        } else {
            // Get the ViewHolder back to get fast access to the TextView
            // and the ImageView.
            holder = (ViewHolder)convertView.getTag();
        }

        Venue venue = (Venue)getItem(position);
        if (DEBUG) Log.d(TAG, "getView() is: " + venue);
        holder.venueName.setText(venue.getName());
        holder.locationLine1.setText(venue.getAddress());
        String line2 = StringFormatters.getVenueLocationCrossStreetOrCity(venue);
        if (line2 == null) {
            holder.locationLine2.setVisibility(View.GONE);
        } else {
            holder.locationLine2.setText(line2);
        }
        if (DEBUG) Log.d(TAG, "Returning: " + convertView);
        return convertView;
    }

    private static class ViewHolder {
        TextView venueName;
        TextView locationLine1;
        TextView locationLine2;
    }
}

@@ -118,24 +118,70 @@
 ypes.Group;%0A
+import com.joelapenna.foursquare.types.Stats;%0A
 import com.j
@@ -214,16 +214,16 @@
 .Venue;%0A
-
 import c
@@ -510,24 +510,57 @@
 .ViewGroup;%0A
+import android.widget.ImageView;%0A
 import andro
@@ -1956,24 +1956,98 @@
 ewHolder();%0A
+            holder.icon = (ImageView)convertView.findViewById(R.id.icon);%0A
             
@@ -2601,56 +2601,425 @@
     
-if (DEBUG) Log.d(TAG, %22getView() is: %22 + venue);
+Stats stats = venue.getStats();%0A        if (stats != null && stats.getBeenhere() != null && stats.getBeenhere().me()) %7B%0A            if (DEBUG) Log.d(TAG, %22Using been here icon%22);%0A            holder.icon.setImageResource(R.drawable.map_marker_blue);%0A        %7D else %7B%0A            if (DEBUG) Log.d(TAG, %22Using never been here icon%22);%0A            holder.icon.setImageResource(R.drawable.map_marker_blue_muted);%0A        %7D%0A
 %0A   
@@ -3120,24 +3120,25 @@
 Address());%0A
+%0A
         Stri
@@ -3462,24 +3462,24 @@
 iew;%0A    %7D%0A%0A
-
     private 
@@ -3500,24 +3500,48 @@
 iewHolder %7B%0A
+        ImageView icon;%0A
         Text

Use different icons for beenthere vs not beenthere.