@@ -296,32 +296,28 @@ public void onListItemClick(ListView l, View v, int position, long id) {
296
296
297
297
@ Override
298
298
public void onUrlDeviceDiscoveryUpdate () {
299
+ for (PwPair pwPair : mPwCollection .getGroupedPwPairsSortedByRank (
300
+ new Utils .PwPairRelevanceComparator ())) {
301
+ String groupId = Utils .getGroupId (pwPair .getPwsResult ());
302
+ Log .d (TAG , "groupid to add " + groupId );
303
+ if (mNearbyDeviceAdapter .containsGroupId (groupId )) {
304
+ mNearbyDeviceAdapter .updateItem (pwPair );
305
+ } else if (!mGroupIdQueue .contains (groupId )
306
+ && !Utils .isBlocked (pwPair )) {
307
+ mGroupIdQueue .add (groupId );
308
+ }
309
+ }
310
+
311
+ if (mGroupIdQueue .isEmpty () || !mSecondScanComplete ) {
312
+ return ;
313
+ }
299
314
// Since this callback is given on a background thread and we want
300
315
// to update the list adapter (which can only be done on the UI thread)
301
316
// we have to interact with the adapter on the UI thread.
302
317
new Handler (Looper .getMainLooper ()).post (new Runnable () {
303
318
@ Override
304
319
public void run () {
305
- if (SwipeDismissListViewTouchListener .isLocked ()) {
306
- return ;
307
- }
308
- for (PwPair pwPair : mPwCollection .getGroupedPwPairsSortedByRank (
309
- new Utils .PwPairRelevanceComparator ())) {
310
- String groupId = Utils .getGroupId (pwPair .getPwsResult ());
311
- Log .d (TAG , "groupid to add " + groupId );
312
- if (mNearbyDeviceAdapter .containsGroupId (groupId )) {
313
- mNearbyDeviceAdapter .updateItem (pwPair );
314
- } else if (!mGroupIdQueue .contains (groupId )
315
- && !Utils .isBlocked (pwPair )) {
316
- mGroupIdQueue .add (groupId );
317
- if (mSecondScanComplete ) {
318
- // If we've already waited for the second scan timeout,
319
- // go ahead and put the item in the listview.
320
- emptyGroupIdQueue ();
321
- }
322
- }
323
- }
324
- mNearbyDeviceAdapter .notifyDataSetChanged ();
320
+ emptyGroupIdQueue ();
325
321
}
326
322
});
327
323
}
0 commit comments