Fix Conversation page flickers

In this page, 3 conversation lists are implemented by the
ConversationListPreferenceController, these lists updates its contents
in updateState(), which is after the preference screen view created.
So when the first time this page is showed, animations of added contents
will be shown.

The improvement is when the first time, update the list in the
onCreate(), which is called before view creation, instead of the
updateState().

And also do the same thing for RecentConversationsPreferenceController.

Also, to reduce latency,
1. Because currently there are duplicated calls in
NoConversationsPreferenceController to check whether conversations are
exists or not, by removing the duplicated calls and reuse the result
from other controllers, the latency could be reduced.
2. Currently, there are seperated api calls, the
mBackend.getConversations(false) in AllConversationsPreferenceController
and the mBackend.getConversations(true) in
PriorityConversationsPreferenceController, use one
mBackend.getConversations(false) in ConversationListSettings to improve,
this does not change the behavior because the result is filtered in
matchesFilter() both before and after.
3. Currently, we sort conversations first then filter them, change to
filter first then sort to reduce latency.

Fix: 215073227
Test: visual check & robo tests
Change-Id: I028a7fabbbf64cf5627e6615372282a36eb784e5
This commit is contained in:
Chaohui Wang
2022-05-19 16:27:18 +08:00
parent fa878f2f26
commit bd369cfee5
9 changed files with 220 additions and 291 deletions

View File

@@ -17,26 +17,19 @@
package com.android.settings.notification.app;
import android.content.Context;
import android.os.AsyncTask;
import android.service.notification.ConversationChannelWrapper;
import androidx.preference.Preference;
import androidx.preference.PreferenceCategory;
import com.android.settings.R;
import com.android.settings.notification.NotificationBackend;
import java.util.Collections;
import java.util.List;
public class PriorityConversationsPreferenceController extends
ConversationListPreferenceController {
private static final String KEY = "important_conversations";
private List<ConversationChannelWrapper> mConversations;
public PriorityConversationsPreferenceController(Context context,
NotificationBackend backend) {
public PriorityConversationsPreferenceController(Context context, NotificationBackend backend) {
super(context, backend);
}
@@ -45,11 +38,6 @@ public class PriorityConversationsPreferenceController extends
return KEY;
}
@Override
public boolean isAvailable() {
return true;
}
@Override
Preference getSummaryPreference() {
Preference pref = new Preference(mContext);
@@ -63,14 +51,4 @@ public class PriorityConversationsPreferenceController extends
boolean matchesFilter(ConversationChannelWrapper conversation) {
return conversation.getNotificationChannel().isImportantConversation();
}
@Override
public void updateState(Preference preference) {
PreferenceCategory pref = (PreferenceCategory) preference;
// Load conversations
mConversations = mBackend.getConversations(true).getList();
Collections.sort(mConversations, mConversationComparator);
populateList(mConversations, pref);
}
}