Chihhang Chuang | 5198aca | 2021-06-09 13:57:03 +0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2021 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 | package com.android.wallpaper.model; |
| 17 | |
| 18 | import android.content.Context; |
| 19 | import android.os.Bundle; |
| 20 | |
| 21 | import androidx.annotation.Nullable; |
| 22 | import androidx.fragment.app.Fragment; |
| 23 | |
| 24 | import com.android.wallpaper.picker.SectionView; |
| 25 | |
| 26 | /** |
Chihhang Chuang | 502bfa8 | 2021-06-15 13:57:59 +0800 | [diff] [blame] | 27 | * The interface for the behavior of section in the customization picker. |
Chihhang Chuang | 5198aca | 2021-06-09 13:57:03 +0800 | [diff] [blame] | 28 | * |
| 29 | * @param <T> the {@link SectionView} to create for the section |
| 30 | */ |
Chihhang Chuang | 502bfa8 | 2021-06-15 13:57:59 +0800 | [diff] [blame] | 31 | public interface CustomizationSectionController<T extends SectionView> { |
Chihhang Chuang | 5198aca | 2021-06-09 13:57:03 +0800 | [diff] [blame] | 32 | |
Chihhang Chuang | 502bfa8 | 2021-06-15 13:57:59 +0800 | [diff] [blame] | 33 | /** Interface for customization section navigation. */ |
| 34 | interface CustomizationSectionNavigationController { |
Chihhang Chuang | 5198aca | 2021-06-09 13:57:03 +0800 | [diff] [blame] | 35 | /** Navigates to the given {@code fragment}. */ |
| 36 | void navigateTo(Fragment fragment); |
| 37 | } |
| 38 | |
Chihhang Chuang | 502bfa8 | 2021-06-15 13:57:59 +0800 | [diff] [blame] | 39 | /** Returns {@code true} if the customization section is available. */ |
Chihhang Chuang | 5198aca | 2021-06-09 13:57:03 +0800 | [diff] [blame] | 40 | boolean isAvailable(@Nullable Context context); |
| 41 | |
| 42 | /** |
| 43 | * Returns a newly created {@link SectionView} for the section. |
| 44 | * |
| 45 | * @param context the {@link Context} to inflate view |
| 46 | */ |
| 47 | T createView(Context context); |
| 48 | |
| 49 | /** Saves the view state for configuration changes. */ |
| 50 | default void onSaveInstanceState(Bundle savedInstanceState) {} |
| 51 | |
| 52 | /** Releases the controller. */ |
| 53 | default void release() {} |
Kunhung Li | 42f7fbe | 2021-06-10 15:41:42 +0800 | [diff] [blame] | 54 | |
| 55 | /** Gets called when the section gets transitioned out. */ |
| 56 | default void onTransitionOut() {} |
Chihhang Chuang | 5198aca | 2021-06-09 13:57:03 +0800 | [diff] [blame] | 57 | } |