Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Filtering in array list Filterable Not cancelling the previous filter

I have seen the filter method documentation which shows that calling the filter cancels all previous non-executed filtering requests and posts a new filtering request that will be executed later.

But the actual callback which i received is some how different.In my implementation it is not cancelling the previous filter request and calls the publishResults() method for the previous search criteria after the recent search criteria .The logs are as follows:

  10-03 17:49:41.781: E/TAG(2150): onTextChanged first Criteria  
  10-03 17:49:41.781: E/TAG(2150): performFiltering first Criteria  
  10-03 17:49:41.961: E/TAG(2150): onTextChanged second Criteria   
  10-03 17:49:41.961: E/TAG(2150): performFiltering second Criteria  
  10-03 17:49:42.195: E/TAG(2150): publishResults second Criteria   
  10-03 17:49:42.219: E/TAG(2150): publishResults first Criteria     
like image 799
prince_sachdeva Avatar asked Nov 01 '22 13:11

prince_sachdeva


1 Answers

You have to use only one single instance of Filter in your adapter to be able to cancel any previous non-executed filtering request. Don't create a new instance of Filter every time getFilter is called.

For example, initialize it on adapter initialization, and just return it from getFilter method.

like image 53
Hussein El Feky Avatar answered Nov 08 '22 09:11

Hussein El Feky