From 17f8b2c21c2d8cbbeb200a84fe8fa0f94ab9e8a7 Mon Sep 17 00:00:00 2001
From: Aline Bonnet <aline.bonnet@savoirfairelinux.com>
Date: Thu, 5 Jan 2017 17:21:14 -0500
Subject: [PATCH] smartlist: fix the new quick conversation

When displaying the first notification, a new quick conversation is
displayed on top of the smartlist, above the existing conversation
because it receives a Daemon event that is not for it.

Change-Id: I0114a1da41a9678def20ee9997737599d4015714
Tuleap: #1446
---
 .../src/main/java/cx/ring/fragments/SmartListFragment.java  | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/ring-android/app/src/main/java/cx/ring/fragments/SmartListFragment.java b/ring-android/app/src/main/java/cx/ring/fragments/SmartListFragment.java
index 82a9016e2..2fbd18bc7 100644
--- a/ring-android/app/src/main/java/cx/ring/fragments/SmartListFragment.java
+++ b/ring-android/app/src/main/java/cx/ring/fragments/SmartListFragment.java
@@ -113,6 +113,7 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
     private MenuItem mSearchMenuItem = null;
     private MenuItem mDialpadMenuItem = null;
     private String mLastBlockchainQuery = null;
+    private Boolean isSearching = false;
 
     @BindView(R.id.confs_list)
     ListView mList;
@@ -305,6 +306,7 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
                 displayFloatingActionButtonWithDelay(true, 50);
                 setOverflowMenuVisible(menu, true);
                 setLoading(false);
+                isSearching = false;
                 return true;
             }
 
@@ -314,6 +316,7 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
                 displayFloatingActionButtonWithDelay(false, 0);
                 setOverflowMenuVisible(menu, false);
                 setLoading(false);
+                isSearching = true;
                 return true;
             }
         });
@@ -820,6 +823,9 @@ public class SmartListFragment extends Fragment implements SearchView.OnQueryTex
         }
 
         if (event.getEventType() == DaemonEvent.EventType.REGISTERED_NAME_FOUND) {
+            if (!isSearching) {
+                return;
+            }
             RingApplication.uiHandler.post(new Runnable() {
                 @Override
                 public void run() {
-- 
GitLab