1 /* 2 * Copyright 2022 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 androidx.compose.ui.tooling.animation 18 19 import androidx.compose.animation.tooling.ComposeAnimation 20 import androidx.compose.animation.tooling.ComposeAnimationType 21 import org.jetbrains.annotations.TestOnly 22 23 /** [ComposeAnimation] of type [ComposeAnimationType.UNSUPPORTED]. */ 24 internal class UnsupportedComposeAnimation private constructor(override val label: String?) : 25 ComposeAnimation { 26 override val type = ComposeAnimationType.UNSUPPORTED 27 override val animationObject: Any = 0 28 override val states = emptySet<Int>() 29 30 companion object { 31 /** 32 * [ComposeAnimationType] from ANIMATABLE to UNSUPPORTED are not available in previous 33 * versions of the library. To avoid creating non-existing enum, 34 * [UnsupportedComposeAnimation] should only be instantiated if [ComposeAnimationType] API 35 * for UNSUPPORTED enum is available. 36 */ <lambda>null37 var apiAvailable = enumValues<ComposeAnimationType>().any { it.name == "UNSUPPORTED" } 38 private set 39 createnull40 fun create(label: String?) = if (apiAvailable) UnsupportedComposeAnimation(label) else null 41 42 /** This method is for testing only. */ 43 @TestOnly 44 fun testOverrideAvailability(override: Boolean) { 45 apiAvailable = override 46 } 47 } 48 } 49