public class

RowStyle

extends java.lang.Object

 java.lang.Object

↳androidx.slice.widget.RowStyle

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

Holds style information shared between child views of a row

Summary

Fields
public static final intUNBOUNDED

Constructors
publicRowStyle(Context context, int resId, SliceStyle sliceStyle)

publicRowStyle(Context context, SliceStyle sliceStyle)

Initializes with default values.

Methods
public intgetActionDividerHeight()

public intgetBottomDividerEndPadding()

public intgetBottomDividerStartPadding()

public intgetContentEndPadding()

public intgetContentStartPadding()

public booleangetDisableRecyclerViewItemAnimator()

public intgetEndItemEndPadding()

public intgetEndItemStartPadding()

public intgetIconSize()

public intgetImageSize()

public intgetProgressBarEndPadding()

public intgetProgressBarInlineWidth()

public intgetProgressBarStartPadding()

public intgetSeekBarInlineWidth()

public intgetSubContentEndPadding()

public intgetSubContentStartPadding()

public intgetSubtitleColor()

public intgetTextActionPadding()

public intgetTintColor()

public intgetTitleColor()

public intgetTitleEndPadding()

public intgetTitleItemEndPadding()

public intgetTitleItemStartPadding()

public intgetTitleStartPadding()

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

Fields

public static final int UNBOUNDED

Constructors

public RowStyle(Context context, SliceStyle sliceStyle)

Initializes with default values.

public RowStyle(Context context, int resId, SliceStyle sliceStyle)

Methods

public int getTitleItemStartPadding()

public int getTitleItemEndPadding()

public int getContentStartPadding()

public int getContentEndPadding()

public int getTitleStartPadding()

public int getTitleEndPadding()

public int getSubContentStartPadding()

public int getSubContentEndPadding()

public int getEndItemStartPadding()

public int getEndItemEndPadding()

public int getBottomDividerStartPadding()

public int getBottomDividerEndPadding()

public int getActionDividerHeight()

public int getSeekBarInlineWidth()

public int getProgressBarInlineWidth()

public int getProgressBarStartPadding()

public int getProgressBarEndPadding()

public int getTextActionPadding()

public int getIconSize()

public boolean getDisableRecyclerViewItemAnimator()

public int getImageSize()

public int getTintColor()

public int getTitleColor()

public int getSubtitleColor()

Source

/*
 * Copyright 2019 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 android.content.Context;
import android.content.res.TypedArray;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import androidx.annotation.RestrictTo;
import androidx.annotation.StyleableRes;
import androidx.slice.view.R;

/**
 * Holds style information shared between child views of a row
 * @hide
 */
@RestrictTo(RestrictTo.Scope.LIBRARY)
@RequiresApi(19)
public class RowStyle {
    public static final int UNBOUNDED = -1;

    private final SliceStyle mSliceStyle;

    private int mTitleItemStartPadding = UNBOUNDED;
    private int mTitleItemEndPadding = UNBOUNDED;
    private int mContentStartPadding = UNBOUNDED;
    private int mContentEndPadding = UNBOUNDED;
    private int mTitleStartPadding = UNBOUNDED;
    private int mTitleEndPadding = UNBOUNDED;
    private int mSubContentStartPadding = UNBOUNDED;
    private int mSubContentEndPadding = UNBOUNDED;
    private int mEndItemStartPadding = UNBOUNDED;
    private int mEndItemEndPadding = UNBOUNDED;
    private int mBottomDividerStartPadding = UNBOUNDED;
    private int mBottomDividerEndPadding = UNBOUNDED;
    private int mActionDividerHeight = UNBOUNDED;
    private int mSeekBarInlineWidth = UNBOUNDED;
    private int mProgressBarInlineWidth = UNBOUNDED;
    private int mProgressBarStartPadding = UNBOUNDED;
    private int mProgressBarEndPadding = UNBOUNDED;
    private int mTextActionPadding  = UNBOUNDED;
    private int mIconSize = UNBOUNDED;
    private boolean mDisableRecyclerViewItemAnimator = false;
    private int mImageSize;

    // The following values override the ones in SliceStyle.
    @Nullable private Integer mTintColor;
    @Nullable private Integer mTitleColor;
    @Nullable private Integer mSubtitleColor;

    /** Initializes with default values. */
    public RowStyle(@NonNull Context context, @NonNull SliceStyle sliceStyle) {
        mSliceStyle = sliceStyle;
        mImageSize = context.getResources().getDimensionPixelSize(
                R.dimen.abc_slice_small_image_size);
    }

