|
1 | | -package com.omega.sun.ui.controller.base |
2 | | - |
3 | | -import android.view.View |
4 | | -import com.bluelinelabs.conductor.Controller |
5 | | -import com.bluelinelabs.conductor.ControllerChangeHandler |
6 | | -import com.bluelinelabs.conductor.ControllerChangeType |
7 | | -import com.omega.sun.BuildConfig |
8 | | -import leakcanary.AppWatcher |
9 | | - |
10 | | -private class RefWatchingControllerLifecycleListener : Controller.LifecycleListener() { |
11 | | - |
12 | | - private var hasExited = false |
13 | | - |
14 | | - override fun postDestroy(controller: Controller) { |
15 | | - if (hasExited) { |
16 | | - controller.expectWeaklyReachable() |
17 | | - } |
18 | | - } |
19 | | - |
20 | | - override fun preDestroyView(controller: Controller, view: View) { |
21 | | - AppWatcher.objectWatcher.expectWeaklyReachable(view, "A destroyed controller view should have only weak references.") |
22 | | - } |
23 | | - |
24 | | - override fun onChangeEnd( |
25 | | - controller: Controller, |
26 | | - changeHandler: ControllerChangeHandler, |
27 | | - changeType: ControllerChangeType |
28 | | - ) { |
29 | | - hasExited = !changeType.isEnter |
30 | | - if (controller.isDestroyed) { |
31 | | - controller.expectWeaklyReachable() |
32 | | - } |
33 | | - } |
34 | | - |
35 | | - private fun Controller.expectWeaklyReachable() { |
36 | | - AppWatcher.objectWatcher.expectWeaklyReachable(this, "A destroyed controller should have only weak references.") |
37 | | - } |
38 | | -} |
39 | | - |
40 | | -fun Controller.watchForLeaks() { |
41 | | - if(BuildConfig.DEBUG){ |
42 | | - addLifecycleListener(RefWatchingControllerLifecycleListener()) |
43 | | - } |
44 | | -} |
| 1 | +//package com.omega.sun.ui.controller.base |
| 2 | +// |
| 3 | +//import android.view.View |
| 4 | +//import com.bluelinelabs.conductor.Controller |
| 5 | +//import com.bluelinelabs.conductor.ControllerChangeHandler |
| 6 | +//import com.bluelinelabs.conductor.ControllerChangeType |
| 7 | +//import com.omega.sun.BuildConfig |
| 8 | +//import leakcanary.AppWatcher |
| 9 | +// |
| 10 | +//private class RefWatchingControllerLifecycleListener : Controller.LifecycleListener() { |
| 11 | +// |
| 12 | +// private var hasExited = false |
| 13 | +// |
| 14 | +// override fun postDestroy(controller: Controller) { |
| 15 | +// if (hasExited) { |
| 16 | +// controller.expectWeaklyReachable() |
| 17 | +// } |
| 18 | +// } |
| 19 | +// |
| 20 | +// override fun preDestroyView(controller: Controller, view: View) { |
| 21 | +// AppWatcher.objectWatcher.expectWeaklyReachable(view, "A destroyed controller view should have only weak references.") |
| 22 | +// } |
| 23 | +// |
| 24 | +// override fun onChangeEnd( |
| 25 | +// controller: Controller, |
| 26 | +// changeHandler: ControllerChangeHandler, |
| 27 | +// changeType: ControllerChangeType |
| 28 | +// ) { |
| 29 | +// hasExited = !changeType.isEnter |
| 30 | +// if (controller.isDestroyed) { |
| 31 | +// controller.expectWeaklyReachable() |
| 32 | +// } |
| 33 | +// } |
| 34 | +// |
| 35 | +// private fun Controller.expectWeaklyReachable() { |
| 36 | +// AppWatcher.objectWatcher.expectWeaklyReachable(this, "A destroyed controller should have only weak references.") |
| 37 | +// } |
| 38 | +//} |
| 39 | +// |
| 40 | +//fun Controller.watchForLeaks() { |
| 41 | +// if(BuildConfig.DEBUG){ |
| 42 | +// addLifecycleListener(RefWatchingControllerLifecycleListener()) |
| 43 | +// } |
| 44 | +//} |
0 commit comments