|
|
@ -18,6 +18,7 @@ import com.anthonycr.bonsai.SingleAction; |
|
|
|
import com.anthonycr.bonsai.SingleSubscriber; |
|
|
|
import com.anthonycr.bonsai.SingleSubscriber; |
|
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
import javax.inject.Inject; |
|
|
|
import javax.inject.Inject; |
|
|
@ -311,14 +312,16 @@ public class BookmarkDatabase extends SQLiteOpenHelper implements BookmarkModel |
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@NonNull |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Single<List<HistoryItem>> getBookmarksFromFolder(@Nullable final String folder) { |
|
|
|
public Single<List<HistoryItem>> getBookmarksFromFolderSorted(@Nullable final String folder) { |
|
|
|
return Single.create(new SingleAction<List<HistoryItem>>() { |
|
|
|
return Single.create(new SingleAction<List<HistoryItem>>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubscribe(@NonNull SingleSubscriber<List<HistoryItem>> subscriber) { |
|
|
|
public void onSubscribe(@NonNull SingleSubscriber<List<HistoryItem>> subscriber) { |
|
|
|
String finalFolder = folder != null ? folder : ""; |
|
|
|
String finalFolder = folder != null ? folder : ""; |
|
|
|
Cursor cursor = lazyDatabase().query(TABLE_BOOKMARK, null, KEY_FOLDER + "=?", new String[]{finalFolder}, null, null, null); |
|
|
|
Cursor cursor = lazyDatabase().query(TABLE_BOOKMARK, null, KEY_FOLDER + "=?", new String[]{finalFolder}, null, null, null); |
|
|
|
|
|
|
|
|
|
|
|
subscriber.onItem(bindCursorToHistoryItemList(cursor)); |
|
|
|
List<HistoryItem> list = bindCursorToHistoryItemList(cursor); |
|
|
|
|
|
|
|
Collections.sort(list); |
|
|
|
|
|
|
|
subscriber.onItem(list); |
|
|
|
subscriber.onComplete(); |
|
|
|
subscriber.onComplete(); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
}); |
|
|
@ -326,7 +329,7 @@ public class BookmarkDatabase extends SQLiteOpenHelper implements BookmarkModel |
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@NonNull |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Single<List<HistoryItem>> getFolders() { |
|
|
|
public Single<List<HistoryItem>> getFoldersSorted() { |
|
|
|
return Single.create(new SingleAction<List<HistoryItem>>() { |
|
|
|
return Single.create(new SingleAction<List<HistoryItem>>() { |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void onSubscribe(@NonNull SingleSubscriber<List<HistoryItem>> subscriber) { |
|
|
|
public void onSubscribe(@NonNull SingleSubscriber<List<HistoryItem>> subscriber) { |
|
|
@ -350,6 +353,7 @@ public class BookmarkDatabase extends SQLiteOpenHelper implements BookmarkModel |
|
|
|
|
|
|
|
|
|
|
|
cursor.close(); |
|
|
|
cursor.close(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Collections.sort(folders); |
|
|
|
subscriber.onItem(folders); |
|
|
|
subscriber.onItem(folders); |
|
|
|
subscriber.onComplete(); |
|
|
|
subscriber.onComplete(); |
|
|
|
} |
|
|
|
} |
|
|
|