From 8dd6542b86a102af80ea3ee381cd58fee927f88f Mon Sep 17 00:00:00 2001 From: Barry Li Date: Thu, 23 Jun 2016 19:49:07 -0700 Subject: [PATCH 1/4] ANDROID-711 When Fragment is detached, we nullify messageCenterListAdapter to prevent memory leak. Checking if messageCenterListAdapter is null is a more robust and guarenteed check than either isAdded() or !isDetached() --- .../interaction/fragment/MessageCenterFragment.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java b/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java index 00fc17645..3cee6c2a7 100644 --- a/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java +++ b/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java @@ -658,7 +658,9 @@ public void addNewOutGoingMessageItem(ApptentiveMessage message) { unsendMessagesCount++; isPaused = false; - messageCenterListAdapter.setPaused(isPaused); + if (messageCenterListAdapter != null) { + messageCenterListAdapter.setPaused(isPaused); + } } public void displayNewIncomingMessageItem(ApptentiveMessage message) { @@ -771,7 +773,9 @@ public void restoreSavedAttachmentsToComposer(final List images) { messageCenterListAdapter.setForceShowKeyboard(false); } int firstIndex = messageCenterListView.getFirstVisiblePosition(); - messageCenterListAdapter.notifyDataSetChanged(); + if (messageCenterListAdapter != null) { + messageCenterListAdapter.notifyDataSetChanged(); + } messagingActionHandler.sendMessage(messagingActionHandler.obtainMessage(MSG_SCROLL_FROM_TOP, firstIndex, top)); updateComposingBar(); @@ -892,7 +896,7 @@ public void clearComposingUi(Animator.AnimatorListener al, @Override public void updateComposingBar() { - if (!isDetached()) { + if (messageCenterListAdapter != null) { MessageCenterComposingActionBarView barView = messageCenterListAdapter.getComposingActionBarView(); if (barView != null) { barView.showConfirmation = true; @@ -1574,7 +1578,7 @@ public MessagingActionHandler(MessageCenterFragment fragment) { public void handleMessage(Message msg) { MessageCenterFragment fragment = (MessageCenterFragment) messageCenterFragmentWeakReference.get(); - if (fragment == null || fragment.isDetached()) { + if (fragment == null || !fragment.isAdded() || fragment.messageCenterListAdapter == null) { // Message can be delayed. If so, make sure fragment is still available or still attached to activity return; } From 9f33ac4f092d33c2ce9c53402d7667db788174de Mon Sep 17 00:00:00 2001 From: Barry Li Date: Thu, 23 Jun 2016 19:57:59 -0700 Subject: [PATCH 2/4] ANDROID-711 Drop isAdded() check --- .../interaction/fragment/MessageCenterFragment.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java b/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java index 3cee6c2a7..6b8c20d89 100644 --- a/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java +++ b/apptentive/src/main/java/com/apptentive/android/sdk/module/engagement/interaction/fragment/MessageCenterFragment.java @@ -1578,8 +1578,11 @@ public MessagingActionHandler(MessageCenterFragment fragment) { public void handleMessage(Message msg) { MessageCenterFragment fragment = (MessageCenterFragment) messageCenterFragmentWeakReference.get(); - if (fragment == null || !fragment.isAdded() || fragment.messageCenterListAdapter == null) { - // Message can be delayed. If so, make sure fragment is still available or still attached to activity + /* Message can be delayed. If so, make sure fragment is still available and attached to activity + * messageCenterListAdapter will always be set null in onDetach(). it's a good indication if + * fragment is attached. + */ + if (fragment == null || fragment.messageCenterListAdapter == null) { return; } switch (msg.what) { From 36a0b0bd8019a98f5de77aa7241d176358ade90f Mon Sep 17 00:00:00 2001 From: Barry Li Date: Fri, 24 Jun 2016 12:12:09 -0700 Subject: [PATCH 3/4] Android-711 3.1.2 release updates --- CHANGELOG.md | 6 ++++++ .../java/com/apptentive/android/sdk/util/Constants.java | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1a1f52385..5e4e013a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 2016-06-24 - 3.1.2 + +#### Bugs Fixed + +* Fix Message Center composing bar exception thrown when the animation was in play after the fragment was detached + # 2016-06-20 - 3.1.1 #### Improvements diff --git a/apptentive/src/main/java/com/apptentive/android/sdk/util/Constants.java b/apptentive/src/main/java/com/apptentive/android/sdk/util/Constants.java index ed06dd96e..32f8e9a62 100644 --- a/apptentive/src/main/java/com/apptentive/android/sdk/util/Constants.java +++ b/apptentive/src/main/java/com/apptentive/android/sdk/util/Constants.java @@ -11,7 +11,7 @@ */ public class Constants { - public static final String APPTENTIVE_SDK_VERSION = "3.1.1"; + public static final String APPTENTIVE_SDK_VERSION = "3.1.2"; public static final int REQUEST_CODE_PHOTO_FROM_SYSTEM_PICKER = 10; From 432096a0364b2dc48ec9c0c9c7e2148b5100030f Mon Sep 17 00:00:00 2001 From: Barry Li Date: Fri, 24 Jun 2016 12:45:39 -0700 Subject: [PATCH 4/4] Update README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e512cad5c..a1bccc44f 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ use your app, to talk to them at the right time, and in the right way. ##### Version history is tracked [here](CHANGELOG.md) -##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|3.1.1|aar) +##### Binary releases are hosted for Maven [here](http://search.maven.org/#artifactdetails|com.apptentive|apptentive-android|3.1.2|aar) #### Reporting Bugs We encourage you to help us find and fix bugs. If you find a bug, please fill in the contributor agreement, then open a [github issue](https://github.com/apptentive/apptentive-android/issues?direction=desc&sort=created&state=open).