mirror of
https://gitlab.linphone.org/BC/public/linphone-android.git
synced 2026-01-17 11:28:06 +00:00
Prevent calling getCallLogs() if Core isn't started yet
This commit is contained in:
parent
be849e0c80
commit
f325c5ebbd
1 changed files with 15 additions and 0 deletions
|
|
@ -27,6 +27,7 @@ import org.linphone.contacts.ContactsManager
|
|||
import org.linphone.core.CallLog
|
||||
import org.linphone.core.Core
|
||||
import org.linphone.core.CoreListenerStub
|
||||
import org.linphone.core.GlobalState
|
||||
import org.linphone.core.tools.Log
|
||||
import org.linphone.ui.main.history.model.CallLogModel
|
||||
import org.linphone.ui.main.viewmodel.AbstractMainViewModel
|
||||
|
|
@ -47,7 +48,15 @@ class HistoryListViewModel @UiThread constructor() : AbstractMainViewModel() {
|
|||
}
|
||||
|
||||
private val coreListener = object : CoreListenerStub() {
|
||||
override fun onGlobalStateChanged(core: Core, state: GlobalState?, message: String) {
|
||||
if (state == GlobalState.On) {
|
||||
Log.i("$TAG Core just started, fetching history")
|
||||
computeCallLogsList(currentFilter)
|
||||
}
|
||||
}
|
||||
|
||||
override fun onCallLogUpdated(core: Core, callLog: CallLog) {
|
||||
Log.i("$TAG A call log was updated, updating list")
|
||||
computeCallLogsList(currentFilter)
|
||||
}
|
||||
}
|
||||
|
|
@ -107,6 +116,11 @@ class HistoryListViewModel @UiThread constructor() : AbstractMainViewModel() {
|
|||
|
||||
@WorkerThread
|
||||
private fun computeCallLogsList(filter: String) {
|
||||
if (coreContext.core.globalState != GlobalState.On) {
|
||||
Log.e("$TAG Core isn't ON yet, do not attempt to get calls history")
|
||||
return
|
||||
}
|
||||
|
||||
if (callLogs.value.orEmpty().isEmpty()) {
|
||||
fetchInProgress.postValue(true)
|
||||
}
|
||||
|
|
@ -128,6 +142,7 @@ class HistoryListViewModel @UiThread constructor() : AbstractMainViewModel() {
|
|||
}
|
||||
}
|
||||
|
||||
Log.i("$TAG Fetched [${list.size}] call log(s)")
|
||||
callLogs.postValue(list)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue