-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Organize interfaces and naming a bit better.
- Loading branch information
Showing
24 changed files
with
203 additions
and
100 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
23 changes: 0 additions & 23 deletions
23
android/src/main/kotlin/clean/news/flow/ComponentService.kt
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
2 changes: 1 addition & 1 deletion
2
...otlin/clean/news/flow/PaperKeyParceler.kt → ...an/news/flow/parceler/PaperKeyParceler.kt
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,4 +1,4 @@ | ||
package clean.news.flow | ||
package clean.news.flow.parceler | ||
|
||
import android.os.Parcelable | ||
import flow.KeyParceler | ||
|
32 changes: 32 additions & 0 deletions
32
android/src/main/kotlin/clean/news/flow/service/DaggerService.kt
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,32 @@ | ||
package clean.news.flow.service | ||
|
||
import android.content.Context | ||
import flow.Flow | ||
import flow.Services.Binder | ||
import flow.ServicesFactory | ||
|
||
class DaggerService(private val rootComponent: Any) : ServicesFactory() { | ||
|
||
override fun bindServices(services: Binder) { | ||
val key = services.getKey<Any>() | ||
if (key !is WithComponent) { | ||
return | ||
} | ||
|
||
val parent = services.getService<Any>(NAME) ?: rootComponent | ||
val component = key.createComponent(parent) | ||
|
||
services.bind(NAME, component) | ||
} | ||
|
||
interface WithComponent { | ||
fun createComponent(parent: Any): Any | ||
} | ||
|
||
companion object { | ||
const val NAME = "DaggerService" | ||
|
||
fun <T> get(context: Context) = Flow.getService<T>(NAME, context) | ||
} | ||
|
||
} |
40 changes: 40 additions & 0 deletions
40
android/src/main/kotlin/clean/news/flow/service/MortarService.kt
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,40 @@ | ||
package clean.news.flow.service | ||
|
||
import android.content.Context | ||
import flow.Flow | ||
import flow.Services | ||
import flow.Services.Binder | ||
import flow.ServicesFactory | ||
import mortar.MortarScope | ||
|
||
class MortarService(private val rootScope: MortarScope) : ServicesFactory() { | ||
|
||
override fun bindServices(services: Binder) { | ||
val key = services.getKey<Any>() | ||
if (key !is WithScope) { | ||
return | ||
} | ||
|
||
val scopeName = key.javaClass.name | ||
val parentScope = services.getService<MortarScope>(NAME) ?: rootScope | ||
val childScope = parentScope.findChild(scopeName) ?: key.createScope(parentScope).build(scopeName) | ||
|
||
services.bind(NAME, childScope) | ||
} | ||
|
||
override fun tearDownServices(services: Services) { | ||
services.getService<MortarScope>(NAME)?.destroy() | ||
super.tearDownServices(services) | ||
} | ||
|
||
interface WithScope { | ||
fun createScope(parentScope: MortarScope): MortarScope.Builder | ||
} | ||
|
||
companion object { | ||
const val NAME = "MortarService" | ||
|
||
fun <T> get(context: Context) = Flow.getService<T>(NAME, context) | ||
} | ||
|
||
} |
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
Oops, something went wrong.