blob: b01f09828fb48366e31b00092476a40f7c04c24e [file] [log] [blame]
Chihhang Chuang5198aca2021-06-09 13:57:03 +08001/*
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 */
16package com.android.wallpaper.model;
17
18import android.content.Context;
19import android.os.Bundle;
20
21import androidx.annotation.Nullable;
22import androidx.fragment.app.Fragment;
23
24import com.android.wallpaper.picker.SectionView;
25
26/**
Chihhang Chuang502bfa82021-06-15 13:57:59 +080027 * The interface for the behavior of section in the customization picker.
Chihhang Chuang5198aca2021-06-09 13:57:03 +080028 *
29 * @param <T> the {@link SectionView} to create for the section
30 */
Chihhang Chuang502bfa82021-06-15 13:57:59 +080031public interface CustomizationSectionController<T extends SectionView> {
Chihhang Chuang5198aca2021-06-09 13:57:03 +080032
Chihhang Chuang502bfa82021-06-15 13:57:59 +080033 /** Interface for customization section navigation. */
34 interface CustomizationSectionNavigationController {
Chihhang Chuang5198aca2021-06-09 13:57:03 +080035 /** Navigates to the given {@code fragment}. */
36 void navigateTo(Fragment fragment);
37 }
38
Chihhang Chuang502bfa82021-06-15 13:57:59 +080039 /** Returns {@code true} if the customization section is available. */
Chihhang Chuang5198aca2021-06-09 13:57:03 +080040 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 Li42f7fbe2021-06-10 15:41:42 +080054
55 /** Gets called when the section gets transitioned out. */
56 default void onTransitionOut() {}
Chihhang Chuang5198aca2021-06-09 13:57:03 +080057}