|
|
|
@ -1,6 +1,7 @@
@@ -1,6 +1,7 @@
|
|
|
|
|
package acr.browser.lightning.app; |
|
|
|
|
|
|
|
|
|
import android.app.Application; |
|
|
|
|
import android.content.Context; |
|
|
|
|
|
|
|
|
|
import com.squareup.leakcanary.LeakCanary; |
|
|
|
|
import com.squareup.otto.Bus; |
|
|
|
@ -8,38 +9,41 @@ import com.squareup.otto.Bus;
@@ -8,38 +9,41 @@ import com.squareup.otto.Bus;
|
|
|
|
|
import java.util.concurrent.Executor; |
|
|
|
|
import java.util.concurrent.Executors; |
|
|
|
|
|
|
|
|
|
import javax.inject.Inject; |
|
|
|
|
|
|
|
|
|
import acr.browser.lightning.constant.BookmarkPage; |
|
|
|
|
import acr.browser.lightning.database.HistoryDatabase; |
|
|
|
|
import acr.browser.lightning.preference.PreferenceManager; |
|
|
|
|
|
|
|
|
|
public class BrowserApp extends Application { |
|
|
|
|
|
|
|
|
|
private static BrowserApp sInstance; |
|
|
|
|
private static AppComponent appComponent; |
|
|
|
|
private static final Executor mIOThread = Executors.newSingleThreadExecutor(); |
|
|
|
|
|
|
|
|
|
@Inject static Context context; |
|
|
|
|
@Inject static BookmarkPage bookmarkPage; |
|
|
|
|
@Inject static HistoryDatabase historyDatabase; |
|
|
|
|
@Inject static Bus bus; |
|
|
|
|
@Inject static PreferenceManager preferenceManager; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void onCreate() { |
|
|
|
|
super.onCreate(); |
|
|
|
|
sInstance = this; |
|
|
|
|
appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); |
|
|
|
|
appComponent.inject(this); |
|
|
|
|
LeakCanary.install(this); |
|
|
|
|
buildDepencyGraph(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static BrowserApp getContext() { |
|
|
|
|
return sInstance; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static AppComponent getAppComponent() { |
|
|
|
|
return appComponent; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private void buildDepencyGraph() { |
|
|
|
|
appComponent = DaggerAppComponent.builder().appModule(new AppModule(this)).build(); |
|
|
|
|
public static Context getContext() { |
|
|
|
|
return context; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static HistoryDatabase getHistoryDatabase() { |
|
|
|
|
return appComponent.getHistoryDatabase(); |
|
|
|
|
return historyDatabase; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Executor getIOThread() { |
|
|
|
@ -47,15 +51,15 @@ public class BrowserApp extends Application {
@@ -47,15 +51,15 @@ public class BrowserApp extends Application {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static PreferenceManager getPreferenceManager() { |
|
|
|
|
return appComponent.getPreferenceManager(); |
|
|
|
|
return preferenceManager; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static Bus getBus() { |
|
|
|
|
return appComponent.getBus(); |
|
|
|
|
return bus; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public static BookmarkPage getBookmarkPage() { |
|
|
|
|
return appComponent.getBookmarkPage(); |
|
|
|
|
return bookmarkPage; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|