Skip to content

Commit

Permalink
Build96
Browse files Browse the repository at this point in the history
  - #269 - Same error should not be posted multiple times
  • Loading branch information
Hamza417 committed Dec 28, 2023
1 parent 0ae389d commit 637ad1d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,12 @@ open class ErrorLiveData : MutableLiveData<Throwable>() {
}

fun postError(value: Throwable, application: Application) {
postValue(value)
saveTraceToDatabase(value, application.applicationContext)
if (!isSameThrowable(value)) {
postValue(value)
saveTraceToDatabase(value, application.applicationContext)
} else {
Log.e("ErrorLiveData", "Same throwable found, skipping...")
}
}

private fun saveTraceToDatabase(throwable: Throwable, applicationContext: Context) {
Expand All @@ -47,4 +51,10 @@ open class ErrorLiveData : MutableLiveData<Throwable>() {
}
}
}

private fun isSameThrowable(throwable: Throwable): Boolean {
value?.let {
return it.javaClass == throwable.javaClass
} ?: return false
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ class DeviceInfo : ScopedFragment() {
super.onViewCreated(view, savedInstanceState)
startPostponedEnterTransition()

data.getBasics().observe(viewLifecycleOwner, {
data.getBasics().observe(viewLifecycleOwner) {
adapterBasicInfo = AdapterDeviceInfoContent(it, getString(R.string.device))
setAdapters()
})
}

data.getDisplay().observe(viewLifecycleOwner, {
data.getDisplay().observe(viewLifecycleOwner) {
adapterDisplayInfo = AdapterDeviceInfoContent(it, getString(R.string.display))
setAdapters()
})
}
}

private fun setAdapters() {
Expand Down

0 comments on commit 637ad1d

Please sign in to comment.