1 /*
<lambda>null2  * Copyright 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 package com.android.systemui.keyguard.shared.model
18 
19 import androidx.constraintlayout.widget.ConstraintLayout
20 import androidx.constraintlayout.widget.ConstraintSet
21 
22 /**
23  * Lower level modules that determine constraints for a particular section in the lockscreen root
24  * view.
25  */
26 abstract class KeyguardSection {
27     /** Adds the views to the root view. */
28     abstract fun addViews(constraintLayout: ConstraintLayout)
29     /** Binds the views to data. */
30     abstract fun bindData(constraintLayout: ConstraintLayout)
31     /** Applies layout constraints to the view in respect to the root view. */
32     abstract fun applyConstraints(constraintSet: ConstraintSet)
33     /** Removes views and does any data binding destruction. */
34     abstract fun removeViews(constraintLayout: ConstraintLayout)
35 
36     /* Notifies the section is being rebuilt */
37     open fun onRebuildBegin() {}
38 
39     /* Notifies the secion that the rebuild is complete */
40     open fun onRebuildEnd() {}
41 
42     /**
43      * Defines equality as same class.
44      *
45      * This is to enable set operations to be done as an optimization to blueprint transitions.
46      */
47     override fun equals(other: Any?): Boolean {
48         other?.let { other ->
49             return this::class == other::class
50         }
51         return false
52     }
53 
54     /**
55      * Defines hashcode as class.
56      *
57      * This is to enable set operations to be done as an optimization to blueprint transitions.
58      */
59     override fun hashCode(): Int {
60         return this::class.hashCode()
61     }
62 }
63