• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * Copyright (C) 2023 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.dataentries
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.FormattedAggregation
22 import com.android.healthconnect.controller.shared.recyclerview.ViewBinder
23 import com.android.healthconnect.controller.utils.logging.DataEntriesElement
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 AggregationViewBinder : ViewBinder<FormattedAggregation, View> {
29 
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(
36                 context.applicationContext, HealthConnectLoggerEntryPoint::class.java)
37         logger = hiltEntryPoint.logger()
38         return LayoutInflater.from(parent.context)
39             .inflate(R.layout.item_data_aggregation, parent, false)
40     }
41 
bindnull42     override fun bind(view: View, data: FormattedAggregation, index: Int) {
43         val apps = view.findViewById<TextView>(R.id.item_data_origin_apps)
44         val aggregation = view.findViewById<TextView>(R.id.item_data_aggregation)
45         logger.logImpression(DataEntriesElement.AGGREGATION_DATA_VIEW)
46 
47         aggregation.text = data.aggregation
48         aggregation.contentDescription = data.aggregationA11y
49         apps.text = data.contributingApps
50     }
51 }
52