Skip to content
This repository has been archived by the owner on Nov 26, 2022. It is now read-only.

Commit

Permalink
Don't keep context to avoid memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
deckyfx committed Mar 13, 2019
1 parent 58803c7 commit c0d204d
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 22 deletions.
14 changes: 7 additions & 7 deletions app/app.iml
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/debug" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/rs/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/res/resValues/debug" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/apt/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/r/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/aidl/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/buildConfig/androidTest/debug" isTestSource="true" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/build/generated/source/rs/androidTest/debug" isTestSource="true" generated="true" />
Expand Down Expand Up @@ -85,6 +83,8 @@
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/rs" isTestSource="true" />
<sourceFolder url="file://$MODULE_DIR$/src/test/shaders" isTestSource="true" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/not_namespaced_r_class_sources" />
<excludeFolder url="file://$MODULE_DIR$/build/generated/source/r" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/annotations" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/artifact_transform" />
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/attr" />
Expand All @@ -111,20 +111,20 @@
</content>
<orderEntry type="jdk" jdkName="Android API 27 Platform" jdkType="Android SDK" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner-1.0.1" level="project" />
<orderEntry type="library" name="Gradle: io.reactivex:rxjava:1.1.8@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.google.code.findbugs:jsr305:2.0.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core-3.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:rules-1.0.1" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: javax.inject:javax.inject:1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource:3.0.1@aar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-core:3.0.1@aar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: junit:junit:4.12@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-core:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support:support-annotations:25.4.0@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test.espresso:espresso-idling-resource-3.0.1" level="project" />
<orderEntry type="library" name="Gradle: net.zetetic:android-database-sqlcipher-3.5.9" level="project" />
<orderEntry type="library" name="Gradle: net.zetetic:android-database-sqlcipher:3.5.9@aar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-library:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: org.hamcrest:hamcrest-integration:1.3@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.squareup:javawriter:2.1.1@jar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:rules:1.0.1@aar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: com.android.support.test:runner:1.0.1@aar" level="project" />
<orderEntry type="library" scope="TEST" name="Gradle: net.sf.kxml:kxml2:2.3.0@jar" level="project" />
</component>
</module>
5 changes: 0 additions & 5 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,6 @@ android {
}
}

// Automatic versioning
//ext.INCREASE_VERSION_NAME_WHEN_RUN_TASK = ""
//ext.INCREASE_VERSION_CODE_WHEN_RUN_TASK = ""
//apply from: 'https://raw.githubusercontent.com/deckyfx/AndroidTemplate/master/automatic-versioning.gradle'

configurations {
doc {
transitive false
Expand Down
10 changes: 1 addition & 9 deletions app/src/main/java/com/github/deckyfx/dbhelper/DBHelper.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
package com.github.deckyfx.dbhelper;

/**
* Created by decky on 12/28/16.
*/


import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
Expand Down Expand Up @@ -35,8 +30,6 @@ public class DBHelper {

private HashMap<String, Entity> mDAOs;

private Context mContext;

public static class INVOKE {
public static final String QUERY_BUILDER = "queryBuilder";
public static final String LOAD = "load";
Expand All @@ -48,7 +41,6 @@ public static class INVOKE {
}

public DBHelper(Context context, Class<? extends AbstractDaoMaster> daoMasterClass, String dbName){
this.mContext = context;
this.mDAOs = new HashMap<String, Entity>();

if (daoMasterClass != null) {
Expand All @@ -57,7 +49,7 @@ public DBHelper(Context context, Class<? extends AbstractDaoMaster> daoMasterCla
Class<?> devOpenHelperClass = Class.forName(daoMasterClass.getName() + "$" + "DevOpenHelper");
Constructor<?> devOpenHelperCtor = devOpenHelperClass.getDeclaredConstructor(Context.class, String.class, SQLiteDatabase.CursorFactory.class);
Constructor<?> daoMasterCtor = daoMasterClass.getConstructor(SQLiteDatabase.class);
this.OpenHelper = (SQLiteOpenHelper) devOpenHelperCtor.newInstance(this.mContext, dbName, null);
this.OpenHelper = (SQLiteOpenHelper) devOpenHelperCtor.newInstance(context, dbName, null);
this.Sqlitedb = this.OpenHelper.getWritableDatabase();
this.DAOMaster = (AbstractDaoMaster) daoMasterCtor.newInstance(this.Sqlitedb);
this.DAOSession = this.DAOMaster.newSession();
Expand Down
2 changes: 1 addition & 1 deletion dbhelper.iml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/.gradle" />
</content>
<orderEntry type="jdk" jdkName="1.8" jdkType="JavaSDK" />
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

0 comments on commit c0d204d

Please sign in to comment.