Skip to content

Commit

Permalink
Make AdapterWrapper extend BaseAdapter
Browse files Browse the repository at this point in the history
  • Loading branch information
Edward Dale committed Feb 28, 2013
1 parent c5f07d4 commit c18d591
Showing 1 changed file with 59 additions and 4 deletions.
63 changes: 59 additions & 4 deletions library/src/com/mobeta/android/dslv/DragSortListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import android.view.ViewGroup;
import android.widget.AbsListView;
import android.widget.BaseAdapter;
import android.widget.HeaderViewListAdapter;
import android.widget.ListAdapter;
import android.widget.ListView;

Expand Down Expand Up @@ -637,18 +636,74 @@ public ListAdapter getInputAdapter() {
}
}

private class AdapterWrapper extends HeaderViewListAdapter {
private class AdapterWrapper extends BaseAdapter {
private ListAdapter mAdapter;

public AdapterWrapper(ListAdapter adapter) {
super(null, null, adapter);
super();
mAdapter = adapter;

mAdapter.registerDataSetObserver(new DataSetObserver() {
public void onChanged() {
notifyDataSetChanged();
}

public void onInvalidated() {
notifyDataSetInvalidated();
}
});
}

public ListAdapter getAdapter() {
return mAdapter;
}

@Override
public long getItemId(int position) {
return mAdapter.getItemId(position);
}

@Override
public Object getItem(int position) {
return mAdapter.getItem(position);
}

@Override
public int getCount() {
return mAdapter.getCount();
}

@Override
public boolean areAllItemsEnabled() {
return mAdapter.areAllItemsEnabled();
}

@Override
public boolean isEnabled(int position) {
return mAdapter.isEnabled(position);
}

@Override
public int getItemViewType(int position) {
return mAdapter.getItemViewType(position);
}

@Override
public int getViewTypeCount() {
return mAdapter.getViewTypeCount();
}

@Override
public boolean hasStableIds() {
return mAdapter.hasStableIds();
}

@Override
public boolean isEmpty() {
return mAdapter.isEmpty();
}


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

Expand All @@ -664,7 +719,7 @@ public View getView(int position, View convertView, ViewGroup parent) {
if (child != oldChild) {
// shouldn't get here if user is reusing convertViews
// properly
v.removeViewAt(0);
v.removeViewAt(0);
v.addView(child);
}
} else {
Expand Down

0 comments on commit c18d591

Please sign in to comment.