@@ -31,6 +31,7 @@ public class ModuleViewListBuilder {
3131 @ NonNull
3232 private String query = "" ;
3333 private boolean noUpdate ;
34+ private int footerPx ;
3435
3536 public ModuleViewListBuilder (Activity activity ) {
3637 this .activity = activity ;
@@ -100,7 +101,8 @@ public void applyTo(RecyclerView moduleList, ModuleViewAdapter moduleViewAdapter
100101 try {
101102 synchronized (this .updateLock ) {
102103 // Build start
103- moduleHolders = new ArrayList <>();
104+ moduleHolders = new ArrayList <>(Math .min (64 ,
105+ this .mappedModuleHolders .size () + 5 ));
104106 int special = 0 ;
105107 Iterator <NotificationType > notificationTypeIterator = this .notifications .iterator ();
106108 while (notificationTypeIterator .hasNext ()) {
@@ -133,6 +135,9 @@ public void applyTo(RecyclerView moduleList, ModuleViewAdapter moduleViewAdapter
133135 }
134136 }
135137 Collections .sort (moduleHolders , ModuleHolder ::compareTo );
138+ if (this .footerPx != 0 ) { // Footer is always last
139+ moduleHolders .add (new ModuleHolder (this .footerPx ));
140+ }
136141 Log .i (TAG , "Got " + moduleHolders .size () + " entries!" );
137142 // Build end
138143 }
@@ -198,10 +203,27 @@ public void refreshNotificationsUI(ModuleViewAdapter moduleViewAdapter) {
198203 }
199204
200205 private boolean matchFilter (ModuleHolder moduleHolder ) {
201- if (this .query .isEmpty ()) return true ;
202206 ModuleInfo moduleInfo = moduleHolder .getMainModuleInfo ();
203- return moduleInfo .id .toLowerCase (Locale .ROOT ).contains (this .query ) ||
204- moduleInfo .name .toLowerCase (Locale .ROOT ).contains (this .query );
207+ String query = this .query ;
208+ String idLw = moduleInfo .id .toLowerCase (Locale .ROOT );
209+ String nameLw = moduleInfo .name .toLowerCase (Locale .ROOT );
210+ String authorLw = moduleInfo .author .toLowerCase (Locale .ROOT );
211+ if (query .isEmpty () || query .equals (idLw ) ||
212+ query .equals (nameLw ) || query .equals (authorLw )) {
213+ moduleHolder .filterLevel = 0 ; // Lower = better
214+ return true ;
215+ }
216+ if (idLw .contains (query ) || nameLw .contains (query )) {
217+ moduleHolder .filterLevel = 1 ;
218+ return true ;
219+ }
220+ if (authorLw .contains (query ) || (moduleInfo .description != null &&
221+ moduleInfo .description .toLowerCase (Locale .ROOT ).contains (query ))) {
222+ moduleHolder .filterLevel = 2 ;
223+ return true ;
224+ }
225+ moduleHolder .filterLevel = 3 ;
226+ return false ;
205227 }
206228
207229 private static void notifySizeChanged (ModuleViewAdapter moduleViewAdapter ,
@@ -242,4 +264,13 @@ public boolean setQueryChange(String query) {
242264 }
243265 return true ;
244266 }
267+
268+ public void setFooterPx (int footerPx ) {
269+ if (this .footerPx != footerPx ) {
270+ synchronized (this .updateLock ) {
271+ this .footerPx = footerPx ;
272+ }
273+ this .noUpdate = false ;
274+ }
275+ }
245276}
0 commit comments