1 /*
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  */
18 
19 package com.android.healthconnect.controller.entrydetails
20 
21 import android.view.LayoutInflater
22 import android.view.View
23 import android.view.ViewGroup
24 import android.widget.TextView
25 import com.android.healthconnect.controller.R
26 import com.android.healthconnect.controller.data.entries.FormattedEntry.SessionHeader
27 import com.android.healthconnect.controller.shared.recyclerview.ViewBinder
28 import com.android.healthconnect.controller.utils.logging.EntryDetailsElement
29 import com.android.healthconnect.controller.utils.logging.HealthConnectLogger
30 import com.android.healthconnect.controller.utils.logging.HealthConnectLoggerEntryPoint
31 import dagger.hilt.android.EntryPointAccessors
32 
33 class SessionHeaderViewBinder : ViewBinder<SessionHeader, View> {
34     private lateinit var logger: HealthConnectLogger
35 
newViewnull36     override fun newView(parent: ViewGroup): View {
37         val context = parent.context.applicationContext
38         val hiltEntryPoint =
39             EntryPointAccessors.fromApplication(
40                 context.applicationContext, HealthConnectLoggerEntryPoint::class.java)
41         logger = hiltEntryPoint.logger()
42         return LayoutInflater.from(parent.context)
43             .inflate(R.layout.item_data_session_header, parent, false)
44     }
45 
bindnull46     override fun bind(view: View, data: SessionHeader, index: Int) {
47         val header = view.findViewById<TextView>(R.id.item_data_entry_header)
48         header.text = data.header
49         logger.logImpression(EntryDetailsElement.SESSION_DETAIL_HEADER_VIEW)
50     }
51 }
52