Add LeakCanary library, fix a few memory leaks
This commit is contained in:
parent
d5102b5e54
commit
5dff2db5df
15
app/app.iml
15
app/app.iml
@ -98,6 +98,7 @@
|
|||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/23.0.1/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/palette-v7/23.0.1/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/recyclerview-v7/23.0.1/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.android.support/support-v4/23.0.1/jars" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/com.squareup.leakcanary/leakcanary-android/1.3.1/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/exploded-aar/net.i2p.android/client/0.7/jars" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/incremental" />
|
||||||
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
<excludeFolder url="file://$MODULE_DIR$/build/intermediates/jacoco" />
|
||||||
@ -117,17 +118,21 @@
|
|||||||
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
|
<orderEntry type="jdk" jdkName="Android API 23 Platform" jdkType="Android SDK" />
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
<orderEntry type="library" exported="" name="client-0.7" level="project" />
|
<orderEntry type="library" exported="" name="client-0.7" level="project" />
|
||||||
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
|
<orderEntry type="library" exported="" name="leakcanary-analyzer-1.3.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="jsr250-api-1.0" level="project" />
|
<orderEntry type="library" exported="" name="jsr250-api-1.0" level="project" />
|
||||||
<orderEntry type="library" exported="" name="dagger-2.0.1" level="project" />
|
<orderEntry type="library" exported="" name="dagger-2.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="leakcanary-watcher-1.3.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="otto-1.3.8" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="haha-1.3" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="palette-v7-23.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="design-23.0.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="appcompat-v7-23.0.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="javax.inject-1" level="project" />
|
<orderEntry type="library" exported="" name="javax.inject-1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" />
|
<orderEntry type="library" exported="" name="jsoup-1.8.1" level="project" />
|
||||||
|
<orderEntry type="library" exported="" name="leakcanary-android-1.3.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
|
<orderEntry type="library" exported="" name="recyclerview-v7-23.0.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="support-v4-23.0.1" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
|
<orderEntry type="library" exported="" name="support-annotations-23.0.1" level="project" />
|
||||||
<orderEntry type="library" exported="" name="otto-1.3.8" level="project" />
|
|
||||||
<orderEntry type="library" exported="" name="palette-v7-23.0.1" level="project" />
|
|
||||||
<orderEntry type="module" module-name="libnetcipher" exported="" />
|
<orderEntry type="module" module-name="libnetcipher" exported="" />
|
||||||
</component>
|
</component>
|
||||||
</module>
|
</module>
|
@ -55,9 +55,14 @@ dependencies {
|
|||||||
|
|
||||||
// Only Lightning Plus needs the proxy libraries
|
// Only Lightning Plus needs the proxy libraries
|
||||||
lightningPlusCompile 'net.i2p.android:client:0.7'
|
lightningPlusCompile 'net.i2p.android:client:0.7'
|
||||||
lightningPlusCompile(project(':libnetcipher'))
|
|
||||||
|
|
||||||
provided 'javax.annotation:jsr250-api:1.0'
|
// Use the following code to update the libnetcipher submodule
|
||||||
// git submodule foreach git reset --hard
|
// git submodule foreach git reset --hard
|
||||||
// git submodule update --remote
|
// git submodule update --remote
|
||||||
|
lightningPlusCompile(project(':libnetcipher'))
|
||||||
|
|
||||||
|
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
|
||||||
|
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
|
||||||
|
|
||||||
|
provided 'javax.annotation:jsr250-api:1.0'
|
||||||
}
|
}
|
@ -29,7 +29,7 @@ public class ProxyUtils {
|
|||||||
|
|
||||||
private ProxyUtils(Context context) {
|
private ProxyUtils(Context context) {
|
||||||
mPreferences = PreferenceManager.getInstance();
|
mPreferences = PreferenceManager.getInstance();
|
||||||
mI2PHelper = new I2PAndroidHelper(context);
|
mI2PHelper = new I2PAndroidHelper(context.getApplicationContext());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static ProxyUtils getInstance(@NonNull Context context) {
|
public static ProxyUtils getInstance(@NonNull Context context) {
|
||||||
|
@ -3,6 +3,8 @@ package acr.browser.lightning.app;
|
|||||||
import android.app.Application;
|
import android.app.Application;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
|
||||||
|
import com.squareup.leakcanary.LeakCanary;
|
||||||
|
|
||||||
public class BrowserApp extends Application {
|
public class BrowserApp extends Application {
|
||||||
|
|
||||||
private static Context context;
|
private static Context context;
|
||||||
@ -12,6 +14,7 @@ public class BrowserApp extends Application {
|
|||||||
public void onCreate() {
|
public void onCreate() {
|
||||||
super.onCreate();
|
super.onCreate();
|
||||||
context = getApplicationContext();
|
context = getApplicationContext();
|
||||||
|
LeakCanary.install(this);
|
||||||
buildDepencyGraph();
|
buildDepencyGraph();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,7 +51,7 @@ public class BookmarkManager {
|
|||||||
|
|
||||||
private final String DEFAULT_BOOKMARK_TITLE;
|
private final String DEFAULT_BOOKMARK_TITLE;
|
||||||
|
|
||||||
private Map<String, HistoryItem> mBookmarksMap = new HashMap<>();
|
private final Map<String, HistoryItem> mBookmarksMap = new HashMap<>();
|
||||||
// private final List<HistoryItem> mBookmarkList = new ArrayList<>();
|
// private final List<HistoryItem> mBookmarkList = new ArrayList<>();
|
||||||
private String mCurrentFolder = "";
|
private String mCurrentFolder = "";
|
||||||
private final ExecutorService mExecutor;
|
private final ExecutorService mExecutor;
|
||||||
@ -84,8 +84,8 @@ public class BookmarkManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Initialize the Bookmaneger, it's a one-time operation and will be executed asynchronously.
|
* Initialize the BookmarkManager, it's a one-time operation and will be executed asynchronously.
|
||||||
* When done, mReady flag will been setted to true.
|
* When done, mReady flag will been set to true.
|
||||||
*/
|
*/
|
||||||
private class BookmarkInitializer implements Runnable{
|
private class BookmarkInitializer implements Runnable{
|
||||||
private final Context mContext;
|
private final Context mContext;
|
||||||
@ -131,7 +131,8 @@ public class BookmarkManager {
|
|||||||
} finally {
|
} finally {
|
||||||
Utils.close(bookmarksReader);
|
Utils.close(bookmarksReader);
|
||||||
}
|
}
|
||||||
mBookmarksMap = bookmarks;
|
mBookmarksMap.clear();
|
||||||
|
mBookmarksMap.putAll(bookmarks);
|
||||||
mReady = true;
|
mReady = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -282,7 +283,8 @@ public class BookmarkManager {
|
|||||||
bookmarks.put(url, item);
|
bookmarks.put(url, item);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mBookmarksMap = bookmarks;
|
mBookmarksMap.clear();
|
||||||
|
mBookmarksMap.putAll(bookmarks);
|
||||||
mExecutor.execute(new BookmarksWriter(new LinkedList<>(mBookmarksMap.values())));
|
mExecutor.execute(new BookmarksWriter(new LinkedList<>(mBookmarksMap.values())));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -353,11 +353,11 @@ public class SearchAdapter extends BaseAdapter implements Filterable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private File downloadSuggestionsForQuery(String query) {
|
private File downloadSuggestionsForQuery(String query) {
|
||||||
File cacheFile = new File(mContext.getCacheDir(), query.hashCode() + CACHE_FILE_TYPE);
|
File cacheFile = new File(BrowserApp.getAppContext().getCacheDir(), query.hashCode() + CACHE_FILE_TYPE);
|
||||||
if (System.currentTimeMillis() - INTERVAL_DAY < cacheFile.lastModified()) {
|
if (System.currentTimeMillis() - INTERVAL_DAY < cacheFile.lastModified()) {
|
||||||
return cacheFile;
|
return cacheFile;
|
||||||
}
|
}
|
||||||
if (!isNetworkConnected(mContext)) {
|
if (!isNetworkConnected(BrowserApp.getAppContext())) {
|
||||||
return cacheFile;
|
return cacheFile;
|
||||||
}
|
}
|
||||||
InputStream in = null;
|
InputStream in = null;
|
||||||
|
Loading…
Reference in New Issue
Block a user