Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8143d2ad authored by Jason Monk's avatar Jason Monk Committed by Android (Google) Code Review
Browse files

Merge "Fix missing summaries" into nyc-dev

parents 6d6ea3fe c0645732
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -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;

+9 −3
Original line number Diff line number Diff line
@@ -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);