1 /* 2 * Copyright (C) 2024 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 package com.android.intentresolver.contentpreview.payloadtoggle.shared.model 18 19 /** Unique identifier for preview items. */ 20 sealed interface PreviewKey { 21 22 private data class Temp(override val key: Int, override val isFinal: Boolean = false) : 23 PreviewKey 24 25 private data class Final(override val key: Int, override val isFinal: Boolean = true) : 26 PreviewKey 27 28 /** The identifier, must be unique among like keys types */ 29 val key: Int 30 /** Whether this key is final or temporary. */ 31 val isFinal: Boolean 32 33 companion object { 34 /** 35 * Creates a temporary key. 36 * 37 * This is used for the initial preview items until final keys can be generated, at which 38 * point it is replaced with a final key. 39 */ tempnull40 fun temp(key: Int): PreviewKey = Temp(key) 41 42 /** 43 * Creates a final key. 44 * 45 * This is used for all preview items other than the initial preview items. 46 */ 47 fun final(key: Int): PreviewKey = Final(key) 48 } 49 } 50