Adding new filter

Ashera provides framework to create predefined event handler in cross platform way.

One of the common requirement in displaying data is to allow user to filter data. RecylerView and ListView in Ashera is extended to add filter method when in we can filter data. By default, filter filters data by matching all data with startsWith the query provided and is case insensitive.

Say for example we need filter which filters data by matching all data with endsWith the query provided and is case insensitive. This can be achieved by creating a custom filter.

Installation

The following are the steps to create new filter:

  • Download a copy of https://github.com/AsheraCordova/Custom.git into the project folder. This project acts as a template for adding custom cross platform functionality.
  • Install the plugin onto the project using command cordova plugin add Custom.
  • Import the project into your favorite ide. e.g. eclipse
  • Sample event handler can be found in the project here
  • After you create your new filter, you need to register it as follows com.ashera.converter.FilterFactory.register(LowerCaseSuffixFilter.class.getName(), new LowerCaseSuffixFilter());
  • To the recycler view, add attribute filterId as follows: filterId="com.ashera.custom.LowerCaseSuffixFilter"
  • Also given that the project is cordova plugin, you need to update plugin.xml and reinstall the plugin for any new functionality to take effect.

Example - RecyclerView with suffix filtering

This example shows how to use custom filters.