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:
@@ -16,32 +16,18 @@
|
||||
|
||||
package com.android.settings.notification.app;
|
||||
|
||||
import android.app.people.IPeopleManager;
|
||||
import android.content.Context;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.RemoteException;
|
||||
import android.service.notification.ConversationChannelWrapper;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
|
||||
import androidx.preference.Preference;
|
||||
import com.android.settingslib.core.AbstractPreferenceController;
|
||||
|
||||
import com.android.settings.R;
|
||||
import com.android.settings.notification.NotificationBackend;
|
||||
import com.android.settingslib.widget.LayoutPreference;
|
||||
class NoConversationsPreferenceController extends AbstractPreferenceController {
|
||||
|
||||
public class NoConversationsPreferenceController extends ConversationListPreferenceController {
|
||||
|
||||
private static String TAG = "NoConversationsPC";
|
||||
private static final String KEY = "no_conversations";
|
||||
|
||||
private IPeopleManager mPs;
|
||||
private int mConversationCount = 0;
|
||||
private boolean mIsAvailable = false;
|
||||
|
||||
public NoConversationsPreferenceController(Context context,
|
||||
NotificationBackend backend, IPeopleManager ps) {
|
||||
super(context, backend);
|
||||
mPs = ps;
|
||||
NoConversationsPreferenceController(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,44 +37,10 @@ public class NoConversationsPreferenceController extends ConversationListPrefere
|
||||
|
||||
@Override
|
||||
public boolean isAvailable() {
|
||||
return true;
|
||||
return mIsAvailable;
|
||||
}
|
||||
|
||||
@Override
|
||||
Preference getSummaryPreference() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
boolean matchesFilter(ConversationChannelWrapper conversation) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateState(Preference preference) {
|
||||
LayoutPreference pref = (LayoutPreference) preference;
|
||||
// Load conversations
|
||||
new AsyncTask<Void, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Void... unused) {
|
||||
mConversationCount = mBackend.getConversations(false).getList().size();
|
||||
try {
|
||||
mConversationCount += mPs.getRecentConversations().getList().size();
|
||||
} catch (RemoteException e) {
|
||||
Log.w(TAG, "Error calling PS", e);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void unused) {
|
||||
if (mContext == null) {
|
||||
return;
|
||||
}
|
||||
pref.findViewById(R.id.onboarding).setVisibility(mConversationCount == 0
|
||||
? View.VISIBLE : View.GONE);
|
||||
preference.setVisible(mConversationCount == 0);
|
||||
}
|
||||
}.execute();
|
||||
void setAvailable(boolean available) {
|
||||
mIsAvailable = available;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user