diff --git a/.idea/caches/build_file_checksums.ser b/.idea/caches/build_file_checksums.ser index bd8bfe06..381ba262 100644 Binary files a/.idea/caches/build_file_checksums.ser and b/.idea/caches/build_file_checksums.ser differ diff --git a/.idea/caches/gradle_models.ser b/.idea/caches/gradle_models.ser index 9545b2bb..772a3e63 100644 Binary files a/.idea/caches/gradle_models.ser and b/.idea/caches/gradle_models.ser differ diff --git a/app/build.gradle b/app/build.gradle index 379f6605..b2418289 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -32,7 +32,6 @@ dependencies { implementation 'com.android.support:palette-v7:28.0.0' implementation 'com.android.support:recyclerview-v7:28.0.0' - implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' @@ -57,5 +56,5 @@ dependencies { implementation "joda-time:joda-time:2.9.9" implementation 'org.jsoup:jsoup:1.11.3' - + implementation 'io.reactivex.rxjava2:rxandroid:2.1.1' } diff --git a/app/src/main/java/com/readrops/app/ARepository.java b/app/src/main/java/com/readrops/app/ARepository.java index 33adf3f8..2873a5ef 100644 --- a/app/src/main/java/com/readrops/app/ARepository.java +++ b/app/src/main/java/com/readrops/app/ARepository.java @@ -5,13 +5,23 @@ import android.os.Handler; import android.os.Looper; import com.readrops.app.database.Database; +import com.readrops.app.database.entities.Feed; +import com.readrops.app.database.entities.Folder; import com.readrops.app.database.entities.Item; import com.readrops.readropslibrary.ParsingResult; -import com.readrops.readropslibrary.localfeed.RSSNetwork; +import org.reactivestreams.Subscriber; + +import java.util.concurrent.Callable; import java.util.concurrent.Executor; import java.util.concurrent.Executors; +import io.reactivex.Completable; +import io.reactivex.CompletableEmitter; +import io.reactivex.CompletableObserver; +import io.reactivex.CompletableOnSubscribe; +import io.reactivex.Flowable; + public abstract class ARepository { protected Executor executor; @@ -32,9 +42,31 @@ public abstract class ARepository { public abstract void addFeed(ParsingResult result); - public abstract void deleteFeed(Item item); + public abstract void deleteFeed(Feed feed); - public abstract void moveFeed(Item item); + public Completable addFolder(String name) { + return Completable.create(emitter -> { + Folder folder = new Folder(name); + database.folderDao().insert(folder); + + emitter.onComplete(); + }); + } + + public Completable deleteFolder(Folder folder) { + return Completable.create(emitter -> { + database.folderDao().delete(folder); + emitter.onComplete(); + }); + } + + public Completable changeFeedFolder(Feed feed, Folder newFolder) { + return Completable.create(emitter -> { + database.feedDao().updateFeedFolder(feed.getId(), newFolder.getId()); + emitter.onComplete(); + }); + + } protected void failureCallBackInMainThread(Exception e) { Handler handler = new Handler(Looper.getMainLooper()); diff --git a/app/src/main/java/com/readrops/app/BasedRepository.java b/app/src/main/java/com/readrops/app/BasedRepository.java index 191d010c..fd6a36e7 100644 --- a/app/src/main/java/com/readrops/app/BasedRepository.java +++ b/app/src/main/java/com/readrops/app/BasedRepository.java @@ -4,6 +4,7 @@ import android.app.Application; import android.arch.lifecycle.LiveData; import com.readrops.app.database.ItemWithFeed; +import com.readrops.app.database.entities.Feed; import com.readrops.app.database.entities.Item; import com.readrops.readropslibrary.ParsingResult; @@ -29,14 +30,7 @@ public class BasedRepository extends ARepository { } @Override - public void deleteFeed(Item item) { + public void deleteFeed(Feed feed) { } - - @Override - public void moveFeed(Item item) { - - } - - } diff --git a/app/src/main/java/com/readrops/app/LocalFeedRepository.java b/app/src/main/java/com/readrops/app/LocalFeedRepository.java index 729e5de3..03432ad7 100644 --- a/app/src/main/java/com/readrops/app/LocalFeedRepository.java +++ b/app/src/main/java/com/readrops/app/LocalFeedRepository.java @@ -3,9 +3,7 @@ package com.readrops.app; import android.app.Application; import android.arch.lifecycle.LiveData; import android.graphics.Bitmap; -import android.support.annotation.ColorInt; import android.support.v7.graphics.Palette; -import android.util.Log; import android.util.Patterns; import com.readrops.app.database.ItemWithFeed; @@ -88,18 +86,12 @@ public class LocalFeedRepository extends ARepository implements QueryCallback { } @Override - public void deleteFeed(Item item) { + public void deleteFeed(Feed feed) { executor.execute(() -> { }); } - @Override - public void moveFeed(Item item) { - - } - - @Override public void onSyncSuccess(AFeed feed, RSSNetwork.RSSType type) { switch (type) { diff --git a/app/src/main/java/com/readrops/app/database/dao/FolderDao.java b/app/src/main/java/com/readrops/app/database/dao/FolderDao.java index 6205de17..4d47ff91 100644 --- a/app/src/main/java/com/readrops/app/database/dao/FolderDao.java +++ b/app/src/main/java/com/readrops/app/database/dao/FolderDao.java @@ -2,6 +2,7 @@ package com.readrops.app.database.dao; import android.arch.lifecycle.LiveData; import android.arch.persistence.room.Dao; +import android.arch.persistence.room.Delete; import android.arch.persistence.room.Insert; import android.arch.persistence.room.Query; @@ -17,4 +18,7 @@ public interface FolderDao { @Insert long insert(Folder folder); + + @Delete + void delete(Folder folder); }