From ba4807f62c7101d30536ecb0795ed4e2a7574850 Mon Sep 17 00:00:00 2001 From: inorichi Date: Sun, 4 Mar 2018 21:04:41 +0100 Subject: [PATCH] Add logging to controller lifecycle to help reproducing bugs --- .../ui/base/controller/BaseController.kt | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt index 6e9f64f282..acf2ff1e86 100644 --- a/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt +++ b/app/src/main/java/eu/kanade/tachiyomi/ui/base/controller/BaseController.kt @@ -12,6 +12,7 @@ import com.bluelinelabs.conductor.ControllerChangeType import com.bluelinelabs.conductor.RestoreViewOnCreateController import kotlinx.android.extensions.LayoutContainer import kotlinx.android.synthetic.* +import timber.log.Timber abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateController(bundle), LayoutContainer { @@ -21,6 +22,22 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr override fun postCreateView(controller: Controller, view: View) { onViewCreated(view) } + + override fun preCreateView(controller: Controller) { + Timber.d("Create view for ${controller.instance()}") + } + + override fun preAttach(controller: Controller, view: View) { + Timber.d("Attach view for ${controller.instance()}") + } + + override fun preDetach(controller: Controller, view: View) { + Timber.d("Detach view for ${controller.instance()}") + } + + override fun preDestroyView(controller: Controller, view: View) { + Timber.d("Destroy view for ${controller.instance()}") + } }) } @@ -63,6 +80,10 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr (activity as? AppCompatActivity)?.supportActionBar?.title = getTitle() } + private fun Controller.instance(): String { + return "${javaClass.simpleName}@${Integer.toHexString(hashCode())}" + } + /** * Workaround for disappearing menu items when collapsing an expandable item like a SearchView. * This method should be removed when fixed upstream. @@ -81,4 +102,4 @@ abstract class BaseController(bundle: Bundle? = null) : RestoreViewOnCreateContr }) } -} \ No newline at end of file +}