Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add method to destroy the singleton and release the Context #94

Merged
merged 1 commit into from
Mar 19, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions library/src/main/java/hotchemi/android/rate/AppRate.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public static AppRate with(Context context) {
return singleton;
}

public static void destroy() {
singleton = null;
}

public static boolean showRateDialogIfMeetsConditions(Activity activity) {
boolean isMeetsConditions = singleton.isDebug || singleton.shouldShowRateDialog();
if (isMeetsConditions) {
Expand Down
4 changes: 4 additions & 0 deletions sample/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,8 @@ repositories {

dependencies {
compile project(':library')
// Leak detection
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
}
2 changes: 2 additions & 0 deletions sample/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@

<application
android:allowBackup="false"
android:name=".ExampleApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name">
<activity
android:name=".MainActivity"
android:theme="@style/Theme.AppCompat"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package hotchemi.android.rate.sample;

import android.app.Application;

import com.squareup.leakcanary.LeakCanary;

public class ExampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
LeakCanary.install(this);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,9 @@ public void onClickButton(int which) {
AppRate.showRateDialogIfMeetsConditions(this);
}

@Override
protected void onDestroy() {
AppRate.destroy();
super.onDestroy();
}
}