package com.sometrik.framework;

import java.util.ArrayList;
import java.util.List;

import android.content.Context;
import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.LinearLayout;

public class FWAdapter extends ArrayAdapter<View> {

  private List<View> viewList;
  
  public FWAdapter(Context context, List<View> viewList) {
    super(context, 0, viewList);
    this.viewList = viewList;
  }
  
  public void addItem(View view){
    viewList.add(view);
  }

  @Override
  public int getCount() {
	System.out.println("getCount called with count of: " + viewList.size());
    return viewList.size();
  }

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

  @Override
  public View getView(int position, View convertView, ViewGroup parent) {

	System.out.println("Abina: size: " + viewList.size() + " position: " + position);
    View view;
    if (convertView == null) {  
      System.out.println("creating new abin");
      DisplayMetrics displaymetrics = new DisplayMetrics();
      int dp = (int) TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 35, displaymetrics );
      AbsListView.LayoutParams params = new AbsListView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, 130);
	view = viewList.get(position);
	view.setLayoutParams(params);
    } else {
	System.out.println("recycle abin");
	view = convertView;
    }
    return view;
  }
  
}

@@ -731,82 +731,8 @@
 ) %7B%0A
-%09System.out.println(%22getCount called with count of: %22 + viewList.size());%0A
     
@@ -917,189 +917,8 @@
 ) %7B%0A
-%0A%09System.out.println(%22Abina: size: %22 + viewList.size() + %22 position: %22 + position);%0A    View view;%0A    if (convertView == null) %7B  %0A      System.out.println(%22creating new abin%22);%0A  
     
@@ -971,18 +971,16 @@
 rics();%0A
-  
     int 
@@ -1067,14 +1067,11 @@
 rics
- 
 );%0A
-  
     
@@ -1160,17 +1160,17 @@
 ams.
-MATCH_PAR
+WRAP_CONT
 ENT,
@@ -1176,17 +1176,25 @@
 , 130);%0A
-%09
+    View 
 view = v
@@ -1216,17 +1216,20 @@
 ition);%0A
-%09
+    
 view.set
@@ -1254,85 +1254,8 @@
 s);%0A
-    %7D else %7B%0A%09System.out.println(%22recycle abin%22);%0A%09view = convertView;%0A    %7D%0A
     

Fix adapter changing view on scroll