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.SimpleViewBinder 23 import com.android.healthconnect.controller.shared.recyclerview.ViewBinder 24 import com.android.healthconnect.controller.utils.logging.EntryDetailsElement 25 import com.android.healthconnect.controller.utils.logging.HealthConnectLogger 26 import com.android.healthconnect.controller.utils.logging.HealthConnectLoggerEntryPoint 27 import dagger.hilt.android.EntryPointAccessors 28 29 class PlannedExerciseBlockViewBinder : SimpleViewBinder<PlannedExerciseBlockEntry, View> { 30 private lateinit var logger: HealthConnectLogger 31 newViewnull32 override fun newView(parent: ViewGroup): View { 33 val context = parent.context.applicationContext 34 val hiltEntryPoint = 35 EntryPointAccessors.fromApplication(context, HealthConnectLoggerEntryPoint::class.java) 36 logger = hiltEntryPoint.logger() 37 return LayoutInflater.from(parent.context) 38 .inflate(R.layout.item_planned_exercise_block_entry, parent, false) 39 } 40 bindnull41 override fun bind(view: View, data: PlannedExerciseBlockEntry, index: Int) { 42 val title = view.findViewById<TextView>(R.id.planned_exercise_block_title) 43 44 title.text = data.title 45 title.contentDescription = data.titleA11y 46 logger.logImpression(EntryDetailsElement.PLANNED_EXERCISE_BLOCK_ENTRY_VIEW) 47 } 48 } 49