Skip to content

Commit

Permalink
[FUNC] Throw exception if wrong OnScrollListener
Browse files Browse the repository at this point in the history
  • Loading branch information
Chutaux Robin committed Sep 19, 2014
1 parent f68f90c commit 21cdfea
Showing 1 changed file with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,19 @@ public class ExpandableLayoutListView extends ListView
public ExpandableLayoutListView(Context context)
{
super(context);
setOnScrollListener(new OnExpandableLayoutScoolListener());
setOnScrollListener(new OnExpandableLayoutScrollListener());
}

public ExpandableLayoutListView(Context context, AttributeSet attrs)
{
super(context, attrs);
setOnScrollListener(new OnExpandableLayoutScoolListener());
setOnScrollListener(new OnExpandableLayoutScrollListener());
}

public ExpandableLayoutListView(Context context, AttributeSet attrs, int defStyle)
{
super(context, attrs, defStyle);
setOnScrollListener(new OnExpandableLayoutScoolListener());
setOnScrollListener(new OnExpandableLayoutScrollListener());
}

@Override
Expand Down Expand Up @@ -83,7 +83,16 @@ public boolean performItemClick(View view, int position, long id)
return super.performItemClick(view, position, id);
}

public class OnExpandableLayoutScoolListener implements OnScrollListener
@Override
public void setOnScrollListener(OnScrollListener l)
{
if (!(l instanceof OnExpandableLayoutScrollListener))
throw new IllegalArgumentException("OnScrollListner must be an OnExpandableLayoutScrollListener");

super.setOnScrollListener(l);
}

public class OnExpandableLayoutScrollListener implements OnScrollListener
{
private int scrollState = 0;

Expand Down

0 comments on commit 21cdfea

Please sign in to comment.