This repository has been archived by the owner on Apr 30, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 79
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
Showing
39 changed files
with
1,243 additions
and
447 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
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
39 changes: 39 additions & 0 deletions
39
scoop-basics/src/main/java/com/example/scoop/basics/androidservices/SampleIntentService.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,39 @@ | ||
package com.example.scoop.basics.androidservices; | ||
|
||
import android.app.IntentService; | ||
import android.content.Intent; | ||
import com.example.scoop.basics.App; | ||
import com.example.scoop.basics.MainActivity; | ||
import com.example.scoop.basics.scoop.AppRouter; | ||
import com.example.scoop.basics.ui.DemoScreen; | ||
import com.example.scoop.basics.ui.navigationsample.screen.AScreen; | ||
import javax.inject.Inject; | ||
import timber.log.Timber; | ||
|
||
public class SampleIntentService extends IntentService { | ||
|
||
@Inject | ||
AppRouter appRouter; | ||
|
||
public SampleIntentService() { | ||
super(SampleIntentService.class.getSimpleName()); | ||
} | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
|
||
Timber.d("onCreate"); | ||
getApp().getApplicationGraph().inject(this); | ||
} | ||
|
||
private App getApp() {return (App) this.getApplicationContext();} | ||
|
||
@Override | ||
protected void onHandleIntent(Intent intent) { | ||
appRouter.replaceAllWith(new DemoScreen(), new AScreen()); | ||
Intent mainActivityIntent = new Intent(this, MainActivity.class); | ||
mainActivityIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); | ||
startActivity(mainActivityIntent); | ||
} | ||
} |
21 changes: 10 additions & 11 deletions
21
scoop-basics/src/main/java/com/example/scoop/basics/scoop/AppRouter.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,25 +1,24 @@ | ||
package com.example.scoop.basics.scoop; | ||
|
||
import com.lyft.scoop.Router; | ||
import com.jakewharton.rxrelay.BehaviorRelay; | ||
import com.lyft.scoop.RouteChange; | ||
import com.lyft.scoop.ScreenScooper; | ||
import com.lyft.scoop.Router; | ||
import rx.Observable; | ||
import rx.subjects.BehaviorSubject; | ||
|
||
public class AppRouter extends Router { | ||
|
||
private final BehaviorSubject<RouteChange> screenChangeSubject = BehaviorSubject.create(); | ||
private final BehaviorRelay<RouteChange> routeChangeRelay = BehaviorRelay.create(); | ||
|
||
public AppRouter(ScreenScooper screenScooper, boolean hasEmptyStack) { | ||
super(screenScooper, hasEmptyStack); | ||
public AppRouter(boolean hasEmptyStack) { | ||
super(hasEmptyStack); | ||
} | ||
|
||
public Observable<RouteChange> observeScreenChange() { | ||
return screenChangeSubject.asObservable(); | ||
@Override | ||
protected void onRouteChanged(RouteChange routeChange) { | ||
routeChangeRelay.call(routeChange); | ||
} | ||
|
||
@Override | ||
protected void onScoopChanged(RouteChange change) { | ||
screenChangeSubject.onNext(change); | ||
public Observable<RouteChange> observeRouteChange() { | ||
return routeChangeRelay.asObservable(); | ||
} | ||
} |
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
Oops, something went wrong.