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 @@ -183,8 +183,6 @@ public abstract class BrowserActivity extends ThemableBrowserActivity implements
// Event bus
@Inject Bus mEventBus;
@Inject BookmarkPage mBookmarkPage;
@Inject LightningDialogBuilder bookmarksDialogBuilder;
@Inject TabsManager mTabsManager;

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

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

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

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

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

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

Loading…
Cancel
Save