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.wallpaper.picker.category.wrapper
18 
19 import com.android.wallpaper.model.Category
20 
21 /**
22  * Temporary wrapper to maintain compatibility with legacy code. It prevents redundant category data
23  * fetches by reusing data fetched via the recommended architecture.
24  */
25 interface WallpaperCategoryWrapper {
26 
27     /**
28      * This function is used to get categories that have already been fetched. The
29      * forceRefreshLiveWallpapers flag is used to decide whether we should re-fetch live wallpaper
30      * categories or not.
31      */
getCategoriesnull32     suspend fun getCategories(forceRefreshLiveWallpaperCategories: Boolean): List<Category>
33 
34     /**
35      * This function is used to get a single particular category out of all the fetched categories.
36      * It also accepts forceRefreshLiveWallpapers flag in case the category has been updated.
37      */
38     fun getCategory(
39         categories: List<Category>,
40         collectionId: String,
41         forceRefreshLiveWallpaperCategories: Boolean,
42     ): Category?
43 
44     /** This function is used to trigger re-fetching live wallpaper categories. */
45     suspend fun refreshLiveWallpaperCategories()
46 }
47