mirror of https://github.com/readrops/Readrops.git
Add folder creation, deletion and feed folder change with rxandroid
This commit is contained in:
parent
d76d2e356f
commit
d0b5fa6866
Binary file not shown.
Binary file not shown.
|
@ -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'
|
||||
}
|
||||
|
|
|
@ -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());
|
||||
|
|
|
@ -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) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue