Skip to content

Commit f2f21a6

Browse files
authored
Merge pull request #15 from NemoOudeis/codestyle
Codestyle
2 parents b1ca319 + 8c6fbb9 commit f2f21a6

File tree

9 files changed

+392
-444
lines changed

9 files changed

+392
-444
lines changed

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -89,4 +89,5 @@ install:
8989

9090
script:
9191
- cp local.properties.ci local.properties
92-
- "./gradlew assembleRelease bintrayUpload"
92+
- ./gradlew check
93+
- if [ TRAVIS_BRANCH == "master" ]; then ./gradlew assembleRelease bintrayUpload; fi

rekotlin-router/src/main/java/org/rekotlinrouter/NavigationAction.kt

+6-11
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ package org.rekotlinrouter
22

33
import org.rekotlin.Action
44

5-
65
class SetRouteAction(var route: Route,
76
var animated: Boolean = true,
8-
action: StandardAction? = null): StandardActionConvertible {
7+
action: StandardAction? = null) : StandardActionConvertible {
98

109
companion object {
1110
const val type = "RE_KOTLIN_ROUTER_SET_ROUTE"
1211
}
13-
1412

1513
init {
1614
// TODO: Convert the below to ArrayList
@@ -23,16 +21,13 @@ class SetRouteAction(var route: Route,
2321

2422
override fun toStandardAction(): StandardAction {
2523

26-
val payloadMap: HashMap<String,Any> = HashMap()
27-
payloadMap.put("route",this.route)
28-
payloadMap.put("animated",this.animated)
24+
val payloadMap: HashMap<String, Any> = HashMap()
25+
payloadMap.put("route", this.route)
26+
payloadMap.put("animated", this.animated)
2927
return StandardAction(type = SetRouteAction.type,
3028
payload = payloadMap,
31-
isTypedAction = true)
29+
isTypedAction = true)
3230
}
33-
34-
35-
3631
}
3732

38-
class SetRouteSpecificData ( val route: Route, val data: Any): Action
33+
class SetRouteSpecificData(val route: Route, val data: Any) : Action

rekotlin-router/src/main/java/org/rekotlinrouter/NavigationReducer.kt

+15-16
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@ package org.rekotlinrouter
22

33
import org.rekotlin.Action
44

5-
6-
75
/**
86
The Navigation Reducer handles the state slice concerned with storing the current navigation
97
information. Note, that this reducer is **not** a *top-level* reducer, you need to use it within
@@ -15,20 +13,20 @@ class NavigationReducer {
1513
companion object NavRed {
1614

1715
fun handleAction(action: Action, state: NavigationState?): NavigationState {
18-
var navigationState = state ?: NavigationState()
16+
var navigationState = state ?: NavigationState()
1917

20-
when(action) {
21-
is SetRouteAction -> {
22-
navigationState = setRoute(navigationState,action)
23-
}
24-
is SetRouteSpecificData -> {
25-
navigationState = setRouteSpecificData(navigationState, action.route, action.data)
26-
}
27-
else -> {
28-
navigationState = NavigationState()
18+
when (action) {
19+
is SetRouteAction -> {
20+
navigationState = setRoute(navigationState, action)
21+
}
22+
is SetRouteSpecificData -> {
23+
navigationState = setRouteSpecificData(navigationState, action.route, action.data)
24+
}
25+
else -> {
26+
navigationState = NavigationState()
27+
}
2928
}
30-
}
31-
return navigationState
29+
return navigationState
3230
}
3331

3432
fun setRoute(state: NavigationState, setRouteAction: SetRouteAction): NavigationState {
@@ -49,7 +47,8 @@ class NavigationReducer {
4947
}
5048

5149
fun reduce(action: Action, oldState: NavigationState?): NavigationState {
52-
val state = oldState ?: NavigationReducer.handleAction(action = action, state = oldState)
50+
val state = oldState
51+
?: NavigationReducer.handleAction(action = action, state = oldState)
5352
when (action) {
5453
is SetRouteAction -> {
5554
return NavigationReducer.handleAction(action = action, state = state)
@@ -63,4 +62,4 @@ class NavigationReducer {
6362
}
6463

6564
}
66-
}
65+
}
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,16 @@
11
package org.rekotlinrouter
22

3-
4-
53
class FullRoute(route: Route) {
64
val routeString: String
75

86
init {
97
this.routeString = route.joinToString(separator = "/")
108
}
11-
129
}
1310

14-
data class NavigationState(var route: Route = arrayListOf() ,
15-
var routeSpecificState: HashMap<String,Any> = HashMap() ,
16-
var changeRouteAnimated: Boolean = true) {
17-
11+
data class NavigationState(var route: Route = arrayListOf(),
12+
var routeSpecificState: HashMap<String, Any> = HashMap(),
13+
var changeRouteAnimated: Boolean = true) {
1814

1915
fun <T> getRouteSpecificState(givenRoutes: Route): T? {
2016
val fullroute = FullRoute(givenRoutes)
@@ -24,8 +20,6 @@ data class NavigationState(var route: Route = arrayListOf() ,
2420
}
2521
}
2622

27-
28-
2923
interface HasNavigationState {
3024
var navigationState: NavigationState
31-
}
25+
}

0 commit comments

Comments
 (0)