jeudi 30 mars 2017

What pattern is this using?

In order to add some behavior into onScroll event of ListView,I added some code by subclass ListView like this:

class MyListView extends ListView{
      public void setOnScrollListener(OnScrollListener listener){
            final OnScrollListener lis = new OnScrollListener(){
            @Override
            public void onScrollStateChanged(AbsListView view, int scrollState) {
                listener.onScrollStateChanged(view, scrollState);
                //below is added behavior of my Listview
                }
            }

        super.setOnScrollListener(lis);
      }
}

and the usage of it is simple:

MyListView myList = new MyListView(...);
myList.setOnScrollListener(new OnScrollListener(){...});//here is the old logic

this sounds like Decorator pattern but it is not, because there is no composite but only inheritance(in facto I do not need composite here).

So the problem is what should I call it?

Aucun commentaire:

Enregistrer un commentaire