Another fix related to callLogs crash reported on the Play Store

This commit is contained in:
Sylvain Berfini 2023-04-11 08:34:47 +02:00
parent 222d60cfdd
commit 98f6206e75
3 changed files with 6 additions and 4 deletions

View file

@ -110,17 +110,17 @@ class CallLogsListAdapter(
override fun displayHeaderForPosition(position: Int): Boolean {
if (position >= itemCount) return false
val callLogGroup = getItem(position)
val date = callLogGroup.lastCallLog.startDate
val date = callLogGroup.lastCallLogStartTimestamp
val previousPosition = position - 1
return if (previousPosition >= 0) {
val previousItemDate = getItem(previousPosition).lastCallLog.startDate
val previousItemDate = getItem(previousPosition).lastCallLogStartTimestamp
!TimestampUtils.isSameDay(date, previousItemDate)
} else true
}
override fun getHeaderViewForPosition(context: Context, position: Int): View {
val callLog = getItem(position)
val date = formatDate(context, callLog.lastCallLog.startDate)
val date = formatDate(context, callLog.lastCallLogStartTimestamp)
val binding: GenericListHeaderBinding = DataBindingUtil.inflate(
LayoutInflater.from(context),
R.layout.generic_list_header, null, false

View file

@ -27,6 +27,7 @@ class GroupedCallLogData(callLog: CallLog) {
var lastCallLog: CallLog = callLog
var lastCallLogId: String? = callLog.callId
var lastCallLogStartTimestamp: Long = callLog.startDate
val lastCallLogViewModel: CallLogViewModel
get() {
if (::_lastCallLogViewModel.isInitialized) {
@ -47,5 +48,6 @@ class GroupedCallLogData(callLog: CallLog) {
fun updateLastCallLog(callLog: CallLog) {
lastCallLog = callLog
lastCallLogId = callLog.callId
lastCallLogStartTimestamp = callLog.startDate
}
}

View file

@ -122,7 +122,7 @@ class CallLogsListViewModel : ViewModel() {
previousCallLogGroup.lastCallLog.remoteAddress.equal(callLog.remoteAddress)
) {
if (TimestampUtils.isSameDay(
previousCallLogGroup.lastCallLog.startDate,
previousCallLogGroup.lastCallLogStartTimestamp,
callLog.startDate
)
) {