Invoke notifySummaryChanged callback only when text changed.

Bug: 32905374
Test: make -j40 RunSettingsRoboTests
Change-Id: I709329d3024656080723383231a884f3cf8a9a43
This commit is contained in:
jackqdyulei
2016-11-15 10:54:50 -08:00
parent 3b4d72721d
commit 882d48fd46
2 changed files with 97 additions and 9 deletions

View File

@@ -25,6 +25,8 @@ import android.os.HandlerThread;
import android.os.Looper;
import android.os.Message;
import android.os.Process;
import android.support.annotation.VisibleForTesting;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.ArraySet;
import android.util.Log;
@@ -141,19 +143,31 @@ public class SummaryLoader {
if (DEBUG) {
Log.d(TAG, "setSummary " + tile.title + " - " + summary);
}
tile.summary = summary;
if (mSummaryConsumer != null) {
mSummaryConsumer.notifySummaryChanged(tile);
} else {
if (DEBUG) {
Log.d(TAG, "SummaryConsumer is null, skipping summary update for "
+ tile.title);
}
}
updateSummaryIfNeeded(tile, summary);
}
});
}
@VisibleForTesting
void updateSummaryIfNeeded(Tile tile, CharSequence summary) {
if (TextUtils.equals(tile.summary, summary)) {
if (DEBUG) {
Log.d(TAG, "Summary doesn't change, skipping summary update for " + tile.title);
}
return;
}
tile.summary = summary;
if (mSummaryConsumer != null) {
mSummaryConsumer.notifySummaryChanged(tile);
} else {
if (DEBUG) {
Log.d(TAG, "SummaryConsumer is null, skipping summary update for "
+ tile.title);
}
}
}
/**
* Only call from the main thread.
*/