1 /**
2  * Copyright (C) 2024 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5  * in compliance with the License. You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software distributed under the License
10  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11  * or implied. See the License for the specific language governing permissions and limitations under
12  * the License.
13  */
14 package com.android.healthconnect.controller.entrydetails
15 
16 import android.view.LayoutInflater
17 import android.view.View
18 import android.view.ViewGroup
19 import android.widget.TextView
20 import com.android.healthconnect.controller.R
21 import com.android.healthconnect.controller.data.entries.FormattedEntry.PlannedExerciseBlockEntry
22 import com.android.healthconnect.controller.shared.recyclerview.ViewBinder
23 import com.android.healthconnect.controller.utils.logging.EntryDetailsElement
24 import com.android.healthconnect.controller.utils.logging.HealthConnectLogger
25 import com.android.healthconnect.controller.utils.logging.HealthConnectLoggerEntryPoint
26 import dagger.hilt.android.EntryPointAccessors
27 
28 class PlannedExerciseBlockViewBinder : ViewBinder<PlannedExerciseBlockEntry, View> {
29     private lateinit var logger: HealthConnectLogger
30 
newViewnull31     override fun newView(parent: ViewGroup): View {
32         val context = parent.context.applicationContext
33         val hiltEntryPoint =
34             EntryPointAccessors.fromApplication(context, HealthConnectLoggerEntryPoint::class.java)
35         logger = hiltEntryPoint.logger()
36         return LayoutInflater.from(parent.context)
37             .inflate(R.layout.item_planned_exercise_block_entry, parent, false)
38     }
39 
bindnull40     override fun bind(view: View, data: PlannedExerciseBlockEntry, index: Int) {
41         val title = view.findViewById<TextView>(R.id.planned_exercise_block_title)
42 
43         title.text = data.title
44         title.contentDescription = data.titleA11y
45         logger.logImpression(EntryDetailsElement.PLANNED_EXERCISE_BLOCK_ENTRY_VIEW)
46     }
47 }
48