1 /* 2 * Copyright (C) 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 com.android.intentresolver.widget 18 19 import android.graphics.Bitmap 20 import android.net.Uri 21 22 internal typealias ImageLoader = suspend (Uri) -> Bitmap? 23 24 interface ImagePreviewView { setTransitionElementStatusCallbacknull25 fun setTransitionElementStatusCallback(callback: TransitionElementStatusCallback?) 26 fun setImages(uris: List<Uri>, imageLoader: ImageLoader) 27 28 /** 29 * [ImagePreviewView] progressively prepares views for shared element transition and reports 30 * each successful preparation with [onTransitionElementReady] call followed by 31 * closing [onAllTransitionElementsReady] invocation. Thus the overall invocation pattern is 32 * zero or more [onTransitionElementReady] calls followed by the final 33 * [onAllTransitionElementsReady] call. 34 */ 35 interface TransitionElementStatusCallback { 36 /** 37 * Invoked when a view for a shared transition animation element is ready i.e. the image 38 * is loaded and the view is laid out. 39 * @param name shared element name. 40 */ 41 fun onTransitionElementReady(name: String) 42 43 /** 44 * Indicates that all supported transition elements have been reported with 45 * [onTransitionElementReady]. 46 */ 47 fun onAllTransitionElementsReady() 48 } 49 } 50