/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

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