File tree Expand file tree Collapse file tree 2 files changed +21
-6
lines changed
main/java/fr/free/nrw/commons
test/java/fr/free/nrw/commons Expand file tree Collapse file tree 2 files changed +21
-6
lines changed Original file line number Diff line number Diff line change 1717import com .facebook .drawee .backends .pipeline .Fresco ;
1818import com .facebook .stetho .Stetho ;
1919import com .squareup .leakcanary .LeakCanary ;
20+ import com .squareup .leakcanary .RefWatcher ;
2021
2122import org .acra .ACRA ;
2223import org .acra .ReportingInteractionMode ;
@@ -117,12 +118,8 @@ public synchronized NearbyPlaces getNearbyPlaces() {
117118 @ Override
118119 public void onCreate () {
119120 super .onCreate ();
120- if (LeakCanary .isInAnalyzerProcess (this )) {
121- // This process is dedicated to LeakCanary for heap analysis.
122- // You should not init your app in this process.
123- return ;
124- }
125- LeakCanary .install (this );
121+
122+ setupLeakCanary ();
126123
127124 Timber .plant (new Timber .DebugTree ());
128125
@@ -143,6 +140,13 @@ public void onCreate() {
143140 cacheData = new CacheController ();
144141 }
145142
143+ protected RefWatcher setupLeakCanary () {
144+ if (LeakCanary .isInAnalyzerProcess (this )) {
145+ return RefWatcher .DISABLED ;
146+ }
147+ return LeakCanary .install (this );
148+ }
149+
146150 /**
147151 * @return Account|null
148152 */
Original file line number Diff line number Diff line change 1+ package fr .free .nrw .commons ;
2+
3+ import com .squareup .leakcanary .RefWatcher ;
4+
5+ // This class is automatically discovered by Robolectric
6+ public class TestCommonsApplication extends CommonsApplication {
7+ @ Override protected RefWatcher setupLeakCanary () {
8+ // No leakcanary in unit tests.
9+ return RefWatcher .DISABLED ;
10+ }
11+ }
You can’t perform that action at this time.
0 commit comments