diff --git a/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java b/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java index 107aa8beb..f8322f040 100644 --- a/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java +++ b/extensions/robospice-ui-spicelist-parent/robospice-ui-spicelist/src/main/java/com/octo/android/robospice/spicelist/SpiceListView.java @@ -18,6 +18,8 @@ */ public class SpiceListView extends ListView { + private final SpiceListScrollListener onScrollListener = new SpiceListScrollListener(); + // ---------------------------- // --- CONSTRUCTORS // ---------------------------- @@ -43,7 +45,8 @@ public SpiceListView(Context context) { @Override public void setOnScrollListener(OnScrollListener l) { - super.setOnScrollListener(new SpiceListScrollListener(l)); + onScrollListener.setWrappedListener(l); + super.setOnScrollListener(onScrollListener); } @Override @@ -71,7 +74,7 @@ public BaseSpiceArrayAdapter getAdapter() { // --- PRIVATE API // ---------------------------- private void initialize() { - super.setOnScrollListener(new SpiceListScrollListener()); + super.setOnScrollListener(onScrollListener); } // ---------------------------- @@ -79,14 +82,10 @@ private void initialize() { // ---------------------------- private final class SpiceListScrollListener implements OnScrollListener { - private final OnScrollListener wrappedListener; - - public SpiceListScrollListener() { - this.wrappedListener = null; - } + private OnScrollListener wrappedListener; - public SpiceListScrollListener(OnScrollListener wrappedListener) { - this.wrappedListener = wrappedListener; + private void setWrappedListener(OnScrollListener l) { + this.wrappedListener = l; } @Override