blob: f1c982b432f8ee29cdd6067fdefb2bc3b3b7fcd7 [file] [log] [blame]
Catherine Liang68e0a822023-01-26 20:22:58 +00001/*
2 * Copyright (C) 2023 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
18package com.android.customization.picker.color.ui.section
19
20import android.content.Context
21import android.view.LayoutInflater
22import androidx.lifecycle.LifecycleOwner
23import com.android.customization.picker.color.ui.binder.ColorSectionViewBinder
24import com.android.customization.picker.color.ui.fragment.ColorPickerFragment
25import com.android.customization.picker.color.ui.view.ColorSectionView2
26import com.android.customization.picker.color.ui.viewmodel.ColorPickerViewModel
27import com.android.wallpaper.R
28import com.android.wallpaper.model.CustomizationSectionController
29import com.android.wallpaper.model.CustomizationSectionController.CustomizationSectionNavigationController as NavigationController
30
31class ColorSectionController2(
32 private val navigationController: NavigationController,
33 private val viewModel: ColorPickerViewModel,
34 private val lifecycleOwner: LifecycleOwner
35) : CustomizationSectionController<ColorSectionView2> {
36
37 override fun isAvailable(context: Context): Boolean {
38 return true
39 }
40
41 override fun createView(context: Context): ColorSectionView2 {
42 return createView(context, CustomizationSectionController.ViewCreationParams())
43 }
44
45 override fun createView(
46 context: Context,
47 params: CustomizationSectionController.ViewCreationParams
48 ): ColorSectionView2 {
49 @SuppressWarnings("It is fine to inflate with null parent for our need.")
50 val view =
51 LayoutInflater.from(context)
52 .inflate(
53 R.layout.color_section_view2,
54 null,
55 ) as ColorSectionView2
56 ColorSectionViewBinder.bind(
57 view = view,
58 viewModel = viewModel,
59 lifecycleOwner = lifecycleOwner,
60 navigationOnClick = {
61 navigationController.navigateTo(ColorPickerFragment.newInstance())
62 },
63 isConnectedHorizontallyToOtherSections = params.isConnectedHorizontallyToOtherSections,
64 )
65 return view
66 }
67}