Loading src/com/android/settings/dashboard/DashboardAdapter.java +13 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading src/com/android/settings/dashboard/SummaryLoader.java +9 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } Loading Loading @@ -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); Loading Loading
src/com/android/settings/dashboard/DashboardAdapter.java +13 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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; Loading
src/com/android/settings/dashboard/SummaryLoader.java +9 −3 Original line number Diff line number Diff line Loading @@ -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; Loading @@ -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; Loading Loading @@ -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); } Loading Loading @@ -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); Loading