public abstract class

SliceChildView

extends FrameLayout

 java.lang.Object

↳FrameLayout

↳androidx.slice.widget.SliceChildView

Subclasses:

TemplateView, RowView, MessageView, GridRowView, ShortcutView

Gradle dependencies

compile group: 'androidx.slice', name: 'slice-view', version: '1.1.0-alpha02'

  • groupId: androidx.slice
  • artifactId: slice-view
  • version: 1.1.0-alpha02

Artifact androidx.slice:slice-view:1.1.0-alpha02 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.slice:slice-view com.android.support:slices-view

Overview

Base class for children views of SliceView.

Summary

Fields
protected intmInsetBottom

protected intmInsetEnd

protected intmInsetStart

protected intmInsetTop

protected longmLastUpdated

protected androidx.slice.widget.SliceActionView.SliceActionLoadingListenermLoadingListener

protected intmMode

protected SliceView.OnSliceActionListenermObserver

protected RowStylemRowStyle

protected booleanmShowLastUpdated

protected SliceStylemSliceStyle

protected intmTintColor

protected SliceViewPolicymViewPolicy

Constructors
publicSliceChildView(Context context)

publicSliceChildView(Context context, AttributeSet attributeSet)

Methods
public intgetHiddenItemCount()

public java.util.Set<SliceItem>getLoadingActions()

The set of currently loading actions.

public intgetMode()

public abstract voidresetView()

Called when the view should be reset.

public voidsetActionLoading(SliceItem item)

Indicates that a particular action is being loaded.

public voidsetAllowTwoLines(boolean allowTwoLines)

Sets whether this slice can have 2 lines of subtitle text in the first row.

public voidsetInsets(int l, int t, int r, int b)

Sets the insets (padding) for the slice.

public voidsetLastUpdated(long lastUpdated)

Sets when the content of this view was last updated.

public voidsetLoadingActions(java.util.Set<SliceItem> loadingActions)

Sets the actions that are being loaded.

public voidsetPolicy(SliceViewPolicy policy)

Sets the policy information for this view.

public voidsetShowLastUpdated(boolean showLastUpdated)

Sets whether the last updated time should be displayed.

public voidsetSliceActionListener(SliceView.OnSliceActionListener observer)

Sets the observer to notify when an interaction events occur on the view.

public voidsetSliceActionLoadingListener(androidx.slice.widget.SliceActionView.SliceActionLoadingListener listener)

Sets the listener to notify whenever an action is being loaded.

public voidsetSliceActions(java.util.List<SliceAction> actions)

Sets the slice actions for this view.

public voidsetSliceContent(ListContent content)

Sets the content to display in this slice.

public voidsetSliceItem(SliceContent slice, boolean isHeader, int rowIndex, int rowCount, SliceView.OnSliceActionListener observer)

Called when the slice being displayed in this view is an element of a larger list.

public voidsetStyle(SliceStyle styles, RowStyle rowStyle)

Sets the style information for this view.

public voidsetTint(int tintColor)

Sets a custom color to use for tinting elements like icons for this view.

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

Fields

protected int mMode

protected int mTintColor

protected boolean mShowLastUpdated

protected long mLastUpdated

protected int mInsetStart

protected int mInsetTop

protected int mInsetEnd

protected int mInsetBottom

protected androidx.slice.widget.SliceActionView.SliceActionLoadingListener mLoadingListener

protected SliceStyle mSliceStyle

protected RowStyle mRowStyle

protected SliceViewPolicy mViewPolicy

Constructors

public SliceChildView(Context context)

public SliceChildView(Context context, AttributeSet attributeSet)

Methods

public abstract void resetView()

Called when the view should be reset.

public void setSliceContent(ListContent content)

Sets the content to display in this slice.

public void setInsets(int l, int t, int r, int b)

Sets the insets (padding) for the slice.

public void setSliceItem(SliceContent slice, boolean isHeader, int rowIndex, int rowCount, SliceView.OnSliceActionListener observer)

Called when the slice being displayed in this view is an element of a larger list.

public void setSliceActions(java.util.List<SliceAction> actions)

Sets the slice actions for this view.

public int getMode()

Returns:

the mode of the slice being presented.

public void setTint(int tintColor)

Sets a custom color to use for tinting elements like icons for this view.

public void setShowLastUpdated(boolean showLastUpdated)

Sets whether the last updated time should be displayed.

public void setLastUpdated(long lastUpdated)

Sets when the content of this view was last updated.

public void setSliceActionListener(SliceView.OnSliceActionListener observer)

Sets the observer to notify when an interaction events occur on the view.

public void setSliceActionLoadingListener(androidx.slice.widget.SliceActionView.SliceActionLoadingListener listener)

Sets the listener to notify whenever an action is being loaded.

