Skip to content

Commit

Permalink
Support FastScroller
Browse files Browse the repository at this point in the history
Make AdapterWrapper extend BaseAdapter because that is what
FastScroller wants.
  • Loading branch information
bauerca committed Feb 28, 2013
1 parent c18d591 commit 545a22a
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ Changelog

* Fix #77: OnClickListener in list item crashes
DragSortController.
* Fix #81: Enabling FastScroller causes crash.

0.6.0
-----
Expand Down
28 changes: 25 additions & 3 deletions demo/res/layout/warp_main.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,26 @@
<?xml version="1.0" encoding="utf-8"?>
<merge>
<include layout="@layout/hetero_main"/>
</merge>
<com.mobeta.android.dslv.DragSortListView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res/com.mobeta.android.demodslv"
android:id="@android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="0dp"
android:paddingBottom="0dp"
android:paddingLeft="10dp"
android:layout_margin="10dp"
android:dividerHeight="5dp"
android:fastScrollEnabled="true"
dslv:drag_enabled="true"
dslv:collapsed_height="2dp"
dslv:drag_scroll_start="0.33"
dslv:max_drag_scroll_speed="0.5"
dslv:float_alpha="0.6"
dslv:slide_shuffle_speed="0.3"
dslv:track_drag_sort="false"
dslv:use_default_controller="true"
dslv:drag_handle_id="@id/drag_handle"
dslv:sort_enabled="true"
dslv:remove_enabled="true"
dslv:drag_start_mode="onDown"
dslv:remove_mode="flingRemove" />
7 changes: 4 additions & 3 deletions library/src/com/mobeta/android/dslv/DragSortListView.java
Original file line number Diff line number Diff line change
Expand Up @@ -602,9 +602,8 @@ public void setMaxScrollSpeed(float max) {
*/
@Override
public void setAdapter(ListAdapter adapter) {
mAdapterWrapper = new AdapterWrapper(adapter);

if (adapter != null) {
mAdapterWrapper = new AdapterWrapper(adapter);
adapter.registerDataSetObserver(mObserver);

if (adapter instanceof DropListener) {
Expand All @@ -616,6 +615,8 @@ public void setAdapter(ListAdapter adapter) {
if (adapter instanceof RemoveListener) {
setRemoveListener((RemoveListener) adapter);
}
} else {
mAdapterWrapper = null;
}

super.setAdapter(mAdapterWrapper);
Expand Down Expand Up @@ -719,7 +720,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 545a22a

Please sign in to comment.