From f91017ecadaa80768bcf0440b96327c079e86266 Mon Sep 17 00:00:00 2001 From: Selim Cinek Date: Mon, 14 Mar 2016 12:25:09 -0700 Subject: [PATCH] Decorated custom views now behave better if no custom view is set Bug: 27386952 Change-Id: I40ebd66830b1d0cb124e9a9019c6ead8dcf4d599 --- core/java/android/app/Notification.java | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java index 626d5f93b1152..077c9cc44345c 100644 --- a/core/java/android/app/Notification.java +++ b/core/java/android/app/Notification.java @@ -4571,13 +4571,13 @@ public class Notification implements Parcelable private void buildIntoRemoteViewContent(RemoteViews remoteViews, RemoteViews customContent) { - remoteViews.removeAllViews(R.id.notification_main_column); - // Need to clone customContent before adding, because otherwise it can no longer be - // parceled independently of remoteViews. if (customContent != null) { + // Need to clone customContent before adding, because otherwise it can no longer be + // parceled independently of remoteViews. customContent = customContent.clone(); + remoteViews.removeAllViews(R.id.notification_main_column); + remoteViews.addView(R.id.notification_main_column, customContent); } - remoteViews.addView(R.id.notification_main_column, customContent); // also update the end margin if there is an image int endMargin = mBuilder.mContext.getResources().getDimensionPixelSize( R.dimen.notification_content_margin_end); @@ -4680,13 +4680,13 @@ public class Notification implements Parcelable private RemoteViews buildIntoRemoteView(RemoteViews remoteViews, int id, RemoteViews customContent) { - remoteViews.removeAllViews(id); - // Need to clone customContent before adding, because otherwise it can no longer be - // parceled independently of remoteViews. if (customContent != null) { + // Need to clone customContent before adding, because otherwise it can no longer be + // parceled independently of remoteViews. customContent = customContent.clone(); + remoteViews.removeAllViews(id); + remoteViews.addView(id, customContent); } - remoteViews.addView(id, customContent); return remoteViews; } }