2828import android .widget .TextView ;
2929
3030import com .alfaloop .android .alfabeacon .R ;
31+ import com .alfaloop .android .alfabeacon .fragment .ConnectedFragment ;
3132import com .alfaloop .android .alfabeacon .models .LeBeacon ;
3233
3334import java .text .SimpleDateFormat ;
3435import java .util .ArrayList ;
3536import java .util .List ;
3637
3738public class DeviceAdapter extends RecyclerView .Adapter <DeviceAdapter .MyViewHolder > implements Filterable {
39+ public static final String TAG = DeviceAdapter .class .getSimpleName ();
3840
3941 public interface OnItemClickListener {
4042 void onConnectClick (LeBeacon beacon );
@@ -231,8 +233,8 @@ private class ItemFilter extends Filter {
231233 @ Override
232234 protected FilterResults performFiltering (CharSequence constraint ) {
233235 boolean rssiFilterEnable = false ;
234- int rssiFilterValue = 0 ;
235236 boolean filterStringEnable = false ;
237+ int rssiFilterValue = 0 ;
236238 String filterStringTag = "" ;
237239
238240 final List <LeBeacon > list = mItems ;
@@ -256,6 +258,8 @@ protected FilterResults performFiltering(CharSequence constraint) {
256258 FilterResults results = new FilterResults ();
257259 final ArrayList <LeBeacon > nlist = new ArrayList <LeBeacon >(count );
258260 boolean match = false ;
261+
262+ Log .d (TAG , String .format ("Filter Tag %s" , filterStringTag ));
259263 for (int i = 0 ; i < count ; i ++) {
260264 match = false ;
261265 LeBeacon beacon = list .get (i );
@@ -265,13 +269,36 @@ protected FilterResults performFiltering(CharSequence constraint) {
265269 }
266270 }
267271 if (filterStringEnable ) {
268- String major = String .valueOf (beacon .getiBeacon ().getMajor ());
269- String minor = String .valueOf (beacon .getiBeacon ().getMinor ());
270- String uuid = beacon .getiBeacon ().getUuid ();
272+ if (beacon .getiBeacon () != null ) {
273+ String major = String .valueOf (beacon .getiBeacon ().getMajor ());
274+ String minor = String .valueOf (beacon .getiBeacon ().getMinor ());
275+ String uuid = beacon .getiBeacon ().getUuid ();
276+ Log .d (TAG , String .format ("major:%s minor:%s uuid:%s" , major , minor , uuid ));
277+
278+ if ( major .toUpperCase ().contains (filterStringTag .toUpperCase ()) ||
279+ minor .toUpperCase ().contains (filterStringTag .toUpperCase ()) ||
280+ uuid .toUpperCase ().contains (filterStringTag .toUpperCase ()))
281+ {
282+ match = true ;
283+ }
284+ }
285+
286+ if (beacon .getLineSimpleBeacon () != null ) {
287+ String hwid = String .valueOf (beacon .getLineSimpleBeacon ().getHwid ());
288+ String dm = String .valueOf (beacon .getLineSimpleBeacon ().getDeviceMessage ());
289+ Log .d (TAG , String .format ("hwid:%s dm:%s" , hwid , dm ));
290+ if ( hwid .toUpperCase ().contains (filterStringTag .toUpperCase ()) ||
291+ dm .toUpperCase ().contains (filterStringTag .toUpperCase ())) {
292+ match = true ;
293+ }
294+ }
271295 String macAddress = beacon .getMacAddress ();
272- if ( !major .contains (filterStringTag ) && !minor .contains (filterStringTag ) &&
273- !uuid .contains (filterStringTag ) && !macAddress .contains (filterStringTag ))
274- {
296+ if ( macAddress .toUpperCase ().contains (filterStringTag .toUpperCase ())) {
297+ Log .d (TAG , String .format ("macAddress:%s" , macAddress ));
298+ match = true ;
299+ }
300+
301+ if (!match ) {
275302 continue ;
276303 }
277304 }
0 commit comments