Skip to content

Commit

Permalink
Merge pull request #20346 from wordpress-mobile/origin/fix/20287-talk…
Browse files Browse the repository at this point in the history
…back-stats-crash

Fix crashes with Traffic tab when Talkback enabled
  • Loading branch information
aditi-bhatia authored Mar 1, 2024
2 parents b355f63 + 8cae948 commit 7508d71
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,20 +69,23 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder(

private fun BarChart.draw(item: BlockListItem.TrafficBarChartItem): Int {
resetChart()
val dataSet = getData(item)
val dataSets = mutableListOf<IBarDataSet>()
dataSets.add(dataSet)

data = BarData(getData(item))
data = BarData(dataSets)

configureChartView()
configureYAxis(item)
configureXAxis(item)

invalidate()
return data.dataSets.size
return dataSet.entryCount
}

private fun hasData(entries: List<Bar>) = entries.isNotEmpty() && entries.any { it.value > 0 }

private fun getData(item: BlockListItem.TrafficBarChartItem): List<IBarDataSet> {
private fun getData(item: BlockListItem.TrafficBarChartItem): IBarDataSet {
val minColumnCount = 5

val graphWidth = DisplayUtils.pxToDp(chart.context, chart.width)
Expand All @@ -97,10 +100,8 @@ class TrafficBarChartViewHolder(parent: ViewGroup) : BlockListItemViewHolder(
buildEmptyDataSet(chart.context, cutEntries.size)
}
item.onBarChartDrawn?.invoke(dataSet.entryCount)
val dataSets = mutableListOf<IBarDataSet>()
dataSets.add(dataSet)

return dataSets
return dataSet
}

private fun configureChartView() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ class TrafficOverviewUseCase(
lowerGranularity
)
if (period != null && period != "empty") {
val selectedDate = statsDateFormatter.parseStatsDate(statsGranularity, period)
val selectedDate = statsDateFormatter.parseStatsDate(lowerGranularity, period)
selectedDateProvider.selectDate(
selectedDate,
lowerGranularity
Expand Down

0 comments on commit 7508d71

Please sign in to comment.