public void setActionLoading(SliceItem item)

Indicates that a particular action is being loaded.

public void setLoadingActions(java.util.Set<SliceItem> loadingActions)

Sets the actions that are being loaded.

public void setAllowTwoLines(boolean allowTwoLines)

Sets whether this slice can have 2 lines of subtitle text in the first row.

public java.util.Set<SliceItem> getLoadingActions()

The set of currently loading actions.

public void setStyle(SliceStyle styles, RowStyle rowStyle)

Sets the style information for this view.

public void setPolicy(SliceViewPolicy policy)

Sets the policy information for this view.

public int getHiddenItemCount()

Source

/*
 * Copyright 2018 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.slice.widget;

import static androidx.slice.widget.SliceView.MODE_LARGE;

import android.content.Context;
import android.util.AttributeSet;
import android.widget.FrameLayout;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.slice.SliceItem;
import androidx.slice.core.SliceAction;

import java.util.List;
import java.util.Set;

/**
 * Base class for children views of {@link SliceView}.
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
@RequiresApi(19)
public abstract class SliceChildView extends FrameLayout {

    protected SliceView.OnSliceActionListener mObserver;
    protected int mMode;
    protected int mTintColor = -1;
    protected boolean mShowLastUpdated;
    protected long mLastUpdated = -1;
    protected int mInsetStart;
    protected int mInsetTop;
    protected int mInsetEnd;
    protected int mInsetBottom;
    protected SliceActionView.SliceActionLoadingListener mLoadingListener;
    protected SliceStyle mSliceStyle;
    protected RowStyle mRowStyle;
    protected SliceViewPolicy mViewPolicy;

    public SliceChildView(@NonNull Context context) {
        super(context);
    }

    public SliceChildView(Context context, AttributeSet attributeSet) {
        this(context);
    }

    /**
     * Called when the view should be reset.
     */
    public abstract void resetView();

    /**
     * Sets the content to display in this slice.
     */
    public void setSliceContent(ListContent content) {
        // Do nothing
    }

    /**
     * Sets the insets (padding) for the slice.
     */
    public void setInsets(int l, int t, int r, int b) {
        mInsetStart = l;
        mInsetTop = t;
        mInsetEnd = r;
        mInsetBottom = b;
    }

    /**
     * Called when the slice being displayed in this view is an element of a larger list.
     */
    public void setSliceItem(SliceContent slice, boolean isHeader, int rowIndex,
            int rowCount, SliceView.OnSliceActionListener observer) {
        // Do nothing
    }

    /**
     * Sets the slice actions for this view.
     */
    public void setSliceActions(List<SliceAction> actions) {
        // Do nothing
    }

    /**
     * @return the mode of the slice being presented.
     */
    @SliceView.SliceMode
    public int getMode() {
        return mViewPolicy != null ? mViewPolicy.getMode() : MODE_LARGE;
    }

    /**
     * Sets a custom color to use for tinting elements like icons for this view.
     */
    public void setTint(@ColorInt int tintColor) {
        mTintColor = tintColor;
    }

    /**
     * Sets whether the last updated time should be displayed.
     */
    public void setShowLastUpdated(boolean showLastUpdated) {
        mShowLastUpdated = showLastUpdated;
    }

    /**
     * Sets when the content of this view was last updated.
     */
    public void setLastUpdated(long lastUpdated) {
        mLastUpdated = lastUpdated;
    }

    /**
     * Sets the observer to notify when an interaction events occur on the view.
     */
    public void setSliceActionListener(SliceView.OnSliceActionListener observer) {
        mObserver = observer;
    }

    /**
     * Sets the listener to notify whenever an action is being loaded.
     */
    public void setSliceActionLoadingListener(SliceActionView.SliceActionLoadingListener listener) {
        mLoadingListener = listener;
    }

    /**
     * Indicates that a particular action is being loaded.
     */
    public void setActionLoading(SliceItem item) {
    }

    /**
     * Sets the actions that are being loaded.
     */
    public void setLoadingActions(Set<SliceItem> loadingActions) {
    }

    /**
     * Sets whether this slice can have 2 lines of subtitle text in the first row.
     */
    public void setAllowTwoLines(boolean allowTwoLines) {
    }

    /**
     * The set of currently loading actions.
     */
    public Set<SliceItem> getLoadingActions() {
        return null;
    }

    /**
     * Sets the style information for this view.
     */
    public void setStyle(SliceStyle styles, @NonNull RowStyle rowStyle) {
        mSliceStyle = styles;
        mRowStyle = rowStyle;
    }

    /**
     * Sets the policy information for this view.
     */
    public void setPolicy(@Nullable SliceViewPolicy policy) {
        mViewPolicy = policy;
    }

    public int getHiddenItemCount() {
        return 0;
    }
}