Skip to content

Commit

Permalink
Introduce experimental ConcurrentPairNavigator
Browse files Browse the repository at this point in the history
  • Loading branch information
nhaarman committed Mar 5, 2019
1 parent 7101638 commit ba59e22
Show file tree
Hide file tree
Showing 32 changed files with 2,916 additions and 12 deletions.
9 changes: 5 additions & 4 deletions .circleci/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,14 @@
:ext-acorn-android-timber:lint \
:ext-acorn-android-lifecycle:lint \
\
:samples:hello-world:lintRelease \
:samples:hello-concurrentpairnavigator:lintRelease \
:samples:hello-navigation:lintRelease \
:samples:hello-staterestoration:lintRelease \
:samples:hello-startactivity:lintRelease \
:samples:hello-sharedata:lintRelease \
:samples:hello-viewfactory:lintRelease \
:samples:hello-startactivity:lintRelease \
:samples:hello-staterestoration:lintRelease \
:samples:hello-transitionanimation:lintRelease \
:samples:hello-viewfactory:lintRelease \
:samples:hello-world:lintRelease \
\
:samples:notes-app:android:lintRelease \
\
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
**.log

*.orig
*.attach_*

.idea/assetWizardSettings.xml
.idea/caches/*
Expand Down
1 change: 1 addition & 0 deletions .idea/inspectionProfiles/ktlint.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Copyright 2018 Niek Haarman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nhaarman.acorn.navigation.experimental

import com.nhaarman.acorn.presentation.Container
import com.nhaarman.acorn.presentation.RestorableContainer

/**
* A [Container] that combines two Containers into one.
*
* This interface is used in conjunction with [ConcurrentPairNavigator].
*/
@ExperimentalConcurrentPairNavigator
interface CombinedContainer : RestorableContainer {

val firstContainer: Container
val secondContainer: Container
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Copyright 2018 Niek Haarman
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.nhaarman.acorn.navigation.experimental

import com.nhaarman.acorn.presentation.Container
import com.nhaarman.acorn.presentation.Scene
import com.nhaarman.acorn.presentation.SceneKey

/**
* A [Scene] that combines two Scenes into one.
* The key of this Scene is taken from [secondScene].
*
* This class is used in conjunction with [ConcurrentPairNavigator].
*/
@ExperimentalConcurrentPairNavigator
class CombinedScene(
val firstScene: Scene<out Container>,
val secondScene: Scene<out Container>
) : Scene<CombinedContainer> {

override val key: SceneKey
get() = secondScene.key

override fun onStart() {
}

@Suppress("UNCHECKED_CAST")
override fun attach(v: CombinedContainer) {
(firstScene as Scene<Container>).attach(v.firstContainer)
(secondScene as Scene<Container>).attach(v.secondContainer)
}

@Suppress("UNCHECKED_CAST")
override fun detach(v: CombinedContainer) {
(secondScene as Scene<Container>).detach(v.secondContainer)
(firstScene as Scene<Container>).detach(v.firstContainer)
}

override fun onStop() {
}

override fun onDestroy() {
}
}
Loading

0 comments on commit ba59e22

Please sign in to comment.