Merge "Fix missing summaries" into nyc-dev am: 8143d2a
am: f3a5f79
* commit 'f3a5f7986d41f126d6589296b207285247fb4f8e':
Fix missing summaries
Change-Id: I6dc00e18687f801a23e12204b7627935bbc90e74
This commit is contained in:
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import android.content.ComponentName;
|
||||
import android.content.Context;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.support.v7.widget.PopupMenu;
|
||||
@@ -96,6 +97,18 @@ public class DashboardAdapter extends RecyclerView.Adapter<DashboardAdapter.Dash
|
||||
recountItems();
|
||||
}
|
||||
|
||||
public Tile getTile(ComponentName component) {
|
||||
for (int i = 0; i < mCategories.size(); i++) {
|
||||
for (int j = 0; j < mCategories.get(i).tiles.size(); j++) {
|
||||
Tile tile = mCategories.get(i).tiles.get(j);
|
||||
if (component.equals(tile.intent.getComponent())) {
|
||||
return tile;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public void setCategories(List<DashboardCategory> categories) {
|
||||
mCategories = categories;
|
||||
|
||||
|
@@ -16,6 +16,7 @@
|
||||
package com.android.settings.dashboard;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.ComponentName;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.HandlerThread;
|
||||
@@ -38,7 +39,7 @@ public class SummaryLoader {
|
||||
public static final String SUMMARY_PROVIDER_FACTORY = "SUMMARY_PROVIDER_FACTORY";
|
||||
|
||||
private final Activity mActivity;
|
||||
private final ArrayMap<SummaryProvider, Tile> mSummaryMap = new ArrayMap<>();
|
||||
private final ArrayMap<SummaryProvider, ComponentName> mSummaryMap = new ArrayMap<>();
|
||||
private final List<Tile> mTiles = new ArrayList<>();
|
||||
|
||||
private final Worker mWorker;
|
||||
@@ -74,10 +75,15 @@ public class SummaryLoader {
|
||||
}
|
||||
|
||||
public void setSummary(SummaryProvider provider, final CharSequence summary) {
|
||||
final Tile tile = mSummaryMap.get(provider);
|
||||
final ComponentName component= mSummaryMap.get(provider);
|
||||
mHandler.post(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
// Since tiles are not always cached (like on locale change for instance),
|
||||
// we need to always get the latest one.
|
||||
Tile tile = mAdapter.getTile(component);
|
||||
if (tile == null) return;
|
||||
if (DEBUG) Log.d(TAG, "setSummary " + tile.title + " - " + summary);
|
||||
tile.summary = summary;
|
||||
mAdapter.notifyChanged(tile);
|
||||
}
|
||||
@@ -138,7 +144,7 @@ public class SummaryLoader {
|
||||
SummaryProvider provider = getSummaryProvider(tile);
|
||||
if (provider != null) {
|
||||
if (DEBUG) Log.d(TAG, "Creating " + tile);
|
||||
mSummaryMap.put(provider, tile);
|
||||
mSummaryMap.put(provider, tile.intent.getComponent());
|
||||
if (mListening) {
|
||||
// If we are somehow already listening, put the provider in that state.
|
||||
provider.setListening(true);
|
||||
|
Reference in New Issue
Block a user