Browse Source

No need to inject BookmarkPage, make it a utility class for right now

master
Anthony Restaino 9 years ago
parent
commit
c95f1f86e9
  1. 2
      app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java
  2. 2
      app/src/main/java/acr/browser/lightning/app/AppComponent.java
  3. 5
      app/src/main/java/acr/browser/lightning/app/BrowserApp.java
  4. 18
      app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java
  5. 4
      app/src/main/java/acr/browser/lightning/view/LightningView.java

2
app/src/main/java/acr/browser/lightning/activity/BrowserActivity.java

@ -183,8 +183,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Event bus // Event bus
@Inject Bus mEventBus; @Inject Bus mEventBus;
@Inject BookmarkPage mBookmarkPage;
@Inject LightningDialogBuilder bookmarksDialogBuilder; @Inject LightningDialogBuilder bookmarksDialogBuilder;
@Inject TabsManager mTabsManager; @Inject TabsManager mTabsManager;

2
app/src/main/java/acr/browser/lightning/app/AppComponent.java

@ -31,8 +31,6 @@ public interface AppComponent {
void inject(LightningDialogBuilder builder); void inject(LightningDialogBuilder builder);
void inject(BookmarkPage bookmarkPage);
void inject(TabsFragment fragment); void inject(TabsFragment fragment);
void inject(LightningView lightningView); void inject(LightningView lightningView);

5
app/src/main/java/acr/browser/lightning/app/BrowserApp.java

@ -21,7 +21,6 @@ public class BrowserApp extends Application {
private static final Executor mIOThread = Executors.newSingleThreadExecutor(); private static final Executor mIOThread = Executors.newSingleThreadExecutor();
@Inject static Context context; @Inject static Context context;
@Inject static BookmarkPage bookmarkPage;
@Inject static HistoryDatabase historyDatabase; @Inject static HistoryDatabase historyDatabase;
@Inject static Bus bus; @Inject static Bus bus;
@Inject static PreferenceManager preferenceManager; @Inject static PreferenceManager preferenceManager;
@ -58,8 +57,4 @@ public class BrowserApp extends Application {
return bus; return bus;
} }
public static BookmarkPage getBookmarkPage() {
return bookmarkPage;
}
} }

18
app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java

@ -52,20 +52,12 @@ public final class BookmarkPage {
private static final String END = "</div></body></html>"; private static final String END = "</div></body></html>";
@Inject private static final File FILES_DIR = BrowserApp.getContext().getFilesDir();
BookmarkManager manager; private static final File CACHE_DIR = BrowserApp.getContext().getCacheDir();
private final File FILES_DIR; private BookmarkPage() {}
private final File CACHE_DIR;
@Inject public static void buildBookmarkPage(final String folder, final BookmarkManager manager) {
public BookmarkPage() {
BrowserApp.getAppComponent().inject(this);
FILES_DIR = BrowserApp.getContext().getFilesDir();
CACHE_DIR = BrowserApp.getContext().getCacheDir();
}
public void buildBookmarkPage(final String folder) {
final List<HistoryItem> list = manager.getBookmarksFromFolder(folder, true); final List<HistoryItem> list = manager.getBookmarksFromFolder(folder, true);
final File bookmarkWebPage; final File bookmarkWebPage;
if (folder == null || folder.isEmpty()) { if (folder == null || folder.isEmpty()) {
@ -87,7 +79,7 @@ public final class BookmarkPage {
new Thread(new Runnable() { new Thread(new Runnable() {
@Override @Override
public void run() { public void run() {
buildBookmarkPage(item.getTitle()); buildBookmarkPage(item.getTitle(), manager);
} }
}).run(); }).run();
} else { } else {

4
app/src/main/java/acr/browser/lightning/view/LightningView.java

@ -50,6 +50,7 @@ import acr.browser.lightning.constant.Constants;
import acr.browser.lightning.constant.HistoryPage; import acr.browser.lightning.constant.HistoryPage;
import acr.browser.lightning.constant.StartPage; import acr.browser.lightning.constant.StartPage;
import acr.browser.lightning.controller.UIController; import acr.browser.lightning.controller.UIController;
import acr.browser.lightning.database.BookmarkManager;
import acr.browser.lightning.dialog.LightningDialogBuilder; import acr.browser.lightning.dialog.LightningDialogBuilder;
import acr.browser.lightning.download.LightningDownloadListener; import acr.browser.lightning.download.LightningDownloadListener;
import acr.browser.lightning.preference.PreferenceManager; import acr.browser.lightning.preference.PreferenceManager;
@ -98,6 +99,7 @@ public class LightningView {
@Inject PreferenceManager mPreferences; @Inject PreferenceManager mPreferences;
@Inject LightningDialogBuilder mBookmarksDialogBuilder; @Inject LightningDialogBuilder mBookmarksDialogBuilder;
@Inject ProxyUtils mProxyUtils; @Inject ProxyUtils mProxyUtils;
@Inject BookmarkManager mBookmarkManager;
@SuppressLint("NewApi") @SuppressLint("NewApi")
public LightningView(Activity activity, String url, boolean isIncognito) { public LightningView(Activity activity, String url, boolean isIncognito) {
@ -214,7 +216,7 @@ public class LightningView {
} }
final File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME); final File bookmarkWebPage = new File(mActivity.getFilesDir(), BookmarkPage.FILENAME);
BrowserApp.getBookmarkPage().buildBookmarkPage(null); BookmarkPage.buildBookmarkPage(null, mBookmarkManager);
mActivity.runOnUiThread(new Runnable() { mActivity.runOnUiThread(new Runnable() {
@Override @Override
public void run() { public void run() {

Loading…
Cancel
Save