Skip to content

Commit

Permalink
Invert key/screen naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
pardom committed May 6, 2016
1 parent c71e2f6 commit 8399628
Show file tree
Hide file tree
Showing 16 changed files with 66 additions and 67 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class SceneKeyChanger(private val activity: Activity) : KeyChanger() {

outgoingState?.save(frame.getChildAt(0))

val scene = Scene.getSceneForLayout(frame, layout, context)
val scene = Scene(frame, incomingView)
val transition = if (destination is WithTransition) {
destination.createTransition(outgoingState?.getKey(), incomingState.getKey(), direction)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import android.app.Application
import clean.news.inject.module.ApplicationModule
import clean.news.presentation.inject.ApplicationScope
import clean.news.presentation.navigation.NavigationService
import clean.news.ui.main.MainScreen.MainComponent
import clean.news.ui.main.MainKey.MainComponent
import dagger.Component

@ApplicationScope
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,20 @@ package clean.news.navigation

import clean.news.core.entity.Item
import clean.news.presentation.navigation.NavigationFactory
import clean.news.presentation.navigation.NavigationFactory.ItemShareUrlKey
import clean.news.ui.item.detail.ItemDetailScreen
import clean.news.ui.item.detail.ItemDetailShareScreen
import clean.news.ui.item.url.ItemUrlScreen
import clean.news.ui.item.url.ItemUrlShareScreen
import clean.news.ui.main.MainScreen
import clean.news.ui.item.detail.ItemDetailKey
import clean.news.ui.item.detail.ItemDetailShareKey
import clean.news.ui.item.url.ItemUrlKey
import clean.news.ui.item.url.ItemUrlShareKey
import clean.news.ui.main.MainKey

class FlowNavigationFactory : NavigationFactory {
override fun main() = MainScreen()
override fun main() = MainKey()

override fun itemDetail(item: Item) = ItemDetailScreen(item)
override fun itemDetail(item: Item) = ItemDetailKey(item)

override fun url(item: Item) = ItemUrlScreen(item)
override fun url(item: Item) = ItemUrlKey(item)

override fun shareDetail(item: Item) = ItemDetailShareScreen(item)
override fun shareDetail(item: Item) = ItemDetailShareKey(item)

override fun shareUrl(item: Item): ItemShareUrlKey = ItemUrlShareScreen(item)
override fun shareUrl(item: Item) = ItemUrlShareKey(item)
}
4 changes: 2 additions & 2 deletions android/src/main/kotlin/clean/news/ui/MainActivity.kt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package clean.news.ui

import clean.news.ui.main.MainScreen
import clean.news.ui.main.MainKey

class MainActivity : BaseActivity() {
override fun getDefaultKey() = MainScreen()
override fun getDefaultKey() = MainKey()
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@ import clean.news.core.entity.Item
import clean.news.flow.keychanger.SceneKeyChanger.WithLayout
import clean.news.flow.keychanger.SceneKeyChanger.WithTransition
import clean.news.flow.service.DaggerService.WithComponent
import clean.news.presentation.inject.ClassScope
import clean.news.presentation.model.item.ItemDetailViewModel
import clean.news.presentation.navigation.NavigationFactory.ItemDetailKey
import clean.news.ui.item.detail.ItemDetailShareScreen.ItemDetailShareComponent
import clean.news.ui.item.detail.ItemDetailShareScreen.ItemDetailShareModule
import clean.news.ui.main.MainScreen
import clean.news.ui.main.MainScreen.MainComponent
import clean.news.presentation.inject.ScreenScope
import clean.news.presentation.navigation.NavigationFactory.ItemDetailScreen
import clean.news.ui.item.detail.ItemDetailShareKey.ItemDetailShareComponent
import clean.news.ui.item.detail.ItemDetailShareKey.ItemDetailShareModule
import clean.news.ui.main.MainKey
import clean.news.ui.main.MainKey.MainComponent
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
Expand All @@ -23,15 +22,15 @@ import nz.bradcampbell.paperparcel.PaperParcel
import nz.bradcampbell.paperparcel.PaperParcelable

@PaperParcel
class ItemDetailScreen(val item: Item) : ClassKey(),
class ItemDetailKey(val item: Item) : ClassKey(),
TreeKey,
ItemDetailKey,
ItemDetailScreen,
WithLayout,
WithTransition,
WithComponent,
PaperParcelable {

override fun getParentKey() = MainScreen()
override fun getParentKey() = MainKey()

override fun getLayoutResId() = R.layout.item_detail_view

Expand All @@ -44,7 +43,7 @@ class ItemDetailScreen(val item: Item) : ClassKey(),
return parent.plus(ItemDetailModule(item))
}

@ClassScope(ItemDetailViewModel::class)
@ScreenScope(ItemDetailScreen::class)
@Subcomponent(modules = arrayOf(ItemDetailModule::class))
interface ItemDetailComponent {
fun inject(view: ItemDetailView)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import clean.news.core.entity.Item
import clean.news.data.retrofit.threadUrl
import clean.news.flow.service.DaggerService.WithComponent
import clean.news.navigation.AppNavigationService.WithActivity
import clean.news.presentation.navigation.NavigationFactory.ItemShareDetailKey
import clean.news.ui.item.detail.ItemDetailScreen.ItemDetailComponent
import clean.news.presentation.navigation.NavigationFactory.ItemShareDetailScreen
import clean.news.ui.item.detail.ItemDetailKey.ItemDetailComponent
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
Expand All @@ -16,14 +16,14 @@ import nz.bradcampbell.paperparcel.PaperParcel
import nz.bradcampbell.paperparcel.PaperParcelable

@PaperParcel
class ItemDetailShareScreen(val item: Item) : ClassKey(),
class ItemDetailShareKey(val item: Item) : ClassKey(),
TreeKey,
ItemShareDetailKey,
ItemShareDetailScreen,
WithActivity,
WithComponent,
PaperParcelable {

override fun getParentKey() = ItemDetailScreen(item)
override fun getParentKey() = ItemDetailKey(item)

override fun createComponent(parent: Any): Any {
if (parent !is ItemDetailComponent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import clean.news.app.util.addTo
import clean.news.flow.service.DaggerService
import clean.news.presentation.model.item.ItemDetailViewModel
import clean.news.presentation.model.item.ItemDetailViewModel.Sources
import clean.news.ui.item.detail.ItemDetailScreen.ItemDetailComponent
import clean.news.ui.item.detail.ItemDetailKey.ItemDetailComponent
import com.jakewharton.rxbinding.support.v7.widget.itemClicks
import com.jakewharton.rxbinding.support.v7.widget.navigationClicks
import rx.Observable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import clean.news.R
import clean.news.core.entity.Item
import clean.news.flow.keychanger.SceneKeyChanger.WithLayout
import clean.news.flow.service.DaggerService.WithComponent
import clean.news.ui.main.MainScreen.MainComponent
import clean.news.ui.main.MainKey.MainComponent
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import clean.news.flow.service.DaggerService
import clean.news.presentation.model.item.ItemListViewModel
import clean.news.presentation.model.item.ItemListViewModel.Sources
import clean.news.ui.item.list.ItemListScreen.ItemListModule
import clean.news.ui.main.MainScreen.MainComponent
import clean.news.ui.main.MainKey.MainComponent
import flow.Flow
import rx.android.schedulers.AndroidSchedulers
import rx.subjects.PublishSubject
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import clean.news.core.entity.Item
import clean.news.flow.keychanger.SceneKeyChanger.WithLayout
import clean.news.flow.keychanger.SceneKeyChanger.WithTransition
import clean.news.flow.service.DaggerService.WithComponent
import clean.news.presentation.navigation.NavigationFactory.ItemUrlKey
import clean.news.ui.item.url.ItemUrlShareScreen.ItemUrlShareModule
import clean.news.ui.main.MainScreen
import clean.news.ui.main.MainScreen.MainComponent
import clean.news.presentation.navigation.NavigationFactory.ItemUrlScreen
import clean.news.ui.item.url.ItemUrlShareKey.ItemUrlShareModule
import clean.news.ui.main.MainKey
import clean.news.ui.main.MainKey.MainComponent
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
Expand All @@ -20,15 +20,15 @@ import nz.bradcampbell.paperparcel.PaperParcel
import nz.bradcampbell.paperparcel.PaperParcelable

@PaperParcel
class ItemUrlScreen(val item: Item) : ClassKey(),
class ItemUrlKey(val item: Item) : ClassKey(),
TreeKey,
ItemUrlKey,
ItemUrlScreen,
WithLayout,
WithTransition,
WithComponent,
PaperParcelable {

override fun getParentKey() = MainScreen()
override fun getParentKey() = MainKey()

override fun getLayoutResId() = R.layout.item_url_view

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import android.content.Intent
import clean.news.core.entity.Item
import clean.news.flow.service.DaggerService.WithComponent
import clean.news.navigation.AppNavigationService.WithActivity
import clean.news.presentation.navigation.NavigationFactory.ItemShareUrlKey
import clean.news.ui.item.url.ItemUrlScreen.ItemUrlComponent
import clean.news.presentation.navigation.NavigationFactory.ItemShareUrlScreen
import clean.news.ui.item.url.ItemUrlKey.ItemUrlComponent
import dagger.Module
import dagger.Provides
import dagger.Subcomponent
Expand All @@ -15,14 +15,14 @@ import nz.bradcampbell.paperparcel.PaperParcel
import nz.bradcampbell.paperparcel.PaperParcelable

@PaperParcel
class ItemUrlShareScreen(val item: Item) : ClassKey(),
class ItemUrlShareKey(val item: Item) : ClassKey(),
TreeKey,
ItemShareUrlKey,
ItemShareUrlScreen,
WithActivity,
WithComponent,
PaperParcelable {

override fun getParentKey() = ItemUrlScreen(item)
override fun getParentKey() = ItemUrlKey(item)

override fun createComponent(parent: Any): Any {
if (parent !is ItemUrlComponent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import clean.news.core.entity.Item
import clean.news.flow.service.DaggerService
import clean.news.presentation.model.item.ItemUrlViewModel
import clean.news.presentation.model.item.ItemUrlViewModel.Sources
import clean.news.ui.item.url.ItemUrlScreen.ItemUrlComponent
import clean.news.ui.item.url.ItemUrlKey.ItemUrlComponent
import com.jakewharton.rxbinding.support.v7.widget.itemClicks
import com.jakewharton.rxbinding.support.v7.widget.navigationClicks
import rx.subscriptions.CompositeSubscription
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,22 @@ import clean.news.flow.keychanger.SceneKeyChanger.WithTransition
import clean.news.flow.service.DaggerService.WithComponent
import clean.news.inject.component.ApplicationComponent
import clean.news.presentation.inject.ActivityScope
import clean.news.presentation.navigation.NavigationFactory.MainKey
import clean.news.ui.item.detail.ItemDetailScreen.ItemDetailComponent
import clean.news.ui.item.detail.ItemDetailScreen.ItemDetailModule
import clean.news.presentation.navigation.NavigationFactory.MainScreen
import clean.news.ui.item.detail.ItemDetailKey.ItemDetailComponent
import clean.news.ui.item.detail.ItemDetailKey.ItemDetailModule
import clean.news.ui.item.list.ItemListScreen.ItemListComponent
import clean.news.ui.item.list.ItemListScreen.ItemListModule
import clean.news.ui.item.url.ItemUrlScreen.ItemUrlComponent
import clean.news.ui.item.url.ItemUrlScreen.ItemUrlModule
import clean.news.ui.item.url.ItemUrlKey.ItemUrlComponent
import clean.news.ui.item.url.ItemUrlKey.ItemUrlModule
import dagger.Subcomponent
import flow.ClassKey
import flow.Direction
import nz.bradcampbell.paperparcel.PaperParcel
import nz.bradcampbell.paperparcel.PaperParcelable

@PaperParcel
class MainScreen : ClassKey(),
MainKey,
class MainKey : ClassKey(),
MainScreen,
WithLayout,
WithTransition,
WithComponent,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ import kotlin.reflect.KClass

@Scope
@Retention(RUNTIME)
annotation class ClassScope(val value: KClass<*>)
annotation class ScreenScope(val value: KClass<*>)
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,18 @@ import clean.news.app.usecase.item.GetChildren
import clean.news.app.usecase.item.GetChildren.Request
import clean.news.app.util.addTo
import clean.news.core.entity.Item
import clean.news.presentation.inject.ClassScope
import clean.news.presentation.inject.ScreenScope
import clean.news.presentation.model.Model
import clean.news.presentation.model.item.ItemDetailViewModel.Sinks
import clean.news.presentation.model.item.ItemDetailViewModel.Sources
import clean.news.presentation.navigation.NavigationFactory
import clean.news.presentation.navigation.NavigationFactory.ItemDetailScreen
import clean.news.presentation.navigation.NavigationService
import rx.Observable
import rx.subscriptions.CompositeSubscription
import javax.inject.Inject

@ClassScope(ItemDetailViewModel::class)
@ScreenScope(ItemDetailScreen::class)
class ItemDetailViewModel @Inject constructor(
private val navService: NavigationService,
private val navFactory: NavigationFactory,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@ package clean.news.presentation.navigation
import clean.news.core.entity.Item

interface NavigationFactory {
interface MainKey
interface MainScreen

interface ItemDetailKey
interface ItemDetailScreen

interface ItemUrlKey
interface ItemUrlScreen

interface ItemShareDetailKey
interface ItemShareDetailScreen

interface ItemShareUrlKey
interface ItemShareUrlScreen

fun main(): MainKey
fun main(): MainScreen

fun itemDetail(item: Item): ItemDetailKey
fun itemDetail(item: Item): ItemDetailScreen

fun url(item: Item): ItemUrlKey
fun url(item: Item): ItemUrlScreen

fun shareDetail(item: Item): ItemShareDetailKey
fun shareDetail(item: Item): ItemShareDetailScreen

fun shareUrl(item: Item): ItemShareUrlKey
fun shareUrl(item: Item): ItemShareUrlScreen
}

0 comments on commit 8399628

Please sign in to comment.