forked from SuperShebang/Reedly
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
David
authored and
David
committed
Sep 11, 2017
1 parent
cb5a598
commit d9740ff
Showing
17 changed files
with
381 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
app/src/main/java/oxim/digital/reedly/configuration/RandomViewIdGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package oxim.digital.reedly.configuration; | ||
|
||
import java.util.UUID; | ||
|
||
public final class RandomViewIdGenerator implements ViewIdGenerator{ | ||
|
||
@Override | ||
public String newId() { | ||
return UUID.randomUUID().toString(); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
app/src/main/java/oxim/digital/reedly/configuration/ViewActionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package oxim.digital.reedly.configuration; | ||
|
||
import rx.Completable; | ||
import rx.Observable; | ||
import rx.Single; | ||
import rx.functions.Action1; | ||
|
||
public interface ViewActionHandler<View> { | ||
|
||
void subscribeTo(Observable<Action1<View>> observable, Action1<View> onCompleteAction, Action1<Throwable> errorAction); | ||
|
||
void subscribeTo(Single<Action1<View>> single, Action1<Throwable> errorAction); | ||
|
||
void subscribeTo(Completable completable, Action1<View> onCompleteAction, Action1<Throwable> errorAction); | ||
|
||
void pause(); | ||
|
||
void resume(); | ||
|
||
void destroy(); | ||
|
||
Observable<Action1<View>> viewActionsObservable(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 3 additions & 27 deletions
30
app/src/main/java/oxim/digital/reedly/configuration/ViewActionQueueProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,8 @@ | ||
package oxim.digital.reedly.configuration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
public interface ViewActionQueueProvider { | ||
|
||
import rx.Scheduler; | ||
ViewActionQueue queueFor(String queueId); | ||
|
||
public final class ViewActionQueueProvider { | ||
|
||
private final Scheduler mainScheduler; | ||
|
||
public ViewActionQueueProvider(final Scheduler mainScheduler) { | ||
this.mainScheduler = mainScheduler; | ||
} | ||
|
||
private final Map<String, ViewActionQueue> viewActionQueueMap = new HashMap<>(); | ||
|
||
public ViewActionQueue queueFor(final String queueId) { | ||
final ViewActionQueue viewActionQueue = viewActionQueueMap.get(queueId); | ||
if (viewActionQueue != null) { | ||
return viewActionQueue; | ||
} | ||
|
||
final ViewActionQueue newQueue = new ViewActionQueue(mainScheduler); | ||
viewActionQueueMap.put(queueId, newQueue); | ||
return newQueue; | ||
} | ||
|
||
public void dispose(final String queueId) { | ||
viewActionQueueMap.remove(queueId); | ||
} | ||
void dispose(String queueId); | ||
} |
33 changes: 33 additions & 0 deletions
33
app/src/main/java/oxim/digital/reedly/configuration/ViewActionQueueProviderImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package oxim.digital.reedly.configuration; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import rx.Scheduler; | ||
|
||
public final class ViewActionQueueProviderImpl implements ViewActionQueueProvider { | ||
|
||
private final Scheduler mainScheduler; | ||
private final Map<String, ViewActionQueue> viewActionQueueMap = new HashMap<>(); | ||
|
||
public ViewActionQueueProviderImpl(final Scheduler mainScheduler) { | ||
this.mainScheduler = mainScheduler; | ||
} | ||
|
||
@Override | ||
public ViewActionQueue queueFor(final String queueId) { | ||
final ViewActionQueue viewActionQueue = viewActionQueueMap.get(queueId); | ||
if (viewActionQueue != null) { | ||
return viewActionQueue; | ||
} | ||
|
||
final ViewActionQueue newQueue = new ViewActionQueue(mainScheduler); | ||
viewActionQueueMap.put(queueId, newQueue); | ||
return newQueue; | ||
} | ||
|
||
@Override | ||
public void dispose(final String queueId) { | ||
viewActionQueueMap.remove(queueId); | ||
} | ||
} |
8 changes: 2 additions & 6 deletions
8
app/src/main/java/oxim/digital/reedly/configuration/ViewIdGenerator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,6 @@ | ||
package oxim.digital.reedly.configuration; | ||
|
||
import java.util.UUID; | ||
public interface ViewIdGenerator { | ||
|
||
public final class ViewIdGenerator { | ||
|
||
public String newId() { | ||
return UUID.randomUUID().toString(); | ||
} | ||
String newId(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
app/src/test/java/oxim/digital/reedly/MockViewActionHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package oxim.digital.reedly; | ||
|
||
import oxim.digital.reedly.configuration.ViewActionHandler; | ||
import rx.Completable; | ||
import rx.Observable; | ||
import rx.Scheduler; | ||
import rx.Single; | ||
import rx.functions.Action1; | ||
import rx.schedulers.Schedulers; | ||
import rx.subjects.PublishSubject; | ||
|
||
public final class MockViewActionHandler<View> implements ViewActionHandler<View> { | ||
|
||
private final PublishSubject<Action1<View>> subject = PublishSubject.create(); | ||
private final Scheduler scheduler = Schedulers.immediate(); | ||
|
||
@Override | ||
public void subscribeTo(final Observable<Action1<View>> observable, final Action1<View> onCompleteAction, final Action1<Throwable> errorAction) { | ||
observable.subscribeOn(scheduler) | ||
.subscribe(this::onResult, errorAction::call); | ||
} | ||
|
||
@Override | ||
public void subscribeTo(final Single<Action1<View>> single, final Action1<Throwable> errorAction) { | ||
single.subscribeOn(scheduler) | ||
.subscribe(this::onResult, errorAction::call); | ||
} | ||
|
||
@Override | ||
public void subscribeTo(final Completable completable, final Action1<View> onCompleteAction, final Action1<Throwable> errorAction) { | ||
completable.subscribeOn(scheduler) | ||
.subscribe(() -> onResult(onCompleteAction), errorAction::call); | ||
} | ||
|
||
private void onResult(final Action1<View> resultAction) { | ||
subject.onNext(resultAction); | ||
} | ||
|
||
@Override | ||
public void pause() { | ||
//noop | ||
} | ||
|
||
@Override | ||
public void resume() { | ||
//noop | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
//noop | ||
} | ||
|
||
@Override | ||
public Observable<Action1<View>> viewActionsObservable() { | ||
return subject; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.