forked from github/wulkanowy-mirror
Fix treessence upgrade (#1361)
This commit is contained in:
@ -7,7 +7,13 @@ import android.os.Bundle
|
||||
import android.view.View
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.fragment.app.FragmentManager
|
||||
import fr.bipi.tressence.common.filters.Filter
|
||||
import io.github.wulkanowy.sdk.exception.FeatureNotAvailableException
|
||||
import io.github.wulkanowy.sdk.scrapper.exception.FeatureDisabledException
|
||||
import timber.log.Timber
|
||||
import java.io.InterruptedIOException
|
||||
import java.net.SocketTimeoutException
|
||||
import java.net.UnknownHostException
|
||||
import javax.inject.Inject
|
||||
import javax.inject.Singleton
|
||||
|
||||
@ -18,7 +24,20 @@ class DebugLogTree : Timber.DebugTree() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun Bundle?.checkSavedState() = if (this == null) "(STATE IS NULL)" else "(STATE IS NOT NULL)"
|
||||
object ExceptionFilter : Filter {
|
||||
|
||||
override fun isLoggable(priority: Int, tag: String?) = true
|
||||
|
||||
override fun skipLog(priority: Int, tag: String?, message: String, t: Throwable?) =
|
||||
when (t) {
|
||||
is FeatureDisabledException,
|
||||
is FeatureNotAvailableException,
|
||||
is UnknownHostException,
|
||||
is SocketTimeoutException,
|
||||
is InterruptedIOException -> true
|
||||
else -> false
|
||||
}
|
||||
}
|
||||
|
||||
class ActivityLifecycleLogger : Application.ActivityLifecycleCallbacks {
|
||||
|
||||
@ -52,9 +71,15 @@ class ActivityLifecycleLogger : Application.ActivityLifecycleCallbacks {
|
||||
}
|
||||
|
||||
@Singleton
|
||||
class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLifecycleCallbacks() {
|
||||
class FragmentLifecycleLogger @Inject constructor() :
|
||||
FragmentManager.FragmentLifecycleCallbacks() {
|
||||
|
||||
override fun onFragmentViewCreated(fm: FragmentManager, f: Fragment, v: View, savedInstanceState: Bundle?) {
|
||||
override fun onFragmentViewCreated(
|
||||
fm: FragmentManager,
|
||||
f: Fragment,
|
||||
v: View,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
Timber.d("${f::class.java.simpleName} VIEW CREATED ${savedInstanceState.checkSavedState()}")
|
||||
}
|
||||
|
||||
@ -62,7 +87,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
Timber.d("${f::class.java.simpleName} STOPPED")
|
||||
}
|
||||
|
||||
override fun onFragmentCreated(fm: FragmentManager, f: Fragment, savedInstanceState: Bundle?) {
|
||||
override fun onFragmentCreated(
|
||||
fm: FragmentManager,
|
||||
f: Fragment,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
Timber.d("${f::class.java.simpleName} CREATED ${savedInstanceState.checkSavedState()}")
|
||||
}
|
||||
|
||||
@ -78,7 +107,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
Timber.d("${f::class.java.simpleName} DESTROYED")
|
||||
}
|
||||
|
||||
override fun onFragmentSaveInstanceState(fm: FragmentManager, f: Fragment, outState: Bundle) {
|
||||
override fun onFragmentSaveInstanceState(
|
||||
fm: FragmentManager,
|
||||
f: Fragment,
|
||||
outState: Bundle
|
||||
) {
|
||||
Timber.d("${f::class.java.simpleName} SAVED INSTANCE STATE")
|
||||
}
|
||||
|
||||
@ -90,7 +123,11 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
Timber.d("${f::class.java.simpleName} VIEW DESTROYED")
|
||||
}
|
||||
|
||||
override fun onFragmentActivityCreated(fm: FragmentManager, f: Fragment, savedInstanceState: Bundle?) {
|
||||
override fun onFragmentActivityCreated(
|
||||
fm: FragmentManager,
|
||||
f: Fragment,
|
||||
savedInstanceState: Bundle?
|
||||
) {
|
||||
Timber.d("${f::class.java.simpleName} ACTIVITY CREATED ${savedInstanceState.checkSavedState()}")
|
||||
}
|
||||
|
||||
@ -102,3 +139,7 @@ class FragmentLifecycleLogger @Inject constructor() : FragmentManager.FragmentLi
|
||||
Timber.d("${f::class.java.simpleName} DETACHED")
|
||||
}
|
||||
}
|
||||
|
||||
private fun Bundle?.checkSavedState() =
|
||||
if (this == null) "(STATE IS NULL)" else "(STATE IS NOT NULL)"
|
||||
|
||||
|
Reference in New Issue
Block a user