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

Commit 732112e3 authored by Adam Lesinski's avatar Adam Lesinski Committed by android-build-merger
Browse files

Merge "Move the guts of Resources to ResourcesImpl" into nyc-dev

am: c4dd2e7d

* commit 'c4dd2e7d':
  Move the guts of Resources to ResourcesImpl
parents f144fc50 c4dd2e7d
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -108,7 +108,7 @@ public class AnimatorInflater {
            float pathErrorScale) throws NotFoundException {
        final ConfigurationBoundResourceCache<Animator> animatorCache = resources
                .getAnimatorCache();
        Animator animator = animatorCache.getInstance(id, theme);
        Animator animator = animatorCache.getInstance(id, resources, theme);
        if (animator != null) {
            if (DBG_ANIMATOR_INFLATER) {
                Log.d(TAG, "loaded animator from cache, " + resources.getResourceName(id));
@@ -157,7 +157,7 @@ public class AnimatorInflater {
        final ConfigurationBoundResourceCache<StateListAnimator> cache = resources
                .getStateListAnimatorCache();
        final Theme theme = context.getTheme();
        StateListAnimator animator = cache.getInstance(id, theme);
        StateListAnimator animator = cache.getInstance(id, resources, theme);
        if (animator != null) {
            return animator;
        }
+3 −1
Original line number Diff line number Diff line
@@ -23,6 +23,7 @@ import android.content.res.AssetManager;
import android.content.res.CompatibilityInfo;
import android.content.res.Configuration;
import android.content.res.Resources;
import android.content.res.ResourcesImpl;
import android.content.res.ResourcesKey;
import android.hardware.display.DisplayManagerGlobal;
import android.util.ArrayMap;
@@ -250,7 +251,8 @@ public class ResourcesManager {
        } else {
            config = getConfiguration();
        }
        r = new Resources(assets, dm, config, compatInfo, classLoader);
        r = new Resources(classLoader);
        r.setImpl(new ResourcesImpl(assets, dm, config, compatInfo));
        if (DEBUG) Slog.i(TAG, "Created app resources " + resDir + " " + r + ": "
                + r.getConfiguration() + " appScale=" + r.getCompatibilityInfo().applicationScale);

+3 −13
Original line number Diff line number Diff line
@@ -23,29 +23,19 @@ package android.content.res;
 * @hide For internal use only.
 */
public class ConfigurationBoundResourceCache<T> extends ThemedResourceCache<ConstantState<T>> {
    private final Resources mResources;

    /**
     * Creates a cache for the given Resources instance.
     *
     * @param resources the resources to use when creating new instances
     */
    public ConfigurationBoundResourceCache(Resources resources) {
        mResources = resources;
    }

    /**
     * If the resource is cached, creates and returns a new instance of it.
     *
     * @param key a key that uniquely identifies the drawable resource
     * @param resources a Resources object from which to create new instances.
     * @param theme the theme where the resource will be used
     * @return a new instance of the resource, or {@code null} if not in
     *         the cache
     */
    public T getInstance(long key, Resources.Theme theme) {
    public T getInstance(long key, Resources resources, Resources.Theme theme) {
        final ConstantState<T> entry = get(key, theme);
        if (entry != null) {
            return entry.newInstance(mResources, theme);
            return entry.newInstance(resources, theme);
        }

        return null;
+3 −13
Original line number Diff line number Diff line
@@ -22,29 +22,19 @@ import android.graphics.drawable.Drawable;
 * Class which can be used to cache Drawable resources against a theme.
 */
class DrawableCache extends ThemedResourceCache<Drawable.ConstantState> {
    private final Resources mResources;

    /**
     * Creates a cache for the given Resources instance.
     *
     * @param resources the resources to use when creating new instances
     */
    public DrawableCache(Resources resources) {
        mResources = resources;
    }

    /**
     * If the resource is cached, creates and returns a new instance of it.
     *
     * @param key a key that uniquely identifies the drawable resource
     * @param resources a Resources object from which to create new instances.
     * @param theme the theme where the resource will be used
     * @return a new instance of the resource, or {@code null} if not in
     *         the cache
     */
    public Drawable getInstance(long key, Resources.Theme theme) {
    public Drawable getInstance(long key, Resources resources, Resources.Theme theme) {
        final Drawable.ConstantState entry = get(key, theme);
        if (entry != null) {
            return entry.newDrawable(mResources, theme);
            return entry.newDrawable(resources, theme);
        }

        return null;
+221 −1063

File changed.

Preview size limit exceeded, changes collapsed.

Loading