From 78fb9e0092ac7ca17fd223f284a51c78e4abd69d Mon Sep 17 00:00:00 2001 From: eehouse Date: Sun, 14 Mar 2010 05:01:13 +0000 Subject: [PATCH] new class that implements those functions in ListAdapter that are always the same or depend on a single count variable. --- .../eehouse/android/xw4/XWListAdapter.java | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListAdapter.java diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListAdapter.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListAdapter.java new file mode 100644 index 000000000..2b3f8f87c --- /dev/null +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/XWListAdapter.java @@ -0,0 +1,30 @@ +/* -*- compile-command: "cd ../../../../../; ant install"; -*- */ + +package org.eehouse.android.xw4; + +import android.app.ListActivity; +import android.widget.ListAdapter; +import android.content.Context; +import android.database.DataSetObserver; + +/** + * Let's see if we can implement a few of these methods just once. + */ +public abstract class XWListAdapter implements ListAdapter { + private int m_count; + + public XWListAdapter( Context context, int count ) { + m_count = count; + } + + public boolean areAllItemsEnabled() { return true; } + public boolean isEnabled( int position ) { return true; } + public int getCount() { return m_count; } + public long getItemId(int position) { return position; } + public int getItemViewType(int position) { return 0; } + public int getViewTypeCount() { return 1; } + public boolean hasStableIds() { return true; } + public boolean isEmpty() { return getCount() == 0; } + public void registerDataSetObserver(DataSetObserver observer) {} + public void unregisterDataSetObserver(DataSetObserver observer) {} +} \ No newline at end of file