From 05f20f44f25a9436d4d198bc48996736420d75ab Mon Sep 17 00:00:00 2001 From: Julia Reynolds Date: Mon, 24 May 2021 09:02:24 -0400 Subject: [PATCH] Improve entrance animations on convo page By moving loading in each controller to the same thread. There will still be shifting as the conversation prefs are added, but it won't be the over thte top shift up and shift down motion that existed prior to this cl. Test: manual Fixes: 188734400 Change-Id: I202981b603b8f9308b2b352a0939182910869cd6 --- res/xml/conversation_list_settings.xml | 4 ++- .../AllConversationsPreferenceController.java | 19 +++----------- .../ConversationListPreferenceController.java | 4 +-- ...rityConversationsPreferenceController.java | 19 +++----------- ...centConversationsPreferenceController.java | 26 +++++-------------- 5 files changed, 19 insertions(+), 53 deletions(-) diff --git a/res/xml/conversation_list_settings.xml b/res/xml/conversation_list_settings.xml index 040a9687f7c..f61d2016868 100644 --- a/res/xml/conversation_list_settings.xml +++ b/res/xml/conversation_list_settings.xml @@ -29,7 +29,7 @@ @@ -55,6 +56,7 @@ diff --git a/src/com/android/settings/notification/app/AllConversationsPreferenceController.java b/src/com/android/settings/notification/app/AllConversationsPreferenceController.java index 03e321bbae1..f61e167e56d 100644 --- a/src/com/android/settings/notification/app/AllConversationsPreferenceController.java +++ b/src/com/android/settings/notification/app/AllConversationsPreferenceController.java @@ -68,21 +68,10 @@ public class AllConversationsPreferenceController extends ConversationListPrefer public void updateState(Preference preference) { PreferenceCategory pref = (PreferenceCategory) preference; // Load conversations - new AsyncTask() { - @Override - protected Void doInBackground(Void... unused) { - mConversations = mBackend.getConversations(false).getList(); - Collections.sort(mConversations, mConversationComparator); - return null; - } - @Override - protected void onPostExecute(Void unused) { - if (mContext == null) { - return; - } - populateList(mConversations, pref); - } - }.execute(); + mConversations = mBackend.getConversations(false).getList(); + Collections.sort(mConversations, mConversationComparator); + + populateList(mConversations, pref); } } diff --git a/src/com/android/settings/notification/app/ConversationListPreferenceController.java b/src/com/android/settings/notification/app/ConversationListPreferenceController.java index 948a3611cb7..0c4f2274340 100644 --- a/src/com/android/settings/notification/app/ConversationListPreferenceController.java +++ b/src/com/android/settings/notification/app/ConversationListPreferenceController.java @@ -63,7 +63,7 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe protected void populateList(List conversations, PreferenceGroup containerGroup) { - // TODO: if preference has children, compare with newly loaded list + containerGroup.setVisible(false); containerGroup.removeAll(); if (conversations != null) { populateConversations(conversations, containerGroup); @@ -72,11 +72,11 @@ public abstract class ConversationListPreferenceController extends AbstractPrefe if (containerGroup.getPreferenceCount() == 0) { containerGroup.setVisible(false); } else { - containerGroup.setVisible(true); Preference summaryPref = getSummaryPreference(); if (summaryPref != null) { containerGroup.addPreference(summaryPref); } + containerGroup.setVisible(true); } } diff --git a/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java b/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java index 5533912d85b..3888a0ac7ed 100644 --- a/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java +++ b/src/com/android/settings/notification/app/PriorityConversationsPreferenceController.java @@ -67,22 +67,9 @@ public class PriorityConversationsPreferenceController extends public void updateState(Preference preference) { PreferenceCategory pref = (PreferenceCategory) preference; // Load conversations - new AsyncTask() { - @Override - protected Void doInBackground(Void... unused) { - mConversations = mBackend.getConversations(true).getList(); - Collections.sort(mConversations, mConversationComparator); - return null; - } - - @Override - protected void onPostExecute(Void unused) { - if (mContext == null) { - return; - } - populateList(mConversations, pref); - } - }.execute(); + mConversations = mBackend.getConversations(true).getList(); + Collections.sort(mConversations, mConversationComparator); + populateList(mConversations, pref); } } diff --git a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java index 8bb64e2fd7c..5b2cdb9fe81 100644 --- a/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java +++ b/src/com/android/settings/notification/app/RecentConversationsPreferenceController.java @@ -104,26 +104,14 @@ public class RecentConversationsPreferenceController extends AbstractPreferenceC public void updateState(Preference preference) { PreferenceCategory pref = (PreferenceCategory) preference; // Load conversations - new AsyncTask() { - @Override - protected Void doInBackground(Void... unused) { - try { - mConversations = mPs.getRecentConversations().getList(); - } catch (RemoteException e) { - Slog.w(TAG, "Could get recents", e); - } - Collections.sort(mConversations, mConversationComparator); - return null; - } + try { + mConversations = mPs.getRecentConversations().getList(); + } catch (RemoteException e) { + Slog.w(TAG, "Could get recents", e); + } + Collections.sort(mConversations, mConversationComparator); - @Override - protected void onPostExecute(Void unused) { - if (mContext == null) { - return; - } - populateList(mConversations, pref); - } - }.execute(); + populateList(mConversations, pref); }