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 /** 27 * The interface for the behavior of section in the customization picker. 28 * 29 * @param <T> the {@link SectionView} to create for the section 30 */ 31 public interface CustomizationSectionController<T extends SectionView> { 32 33 /** Interface for customization section navigation. */ 34 interface CustomizationSectionNavigationController { 35 /** Navigates to the given {@code fragment}. */ navigateTo(Fragment fragment)36 void navigateTo(Fragment fragment); 37 } 38 39 /** Returns {@code true} if the customization section is available. */ isAvailable(@ullable Context context)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 */ createView(Context context)47 T createView(Context context); 48 49 /** Saves the view state for configuration changes. */ onSaveInstanceState(Bundle savedInstanceState)50 default void onSaveInstanceState(Bundle savedInstanceState) {} 51 52 /** Releases the controller. */ release()53 default void release() {} 54 55 /** Gets called when the section gets transitioned out. */ onTransitionOut()56 default void onTransitionOut() {} 57 } 58