[jitsi-commits] master: Fixes issue with first incoming message not being included in chat history if we have chat screen visible(phone). Fixes chat not being displayed on incoming message notification click(tablet). (e1a652b)

pawel.domas at jitsi.org pawel.domas at jitsi.org
Mon Feb 17 17:29:30 CET 2014


Repository : ssh://lists.jitsi.org/jitsi-android

On branch  : master
Link       : https://github.com/jitsi/jitsi-android/compare/228347797ad27b2fbc2d48526689ff756b262717...e1a652bad4a538ced0104665f55b9c7ef62647cc

>---------------------------------------------------------------

commit e1a652bad4a538ced0104665f55b9c7ef62647cc
Author: paweldomas <pawel.domas at jitsi.org>
Date:   Mon Feb 17 13:31:02 2014 +0100

    Fixes issue with first incoming message not being included in chat history if we have chat screen visible(phone). Fixes chat not being displayed on incoming message notification click(tablet).


>---------------------------------------------------------------

e1a652bad4a538ced0104665f55b9c7ef62647cc
 src/org/jitsi/android/gui/Jitsi.java             |    8 +++++++
 src/org/jitsi/android/gui/chat/ChatFragment.java |   26 ++++++++++++++++++----
 2 files changed, 30 insertions(+), 4 deletions(-)

diff --git a/src/org/jitsi/android/gui/Jitsi.java b/src/org/jitsi/android/gui/Jitsi.java
index ed27ca0..3a030ff 100644
--- a/src/org/jitsi/android/gui/Jitsi.java
+++ b/src/org/jitsi/android/gui/Jitsi.java
@@ -144,6 +144,14 @@ public class Jitsi
         this.instanceState = savedInstanceState;
     }
 
+    @Override
+    protected void onPause()
+    {
+        super.onPause();
+
+        instanceState = null;
+    }
+
     /**
      * Decides what should be displayed based on supplied <tt>Intent</tt> and
      * instance state.
diff --git a/src/org/jitsi/android/gui/chat/ChatFragment.java b/src/org/jitsi/android/gui/chat/ChatFragment.java
index 6079140..a562bf6 100644
--- a/src/org/jitsi/android/gui/chat/ChatFragment.java
+++ b/src/org/jitsi/android/gui/chat/ChatFragment.java
@@ -152,6 +152,11 @@ public class ChatFragment
     }
 
     /**
+     * Flag indicates that we have loaded the history for the first time.
+     */
+    private boolean historyLoaded = false;
+
+    /**
      * {@inheritDoc}
      */
     @Override
@@ -232,8 +237,6 @@ public class ChatFragment
 
         chatSession.addMessageListener(chatListAdapter);
 
-        initAdapter();
-
         return content;
     }
 
@@ -277,6 +280,8 @@ public class ChatFragment
             // Also register global status listener
             AndroidGUIActivator.getLoginRenderer()
                     .addGlobalStatusListener(globalStatusListener);
+            // Init the history
+            initAdapter();
         }
         else if(!visibleToUser)
         {
@@ -296,9 +301,22 @@ public class ChatFragment
      */
     private void initAdapter()
     {
-        loadHistoryTask = new LoadHistoryTask(true);
+        /**
+         * Initial history load is delayed until the chat is displayed
+         * to the user. We previously relyed on onCreate, but it will be called
+         * too early on phone layouts where ChatPagerAdapter is used. It creates
+         * ChatFragment too early that is before the first message is added to
+         * the history and we are unable to retrieve it without hacks.
+         */
+        if(!historyLoaded)
+        {
+            loadHistoryTask
+                = new LoadHistoryTask(chatListAdapter.isEmpty());
 
-        loadHistoryTask.execute();
+            loadHistoryTask.execute();
+
+            historyLoaded = true;
+        }
     }
 
     @Override




More information about the commits mailing list