PageRenderTime 10ms CodeModel.GetById 1ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/config/src/com/google/marvin/config/AppListAdapter.java

http://eyes-free.googlecode.com/
Java | 113 lines | 70 code | 25 blank | 18 comment | 0 complexity | 15450b1ecd99dc9d99c74cc9ff823911 MD5 | raw file
  1package com.google.marvin.config;
  2
  3import java.util.ArrayList;
  4
  5import android.content.Context;
  6import android.database.DataSetObserver;
  7import android.view.View;
  8import android.view.ViewGroup;
  9import android.widget.LinearLayout;
 10import android.widget.ListAdapter;
 11import android.widget.TextView;
 12
 13/**
 14 * ListAdapter for the AppListView that returns the list items as views.
 15 * Each of the list item views are in a two row format, with the top row having
 16 * the title of the app and using a larger sized font than the bottom row which
 17 * contains the description.
 18 * 
 19 * @author clchen@google.com (Charles L. Chen)
 20 */
 21public class AppListAdapter implements ListAdapter {
 22  ArrayList<AppDesc> apps;
 23  Context ctx;
 24  
 25  public AppListAdapter(Context context, ArrayList<AppDesc> appDescs){
 26    ctx = context;
 27    apps = appDescs;
 28  }
 29  
 30
 31  public boolean areAllItemsEnabled() {
 32    // TODO Auto-generated method stub
 33    return false;
 34  }
 35
 36  public boolean isEnabled(int arg0) {
 37    // There are no separators
 38    return true;
 39  }
 40
 41  public int getCount() {
 42    return apps.size();
 43  }
 44
 45  public Object getItem(int arg0) {
 46    // TODO Auto-generated method stub
 47    return null;
 48  }
 49
 50  public long getItemId(int arg0) {
 51    // TODO Auto-generated method stub
 52    return 0;
 53  }
 54
 55  public int getItemViewType(int arg0) {
 56    // TODO Auto-generated method stub
 57    return 0;
 58  }
 59  
 60  public String getPackageName(int arg0) {
 61    AppDesc currentApp = apps.get(arg0);
 62    return currentApp.getPackageName();
 63  }
 64
 65  public View getView(int arg0, View arg1, ViewGroup arg2) {
 66    AppDesc currentApp = apps.get(arg0);
 67    
 68    LinearLayout baseView = new LinearLayout(ctx);
 69
 70    TextView spacerTop = new TextView(ctx);
 71    TextView spacerBottom = new TextView(ctx);
 72    TextView title = new TextView(ctx);
 73    title.setText(currentApp.getTitle());
 74    title.setTextSize(32);
 75    TextView desc = new TextView(ctx);
 76    desc.setText(currentApp.getDescription());
 77    desc.setTextSize(18);
 78
 79    baseView.setOrientation(LinearLayout.VERTICAL);
 80    baseView.addView(spacerTop);
 81    baseView.addView(title);
 82    baseView.addView(desc);
 83    baseView.addView(spacerBottom);
 84
 85    return baseView;
 86  }
 87
 88  public int getViewTypeCount() {
 89    // Return a 1 because there is only one view type
 90    return 1;
 91  }
 92
 93  public boolean hasStableIds() {
 94    // TODO Auto-generated method stub
 95    return false;
 96  }
 97
 98  public boolean isEmpty() {
 99    // TODO Auto-generated method stub
100    return false;
101  }
102
103  public void registerDataSetObserver(DataSetObserver arg0) {
104    // TODO Auto-generated method stub
105    
106  }
107
108  public void unregisterDataSetObserver(DataSetObserver arg0) {
109    // TODO Auto-generated method stub
110    
111  }
112
113}