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