    public RowStyle(Context context, int resId, @NonNull SliceStyle sliceStyle) {
        mSliceStyle = sliceStyle;
        TypedArray a = context.getTheme().obtainStyledAttributes(resId, R.styleable.RowStyle);
        try {
            mTitleItemStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_titleItemStartPadding, UNBOUNDED);
            mTitleItemEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_titleItemEndPadding, UNBOUNDED);
            mContentStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_contentStartPadding, UNBOUNDED);
            mContentEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_contentEndPadding, UNBOUNDED);
            mTitleStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_titleStartPadding, UNBOUNDED);
            mTitleEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_titleEndPadding, UNBOUNDED);
            mSubContentStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_subContentStartPadding, UNBOUNDED);
            mSubContentEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_subContentEndPadding, UNBOUNDED);
            mEndItemStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_endItemStartPadding, UNBOUNDED);
            mEndItemEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_endItemEndPadding, UNBOUNDED);
            mBottomDividerStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_bottomDividerStartPadding, UNBOUNDED);
            mBottomDividerEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_bottomDividerEndPadding, UNBOUNDED);
            mActionDividerHeight = (int) a.getDimension(
                    R.styleable.RowStyle_actionDividerHeight, UNBOUNDED);
            mSeekBarInlineWidth = (int) a.getDimension(
                    R.styleable.RowStyle_seekBarInlineWidth, UNBOUNDED);
            mProgressBarInlineWidth = (int) a.getDimension(
                    R.styleable.RowStyle_progressBarInlineWidth, UNBOUNDED);
            mProgressBarStartPadding = (int) a.getDimension(
                    R.styleable.RowStyle_progressBarStartPadding, UNBOUNDED);
            mProgressBarEndPadding = (int) a.getDimension(
                    R.styleable.RowStyle_progressBarEndPadding, UNBOUNDED);
            mTextActionPadding = (int) a.getDimension(
                    R.styleable.RowStyle_textActionPadding, 10);
            mIconSize = (int) a.getDimension(
                    R.styleable.RowStyle_iconSize, UNBOUNDED);
            mDisableRecyclerViewItemAnimator = a.getBoolean(
                    R.styleable.RowStyle_disableRecyclerViewItemAnimator, false);
            mImageSize = (int) a.getDimension(
                    R.styleable.RowStyle_imageSize,
                    context.getResources().getDimensionPixelSize(
                        R.dimen.abc_slice_small_image_size));

            // These override the corresponding styles from SliceView.
            mTintColor = getOptionalColor(a, R.styleable.RowStyle_tintColor);
            mTitleColor = getOptionalColor(a, R.styleable.RowStyle_titleColor);
            mSubtitleColor = getOptionalColor(a, R.styleable.RowStyle_subtitleColor);
        } finally {
            a.recycle();
        }
    }

    public int getTitleItemStartPadding() {
        return mTitleItemStartPadding;
    }

    public int getTitleItemEndPadding() {
        return mTitleItemEndPadding;
    }

    public int getContentStartPadding() {
        return mContentStartPadding;
    }

    public int getContentEndPadding() {
        return mContentEndPadding;
    }

    public int getTitleStartPadding() {
        return mTitleStartPadding;
    }

    public int getTitleEndPadding() {
        return mTitleEndPadding;
    }

    public int getSubContentStartPadding() {
        return mSubContentStartPadding;
    }

    public int getSubContentEndPadding() {
        return mSubContentEndPadding;
    }

    public int getEndItemStartPadding() {
        return mEndItemStartPadding;
    }

    public int getEndItemEndPadding() {
        return mEndItemEndPadding;
    }

    public int getBottomDividerStartPadding() {
        return mBottomDividerStartPadding;
    }

    public int getBottomDividerEndPadding() {
        return mBottomDividerEndPadding;
    }

    public int getActionDividerHeight() {
        return mActionDividerHeight;
    }

    public int getSeekBarInlineWidth() {
        return mSeekBarInlineWidth;
    }

    public int getProgressBarInlineWidth() {
        return mProgressBarInlineWidth;
    }

    public int getProgressBarStartPadding() {
        return mProgressBarStartPadding;
    }

    public int getProgressBarEndPadding() {
        return mProgressBarEndPadding;
    }

    public int getTextActionPadding() {
        return mTextActionPadding;
    }

    public int getIconSize() {
        return mIconSize;
    }

    public boolean getDisableRecyclerViewItemAnimator() {
        return mDisableRecyclerViewItemAnimator;
    }

    public int getImageSize() {
        return mImageSize;
    }

    public int getTintColor() {
        return mTintColor != null ? mTintColor : mSliceStyle.getTintColor();
    }

    public int getTitleColor() {
        return mTitleColor != null ? mTitleColor : mSliceStyle.getTitleColor();
    }

    public int getSubtitleColor() {
        return mSubtitleColor != null ? mSubtitleColor : mSliceStyle.getSubtitleColor();
    }

    @Nullable
    private static Integer getOptionalColor(TypedArray a, @StyleableRes int colorRes) {
        return a.hasValue(colorRes) ? a.getColor(colorRes, 0) : null;
    }

}