public class

StandardResourceAccessors

extends java.lang.Object

 java.lang.Object

↳androidx.wear.tiles.renderer.StandardResourceAccessors

Gradle dependencies

compile group: 'androidx.wear', name: 'wear-tiles-renderer', version: '1.0.0-alpha01'

  • groupId: androidx.wear
  • artifactId: wear-tiles-renderer
  • version: 1.0.0-alpha01

Artifact androidx.wear:wear-tiles-renderer:1.0.0-alpha01 it located at Google repository (https://maven.google.com/)

Overview

Utility class to get ResourceAccessors populated with standard options.

Summary

Methods
public static ResourceAccessors.BuilderforLocalApp(Context appContext, ResourceBuilders.Resources tileResources)

Get a builder pre-populated with accessors for the resources of the app hosting the renderer.

public static ResourceAccessors.BuilderforRemoteService(Context hostAppContext, ResourceBuilders.Resources tileResources, Resources serviceAndroidResources)

Get a builder pre-populated with accessors for the resources of a tile provider service.

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Methods

public static ResourceAccessors.Builder forLocalApp(Context appContext, ResourceBuilders.Resources tileResources)

Get a builder pre-populated with accessors for the resources of the app hosting the renderer.

Use setFooAccessor calls to change the pre-populated ones or add others.

Parameters:

appContext: Context for the app that both owns the resources and displays the layout.
tileResources: Resources for the current layout.

public static ResourceAccessors.Builder forRemoteService(Context hostAppContext, ResourceBuilders.Resources tileResources, Resources serviceAndroidResources)

Get a builder pre-populated with accessors for the resources of a tile provider service.

Use setFooAccessor calls to change the pre-populated ones or add others.

Parameters:

hostAppContext: Context for the app hosting the renderer displaying the layout.
tileResources: Resources for the current layout.
serviceAndroidResources: Android resources from the service.

Source

/*
 * Copyright 2021 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.wear.tiles.renderer;

import android.content.Context;
import android.content.res.Resources;

import androidx.annotation.NonNull;
import androidx.wear.tiles.builders.ResourceBuilders;

/** Utility class to get ResourceAccessors populated with standard options. */
public class StandardResourceAccessors {
    private StandardResourceAccessors() {}

    /**
     * Get a builder pre-populated with accessors for the resources of the app hosting the renderer.
     *
     * <p>Use {@code setFooAccessor} calls to change the pre-populated ones or add others.
     *
     * @param appContext Context for the app that both owns the resources and displays the layout.
     * @param tileResources Resources for the current layout.
     */
    @NonNull
    public static ResourceAccessors.Builder forLocalApp(
            @NonNull Context appContext, @NonNull ResourceBuilders.Resources tileResources) {
        AndroidResourceAccessor androidResourceAccessor =
                new AndroidResourceAccessor(appContext.getResources());
        InlineResourceAccessor inlineResourceAccessor = new InlineResourceAccessor(appContext);
        return ResourceAccessors.builder(tileResources.toProto())
                .setAndroidImageResourceByResIdAccessor(androidResourceAccessor)
                .setInlineImageResourceAccessor(inlineResourceAccessor);
    }

    /**
     * Get a builder pre-populated with accessors for the resources of a tile provider service.
     *
     * <p>Use {@code setFooAccessor} calls to change the pre-populated ones or add others.
     *
     * @param hostAppContext Context for the app hosting the renderer displaying the layout.
     * @param tileResources Resources for the current layout.
     * @param serviceAndroidResources Android resources from the service.
     */
    @NonNull
    public static ResourceAccessors.Builder forRemoteService(
            @NonNull Context hostAppContext,
            @NonNull ResourceBuilders.Resources tileResources,
            @NonNull Resources serviceAndroidResources) {
        AndroidResourceAccessor androidResourceAccessor =
                new AndroidResourceAccessor(serviceAndroidResources);
        InlineResourceAccessor inlineResourceAccessor = new InlineResourceAccessor(hostAppContext);
        return ResourceAccessors.builder(tileResources.toProto())
                .setAndroidImageResourceByResIdAccessor(androidResourceAccessor)
                .setInlineImageResourceAccessor(inlineResourceAccessor);
    }
}