SliceUtils

open class SliceUtils
kotlin.Any
   ↳ androidx.slice.SliceUtils

Utilities for dealing with slices.

Summary

Nested classes
open

Holds options for how to handle SliceItems that cannot be serialized.

abstract

A listener used to receive events on slices parsed with #parseSlice(Context, InputStream, String, SliceActionListener).

open

Exception thrown during #parseSlice(Context, InputStream, String, SliceActionListener).

Constants
static Int

Indicates this slice is empty and waiting for content to be loaded.

static Int

Indicates this slice has fully loaded and is not waiting for other content.

static Int

Indicates this slice has some content but is waiting for other content to be loaded.

Public methods
open static Unit
serializeSlice(s: Slice, context: Context, output: OutputStream, encoding: String, options: SliceUtils.SerializeOptions)

Serialize a slice to an OutputStream.

open static Slice
parseSlice(context: Context, input: InputStream, encoding: String, listener: SliceUtils.SliceActionListener)

Parse a slice that has been previously serialized.

open static Int

open static MutableList<SliceItem!>?

open static MutableList<String!>?

Constants

LOADING_ALL

static val LOADING_ALL: Int

Indicates this slice is empty and waiting for content to be loaded.

Value: 0

LOADING_COMPLETE

static val LOADING_COMPLETE: Int

Indicates this slice has fully loaded and is not waiting for other content.

Value: 2

LOADING_PARTIAL

static val LOADING_PARTIAL: Int

Indicates this slice has some content but is waiting for other content to be loaded.

Value: 1

Public methods

serializeSlice

open static fun serializeSlice(s: Slice, context: Context, output: OutputStream, encoding: String, options: SliceUtils.SerializeOptions): Unit

Serialize a slice to an OutputStream.

The slice can later be read into slice form again with #parseSlice. Some slice types cannot be serialized, their handling is controlled by SerializeOptions.

Parameters
s Slice: The slice to serialize.
context Slice: Context used to load any resources in the slice.
output Slice: The output of the serialization.
encoding Slice: The encoding to use for serialization.
options Slice: Options defining how to handle non-serializable items.
Exceptions
IllegalArgumentException if the slice cannot be serialized using the given options.

parseSlice

open static fun parseSlice(context: Context, input: InputStream, encoding: String, listener: SliceUtils.SliceActionListener): Slice

Parse a slice that has been previously serialized.

Parses a slice that was serialized with #serializeSlice.

Note: Slices returned by this cannot be passed to SliceConvert#unwrap(Slice).

Parameters
input Context: The input stream to read from.
encoding Context: The encoding to read as.
listener Context: Listener used to handle actions when reconstructing the slice.
Exceptions
SliceParseException if the InputStream cannot be parsed.

getLoadingState

open static fun getLoadingState(slice: Slice): Int
Return
Int: the current loading state of the provided Slice.

getSliceActions

open static fun getSliceActions(slice: Slice): MutableList<SliceItem!>?
Return
MutableList<SliceItem!>?: the group of actions associated with the provided slice, if they exist.

getSliceKeywords

open static fun getSliceKeywords(slice: Slice): MutableList<String!>?
Return
MutableList<String!>?: the list of keywords associated with the provided slice, null if no keywords were specified or an empty list if the slice was specified to have no keywords.