Browse Source

Fixed bug where bookmarks as homepage changes what bookmarks are shown in bookmark drawer

master
Anthony Restaino 9 years ago
parent
commit
cabea7e097
  1. 2
      app/src/main/java/acr/browser/lightning/constant/BookmarkPage.java
  2. 32
      app/src/main/java/acr/browser/lightning/database/BookmarkManager.java

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

@ -114,7 +114,7 @@ public final class BookmarkPage extends AsyncTask<Void, Void, Void> { @@ -114,7 +114,7 @@ public final class BookmarkPage extends AsyncTask<Void, Void, Void> {
}
private void buildBookmarkPage(@Nullable final String folder, @NonNull final BookmarkManager manager) {
final List<HistoryItem> list = manager.getBookmarksFromFolder(folder, true);
final List<HistoryItem> list = manager.getBookmarksCopyFromFolder(folder, true);
final File bookmarkWebPage;
if (folder == null || folder.isEmpty()) {
bookmarkWebPage = new File(mFilesDir, FILENAME);

32
app/src/main/java/acr/browser/lightning/database/BookmarkManager.java

@ -387,7 +387,7 @@ public class BookmarkManager { @@ -387,7 +387,7 @@ public class BookmarkManager {
*/
@NonNull
public synchronized List<HistoryItem> getBookmarksFromFolder(@Nullable String folder, boolean sort) {
List<HistoryItem> bookmarks = new ArrayList<>();
List<HistoryItem> bookmarks = new ArrayList<>(1);
if (folder == null || folder.isEmpty()) {
bookmarks.addAll(getFolders(sort));
folder = "";
@ -403,6 +403,36 @@ public class BookmarkManager { @@ -403,6 +403,36 @@ public class BookmarkManager {
return bookmarks;
}
/**
* Different from {@link #getBookmarksFromFolder(String, boolean)} only in
* that it doesn't affect the internal state of the bookmark manager which
* tracks the current folder used by the bookmark drawer.
* <p/>
* This method returns a list of bookmarks and folders located in the specified folder.
* This method should generally be used by the UI when it needs a list to display to the
* user as it returns a subset of all bookmarks and includes folders as well which are
* really 'fake' bookmarks.
*
* @param folder the name of the folder to retrieve bookmarks from
* @return a list of bookmarks found in that folder
*/
@NonNull
public synchronized List<HistoryItem> getBookmarksCopyFromFolder(@Nullable String folder, boolean sort) {
List<HistoryItem> bookmarks = new ArrayList<>(1);
if (folder == null || folder.isEmpty()) {
bookmarks.addAll(getFolders(sort));
folder = "";
}
for (HistoryItem item : mBookmarksMap.values()) {
if (item.getFolder().equals(folder))
bookmarks.add(item);
}
if (sort) {
Collections.sort(bookmarks, new SortIgnoreCase());
}
return bookmarks;
}
/**
* Tells you if you are at the root folder or in a subfolder
*

Loading…
Cancel
Save