File tree Expand file tree Collapse file tree 4 files changed +39
-0
lines changed
java/eu/inloop/viewmodel/sample Expand file tree Collapse file tree 4 files changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ android {
1313 }
1414
1515 compileOptions {
16+ encoding " UTF-8"
1617 sourceCompatibility JavaVersion . VERSION_1_7
1718 targetCompatibility JavaVersion . VERSION_1_7
1819 }
@@ -26,6 +27,8 @@ android {
2627
2728dependencies {
2829 compile ' com.android.support:appcompat-v7:22.1.1'
30+ debugCompile ' com.squareup.leakcanary:leakcanary-android:1.3'
31+ releaseCompile ' com.squareup.leakcanary:leakcanary-android-no-op:1.3'
2932 compile ' com.jakewharton:butterknife:5.1.2'
3033 compile project(' :library' )
3134}
Original file line number Diff line number Diff line change 55 <application
66 android : allowBackup =" true"
77 android : icon =" @mipmap/ic_launcher"
8+ android : name =" .SampleApplication"
89 android : label =" @string/app_name"
910 android : theme =" @style/AppTheme" >
1011 <activity
Original file line number Diff line number Diff line change 1+ package eu .inloop .viewmodel .sample ;
2+
3+ import android .app .Application ;
4+ import android .content .Context ;
5+
6+ import com .squareup .leakcanary .LeakCanary ;
7+ import com .squareup .leakcanary .RefWatcher ;
8+
9+ public class SampleApplication extends Application {
10+
11+ private RefWatcher refWatcher ;
12+
13+ @ Override public void onCreate () {
14+ super .onCreate ();
15+ refWatcher = LeakCanary .install (this );
16+ }
17+
18+ public static RefWatcher getRefWatcher (Context context ) {
19+ SampleApplication application = (SampleApplication ) context .getApplicationContext ();
20+ return application .refWatcher ;
21+ }
22+
23+ }
Original file line number Diff line number Diff line change 1010import android .widget .ListView ;
1111import android .widget .TextView ;
1212
13+ import com .squareup .leakcanary .RefWatcher ;
14+
1315import java .util .ArrayList ;
1416import java .util .List ;
1517
1618import butterknife .ButterKnife ;
1719import butterknife .InjectView ;
1820import eu .inloop .viewmodel .base .ViewModelBaseFragment ;
1921import eu .inloop .viewmodel .sample .R ;
22+ import eu .inloop .viewmodel .sample .SampleApplication ;
2023import eu .inloop .viewmodel .sample .viewmodel .UserListViewModel ;
2124import eu .inloop .viewmodel .sample .viewmodel .view .IUserListView ;
2225
@@ -112,4 +115,13 @@ public void showLoading(float progress) {
112115 public void hideProgress () {
113116 mProgressView .setVisibility (View .GONE );
114117 }
118+
119+ @ Override
120+ public void onDestroy () {
121+ super .onDestroy ();
122+
123+ // watch for memory leaks
124+ RefWatcher refWatcher = SampleApplication .getRefWatcher (getActivity ());
125+ refWatcher .watch (this );
126+ }
115127}
You can’t perform that action at this time.
0 commit comments