mirror of
https://github.com/uber/RIBs.git
synced 2026-06-16 12:54:31 +00:00
Integrate Spotless into build (#415)
* Integrate Spotless in build * Update CONTRIBUTING.md * Move improperly placed copyright comments * Update copyright indent * Don't format test fixtures * Run spotlessApply over the whole repo * Remove checkstyle configs * Run spotlessCheck on CI
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,11 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uber.rib.core.RibActivity;
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
import com.uber.rib.root.RootBuilder;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,26 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
import com.uber.rib.root.logged_out.LoggedOutBuilder;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Scope;
|
||||
|
||||
import com.uber.rib.tutorial1.R;
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
import java.lang.annotation.Retention;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/** Builder for the {@link RootScope}. */
|
||||
public class RootBuilder extends ViewBuilder<RootView, RootRouter, RootBuilder.ParentComponent> {
|
||||
@@ -50,7 +45,8 @@ public class RootBuilder extends ViewBuilder<RootView, RootRouter, RootBuilder.P
|
||||
public RootRouter build(ViewGroup parentViewGroup) {
|
||||
RootView view = createView(parentViewGroup);
|
||||
RootInteractor interactor = new RootInteractor();
|
||||
Component component = DaggerRootBuilder_Component.builder()
|
||||
Component component =
|
||||
DaggerRootBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
@@ -82,14 +78,11 @@ public class RootBuilder extends ViewBuilder<RootView, RootRouter, RootBuilder.P
|
||||
}
|
||||
|
||||
@RootScope
|
||||
@dagger.Component(
|
||||
modules = Module.class,
|
||||
dependencies = ParentComponent.class
|
||||
)
|
||||
interface Component extends
|
||||
InteractorBaseComponent<RootInteractor>,
|
||||
LoggedOutBuilder.ParentComponent,
|
||||
BuilderComponent {
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component
|
||||
extends InteractorBaseComponent<RootInteractor>,
|
||||
LoggedOutBuilder.ParentComponent,
|
||||
BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,15 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.uber.rib.core.Bundle;
|
||||
import com.uber.rib.core.Interactor;
|
||||
import com.uber.rib.core.RibInteractor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/** Coordinates Business Logic for {@link RootBuilder.RootScope}. */
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,11 +13,9 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
import com.uber.rib.root.logged_out.LoggedOutBuilder;
|
||||
import com.uber.rib.root.logged_out.LoggedOutRouter;
|
||||
@@ -44,11 +42,7 @@ public class RootRouter extends ViewRouter<RootView, RootInteractor> {
|
||||
getView().addView(loggedOutRouter.getView());
|
||||
}
|
||||
|
||||
public void attachLoggedIn() {
|
||||
public void attachLoggedIn() {}
|
||||
|
||||
}
|
||||
|
||||
public void detachLoggedOut() {
|
||||
|
||||
}
|
||||
public void detachLoggedOut() {}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,13 +13,12 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/** Top level view for {@link RootBuilder.RootScope}. */
|
||||
public class RootView extends FrameLayout implements RootInteractor.RootPresenter {
|
||||
|
||||
+24
-37
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,30 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.off_game;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
/**
|
||||
* Builder for the {@link OffGameScope}.
|
||||
*/
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/** Builder for the {@link OffGameScope}. */
|
||||
public class OffGameBuilder
|
||||
extends ViewBuilder<OffGameView, OffGameRouter, OffGameBuilder.ParentComponent> {
|
||||
|
||||
@@ -53,11 +46,12 @@ public class OffGameBuilder
|
||||
public OffGameRouter build(ViewGroup parentViewGroup) {
|
||||
OffGameView view = createView(parentViewGroup);
|
||||
OffGameInteractor interactor = new OffGameInteractor();
|
||||
Component component = DaggerOffGameBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
Component component =
|
||||
DaggerOffGameBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.offgameRouter();
|
||||
}
|
||||
|
||||
@@ -81,16 +75,13 @@ public class OffGameBuilder
|
||||
@OffGameScope
|
||||
@Provides
|
||||
static OffGameRouter router(
|
||||
Component component,
|
||||
OffGameView view,
|
||||
OffGameInteractor interactor) {
|
||||
Component component, OffGameView view, OffGameInteractor interactor) {
|
||||
return new OffGameRouter(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
@OffGameScope
|
||||
@dagger.Component(modules = Module.class,
|
||||
dependencies = ParentComponent.class)
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<OffGameInteractor>, BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
@@ -115,13 +106,9 @@ public class OffGameBuilder
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface OffGameScope {
|
||||
|
||||
}
|
||||
@interface OffGameScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface OffGameInternal {
|
||||
|
||||
}
|
||||
@interface OffGameInternal {}
|
||||
}
|
||||
|
||||
+11
-18
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,23 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.off_game;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.uber.rib.core.Bundle;
|
||||
import com.uber.rib.core.Interactor;
|
||||
import com.uber.rib.core.RibInteractor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Coordinates Business Logic for {@link OffGameScope}.
|
||||
*/
|
||||
/** Coordinates Business Logic for {@link OffGameScope}. */
|
||||
@RibInteractor
|
||||
public class OffGameInteractor
|
||||
extends Interactor<OffGameInteractor.OffGamePresenter, OffGameRouter> {
|
||||
@@ -43,12 +37,13 @@ public class OffGameInteractor
|
||||
|
||||
presenter
|
||||
.startGameRequest()
|
||||
.subscribe(new Consumer<Object>() {
|
||||
@Override
|
||||
public void accept(Object object) throws Exception {
|
||||
listener.onStartGame();
|
||||
}
|
||||
});
|
||||
.subscribe(
|
||||
new Consumer<Object>() {
|
||||
@Override
|
||||
public void accept(Object object) throws Exception {
|
||||
listener.onStartGame();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
@@ -56,9 +51,7 @@ public class OffGameInteractor
|
||||
void onStartGame();
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
*/
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface OffGamePresenter {
|
||||
|
||||
Observable<Object> startGameRequest();
|
||||
|
||||
+4
-10
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,21 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.off_game;
|
||||
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
|
||||
/**
|
||||
* Adds and removes children of {@link OffGameBuilder.OffGameScope}.
|
||||
*/
|
||||
public class OffGameRouter extends
|
||||
ViewRouter<OffGameView, OffGameInteractor> {
|
||||
/** Adds and removes children of {@link OffGameBuilder.OffGameScope}. */
|
||||
public class OffGameRouter extends ViewRouter<OffGameView, OffGameInteractor> {
|
||||
|
||||
public OffGameRouter(
|
||||
OffGameView view,
|
||||
OffGameInteractor interactor,
|
||||
OffGameBuilder.Component component) {
|
||||
OffGameView view, OffGameInteractor interactor, OffGameBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
+3
-8
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,24 +13,19 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.off_game;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.uber.rib.core.Initializer;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
/**
|
||||
* Top level view for {@link OffGameBuilder.OffGameScope}.
|
||||
*/
|
||||
/** Top level view for {@link OffGameBuilder.OffGameScope}. */
|
||||
public class OffGameView extends LinearLayout implements OffGameInteractor.OffGamePresenter {
|
||||
|
||||
private Button button;
|
||||
|
||||
+13
-18
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.tic_tac_toe;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@@ -37,9 +36,7 @@ class Board {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if it is a draw (i.e., no more EMPTY cell)
|
||||
*/
|
||||
/** Return true if it is a draw (i.e., no more EMPTY cell) */
|
||||
boolean isDraw() {
|
||||
for (int row = 0; row < ROWS; ++row) {
|
||||
for (int col = 0; col < COLS; ++col) {
|
||||
@@ -51,24 +48,22 @@ class Board {
|
||||
return !hasWon(MarkerType.CROSS) && !hasWon(MarkerType.NOUGHT);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return true if the player with "theSeed" has won after placing at (currentRow, currentCol)
|
||||
*/
|
||||
/** Return true if the player with "theSeed" has won after placing at (currentRow, currentCol) */
|
||||
boolean hasWon(MarkerType theSeed) {
|
||||
return ((cells[currentRow][0] == theSeed
|
||||
&& cells[currentRow][1] == theSeed
|
||||
&& cells[currentRow][2] == theSeed)
|
||||
&& cells[currentRow][1] == theSeed
|
||||
&& cells[currentRow][2] == theSeed)
|
||||
|| (cells[0][currentCol] == theSeed
|
||||
&& cells[1][currentCol] == theSeed
|
||||
&& cells[2][currentCol] == theSeed)
|
||||
&& cells[1][currentCol] == theSeed
|
||||
&& cells[2][currentCol] == theSeed)
|
||||
|| (currentRow == currentCol
|
||||
&& cells[0][0] == theSeed
|
||||
&& cells[1][1] == theSeed
|
||||
&& cells[2][2] == theSeed)
|
||||
&& cells[0][0] == theSeed
|
||||
&& cells[1][1] == theSeed
|
||||
&& cells[2][2] == theSeed)
|
||||
|| (currentRow + currentCol == 2
|
||||
&& cells[0][2] == theSeed
|
||||
&& cells[1][1] == theSeed
|
||||
&& cells[2][0] == theSeed));
|
||||
&& cells[0][2] == theSeed
|
||||
&& cells[1][1] == theSeed
|
||||
&& cells[2][0] == theSeed));
|
||||
}
|
||||
|
||||
enum MarkerType {
|
||||
|
||||
+1
-2
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.tic_tac_toe;
|
||||
|
||||
class BoardCoordinate {
|
||||
|
||||
+24
-37
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,30 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.tic_tac_toe;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
/**
|
||||
* Builder for the {@link TicTacToeScope}.
|
||||
*/
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/** Builder for the {@link TicTacToeScope}. */
|
||||
public class TicTacToeBuilder
|
||||
extends ViewBuilder<TicTacToeView, TicTacToeRouter, TicTacToeBuilder.ParentComponent> {
|
||||
|
||||
@@ -53,11 +46,12 @@ public class TicTacToeBuilder
|
||||
public TicTacToeRouter build(ViewGroup parentViewGroup) {
|
||||
TicTacToeView view = createView(parentViewGroup);
|
||||
TicTacToeInteractor interactor = new TicTacToeInteractor();
|
||||
Component component = DaggerTicTacToeBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
Component component =
|
||||
DaggerTicTacToeBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.tictactoeRouter();
|
||||
}
|
||||
|
||||
@@ -80,16 +74,13 @@ public class TicTacToeBuilder
|
||||
@TicTacToeScope
|
||||
@Provides
|
||||
static TicTacToeRouter router(
|
||||
Component component,
|
||||
TicTacToeView view,
|
||||
TicTacToeInteractor interactor) {
|
||||
Component component, TicTacToeView view, TicTacToeInteractor interactor) {
|
||||
return new TicTacToeRouter(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
@TicTacToeScope
|
||||
@dagger.Component(modules = Module.class,
|
||||
dependencies = ParentComponent.class)
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<TicTacToeInteractor>, BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
@@ -114,13 +105,9 @@ public class TicTacToeBuilder
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface TicTacToeScope {
|
||||
|
||||
}
|
||||
@interface TicTacToeScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface TicTacToeInternal {
|
||||
|
||||
}
|
||||
@interface TicTacToeInternal {}
|
||||
}
|
||||
|
||||
+37
-48
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,27 +13,21 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.tic_tac_toe;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.uber.rib.core.Bundle;
|
||||
import com.uber.rib.core.Interactor;
|
||||
import com.uber.rib.core.RibInteractor;
|
||||
import com.uber.rib.root.logged_in.tic_tac_toe.Board.MarkerType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Coordinates Business Logic for {@link TicTacToeScope}.
|
||||
*/
|
||||
/** Coordinates Business Logic for {@link TicTacToeScope}. */
|
||||
@RibInteractor
|
||||
public class TicTacToeInteractor
|
||||
extends Interactor<TicTacToeInteractor.TicTacToePresenter, TicTacToeRouter> {
|
||||
extends Interactor<TicTacToeInteractor.TicTacToePresenter, TicTacToeRouter> {
|
||||
|
||||
@Inject Board board;
|
||||
@Inject TicTacToePresenter presenter;
|
||||
@@ -48,37 +42,37 @@ public class TicTacToeInteractor
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
|
||||
presenter
|
||||
.squareClicks()
|
||||
.subscribe(
|
||||
new Consumer<BoardCoordinate>() {
|
||||
@Override
|
||||
public void accept(BoardCoordinate xy) throws Exception {
|
||||
if (board.cells[xy.getX()][xy.getY()] == null) {
|
||||
if (currentPlayer == MarkerType.CROSS) {
|
||||
board.cells[xy.getX()][xy.getY()] = MarkerType.CROSS;
|
||||
board.currentRow = xy.getX();
|
||||
board.currentCol = xy.getY();
|
||||
presenter.addCross(xy);
|
||||
currentPlayer = MarkerType.NOUGHT;
|
||||
} else {
|
||||
board.cells[xy.getX()][xy.getY()] = MarkerType.NOUGHT;
|
||||
board.currentRow = xy.getX();
|
||||
board.currentCol = xy.getY();
|
||||
presenter.addNought(xy);
|
||||
currentPlayer = MarkerType.CROSS;
|
||||
}
|
||||
}
|
||||
if (board.hasWon(MarkerType.CROSS)) {
|
||||
presenter.setPlayerWon(playerOne);
|
||||
} else if (board.hasWon(MarkerType.NOUGHT)) {
|
||||
presenter.setPlayerWon(playerTwo);
|
||||
} else if (board.isDraw()) {
|
||||
presenter.setPlayerTie();
|
||||
} else {
|
||||
updateCurrentPlayer();
|
||||
}
|
||||
}
|
||||
});
|
||||
.squareClicks()
|
||||
.subscribe(
|
||||
new Consumer<BoardCoordinate>() {
|
||||
@Override
|
||||
public void accept(BoardCoordinate xy) throws Exception {
|
||||
if (board.cells[xy.getX()][xy.getY()] == null) {
|
||||
if (currentPlayer == MarkerType.CROSS) {
|
||||
board.cells[xy.getX()][xy.getY()] = MarkerType.CROSS;
|
||||
board.currentRow = xy.getX();
|
||||
board.currentCol = xy.getY();
|
||||
presenter.addCross(xy);
|
||||
currentPlayer = MarkerType.NOUGHT;
|
||||
} else {
|
||||
board.cells[xy.getX()][xy.getY()] = MarkerType.NOUGHT;
|
||||
board.currentRow = xy.getX();
|
||||
board.currentCol = xy.getY();
|
||||
presenter.addNought(xy);
|
||||
currentPlayer = MarkerType.CROSS;
|
||||
}
|
||||
}
|
||||
if (board.hasWon(MarkerType.CROSS)) {
|
||||
presenter.setPlayerWon(playerOne);
|
||||
} else if (board.hasWon(MarkerType.NOUGHT)) {
|
||||
presenter.setPlayerWon(playerTwo);
|
||||
} else if (board.isDraw()) {
|
||||
presenter.setPlayerTie();
|
||||
} else {
|
||||
updateCurrentPlayer();
|
||||
}
|
||||
}
|
||||
});
|
||||
updateCurrentPlayer();
|
||||
}
|
||||
|
||||
@@ -90,10 +84,7 @@ public class TicTacToeInteractor
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
*/
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface TicTacToePresenter {
|
||||
Observable<BoardCoordinate> squareClicks();
|
||||
|
||||
@@ -108,7 +99,5 @@ public class TicTacToeInteractor
|
||||
void addNought(BoardCoordinate xy);
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
|
||||
}
|
||||
public interface Listener {}
|
||||
}
|
||||
|
||||
+4
-10
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,21 +13,15 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.tic_tac_toe;
|
||||
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
|
||||
/**
|
||||
* Adds and removes children of {@link TicTacToeBuilder.TicTacToeScope}.
|
||||
*/
|
||||
public class TicTacToeRouter extends
|
||||
ViewRouter<TicTacToeView, TicTacToeInteractor> {
|
||||
/** Adds and removes children of {@link TicTacToeBuilder.TicTacToeScope}. */
|
||||
public class TicTacToeRouter extends ViewRouter<TicTacToeView, TicTacToeInteractor> {
|
||||
|
||||
public TicTacToeRouter(
|
||||
TicTacToeView view,
|
||||
TicTacToeInteractor interactor,
|
||||
TicTacToeBuilder.Component component) {
|
||||
TicTacToeView view, TicTacToeInteractor interactor, TicTacToeBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
+19
-25
@@ -5,7 +5,7 @@
|
||||
* 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
|
||||
* 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,
|
||||
@@ -13,29 +13,23 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in.tic_tac_toe;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.percentlayout.widget.PercentRelativeLayout;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import androidx.percentlayout.widget.PercentRelativeLayout;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.uber.rib.core.Initializer;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Function;
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* Top level view for {@link TicTacToeBuilder.TicTacToeScope}.
|
||||
*/
|
||||
public class TicTacToeView extends PercentRelativeLayout implements
|
||||
TicTacToeInteractor.TicTacToePresenter {
|
||||
/** Top level view for {@link TicTacToeBuilder.TicTacToeScope}. */
|
||||
public class TicTacToeView extends PercentRelativeLayout
|
||||
implements TicTacToeInteractor.TicTacToePresenter {
|
||||
|
||||
private TextView[][] imageButtons;
|
||||
private TextView titleView;
|
||||
@@ -58,22 +52,22 @@ public class TicTacToeView extends PercentRelativeLayout implements
|
||||
super.onFinishInflate();
|
||||
imageButtons = new TextView[3][];
|
||||
imageButtons[0] =
|
||||
new TextView[]{
|
||||
(TextView) findViewById(R.id.button11),
|
||||
(TextView) findViewById(R.id.button12),
|
||||
(TextView) findViewById(R.id.button13)
|
||||
new TextView[] {
|
||||
(TextView) findViewById(R.id.button11),
|
||||
(TextView) findViewById(R.id.button12),
|
||||
(TextView) findViewById(R.id.button13)
|
||||
};
|
||||
imageButtons[1] =
|
||||
new TextView[]{
|
||||
(TextView) findViewById(R.id.button21),
|
||||
(TextView) findViewById(R.id.button22),
|
||||
(TextView) findViewById(R.id.button23)
|
||||
new TextView[] {
|
||||
(TextView) findViewById(R.id.button21),
|
||||
(TextView) findViewById(R.id.button22),
|
||||
(TextView) findViewById(R.id.button23)
|
||||
};
|
||||
imageButtons[2] =
|
||||
new TextView[]{
|
||||
(TextView) findViewById(R.id.button31),
|
||||
(TextView) findViewById(R.id.button32),
|
||||
(TextView) findViewById(R.id.button33)
|
||||
new TextView[] {
|
||||
(TextView) findViewById(R.id.button31),
|
||||
(TextView) findViewById(R.id.button32),
|
||||
(TextView) findViewById(R.id.button33)
|
||||
};
|
||||
titleView = (TextView) findViewById(R.id.title);
|
||||
}
|
||||
|
||||
+94
-84
@@ -1,103 +1,113 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root.logged_out;
|
||||
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Scope;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
import dagger.Provides;
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
/**
|
||||
* Builder for the {@link LoggedOutScope}.
|
||||
*/
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.ViewGroup;
|
||||
import com.uber.rib.core.InteractorBaseComponent;
|
||||
import com.uber.rib.core.ViewBuilder;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/** Builder for the {@link LoggedOutScope}. */
|
||||
public class LoggedOutBuilder
|
||||
extends ViewBuilder<LoggedOutView, LoggedOutRouter, LoggedOutBuilder.ParentComponent> {
|
||||
extends ViewBuilder<LoggedOutView, LoggedOutRouter, LoggedOutBuilder.ParentComponent> {
|
||||
|
||||
public LoggedOutBuilder(ParentComponent dependency) {
|
||||
super(dependency);
|
||||
}
|
||||
public LoggedOutBuilder(ParentComponent dependency) {
|
||||
super(dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new {@link LoggedOutRouter}.
|
||||
*
|
||||
* @param parentViewGroup parent view group that this router's view will be added to.
|
||||
* @return a new {@link LoggedOutRouter}.
|
||||
*/
|
||||
public LoggedOutRouter build(ViewGroup parentViewGroup) {
|
||||
LoggedOutView view = createView(parentViewGroup);
|
||||
LoggedOutInteractor interactor = new LoggedOutInteractor();
|
||||
Component component = DaggerLoggedOutBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.loggedoutRouter();
|
||||
}
|
||||
/**
|
||||
* Builds a new {@link LoggedOutRouter}.
|
||||
*
|
||||
* @param parentViewGroup parent view group that this router's view will be added to.
|
||||
* @return a new {@link LoggedOutRouter}.
|
||||
*/
|
||||
public LoggedOutRouter build(ViewGroup parentViewGroup) {
|
||||
LoggedOutView view = createView(parentViewGroup);
|
||||
LoggedOutInteractor interactor = new LoggedOutInteractor();
|
||||
Component component =
|
||||
DaggerLoggedOutBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.loggedoutRouter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected LoggedOutView inflateView(LayoutInflater inflater, ViewGroup parentViewGroup) {
|
||||
return (LoggedOutView) inflater.inflate(R.layout.logged_out_rib, parentViewGroup, false);
|
||||
}
|
||||
@Override
|
||||
protected LoggedOutView inflateView(LayoutInflater inflater, ViewGroup parentViewGroup) {
|
||||
return (LoggedOutView) inflater.inflate(R.layout.logged_out_rib, parentViewGroup, false);
|
||||
}
|
||||
|
||||
public interface ParentComponent {
|
||||
// TODO: Define dependencies required from your parent interactor here.
|
||||
}
|
||||
public interface ParentComponent {
|
||||
// TODO: Define dependencies required from your parent interactor here.
|
||||
}
|
||||
|
||||
@dagger.Module
|
||||
public abstract static class Module {
|
||||
|
||||
@LoggedOutScope
|
||||
@Binds
|
||||
abstract LoggedOutInteractor.LoggedOutPresenter presenter(LoggedOutView view);
|
||||
|
||||
@LoggedOutScope
|
||||
@Provides
|
||||
static LoggedOutRouter router(
|
||||
Component component,
|
||||
LoggedOutView view,
|
||||
LoggedOutInteractor interactor) {
|
||||
return new LoggedOutRouter(view, interactor, component);
|
||||
}
|
||||
|
||||
// TODO: Create provider methods for dependencies created by this Rib. These should be static.
|
||||
}
|
||||
@dagger.Module
|
||||
public abstract static class Module {
|
||||
|
||||
@LoggedOutScope
|
||||
@dagger.Component(modules = Module.class,
|
||||
dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<LoggedOutInteractor>, BuilderComponent {
|
||||
@Binds
|
||||
abstract LoggedOutInteractor.LoggedOutPresenter presenter(LoggedOutView view);
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
Builder interactor(LoggedOutInteractor interactor);
|
||||
@BindsInstance
|
||||
Builder view(LoggedOutView view);
|
||||
Builder parentComponent(ParentComponent component);
|
||||
Component build();
|
||||
}
|
||||
@LoggedOutScope
|
||||
@Provides
|
||||
static LoggedOutRouter router(
|
||||
Component component, LoggedOutView view, LoggedOutInteractor interactor) {
|
||||
return new LoggedOutRouter(view, interactor, component);
|
||||
}
|
||||
|
||||
interface BuilderComponent {
|
||||
LoggedOutRouter loggedoutRouter();
|
||||
// TODO: Create provider methods for dependencies created by this Rib. These should be static.
|
||||
}
|
||||
|
||||
@LoggedOutScope
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<LoggedOutInteractor>, BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
Builder interactor(LoggedOutInteractor interactor);
|
||||
|
||||
@BindsInstance
|
||||
Builder view(LoggedOutView view);
|
||||
|
||||
Builder parentComponent(ParentComponent component);
|
||||
|
||||
Component build();
|
||||
}
|
||||
}
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface LoggedOutScope { }
|
||||
interface BuilderComponent {
|
||||
LoggedOutRouter loggedoutRouter();
|
||||
}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface LoggedOutInternal { }
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface LoggedOutScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface LoggedOutInternal {}
|
||||
}
|
||||
|
||||
+36
-28
@@ -1,45 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root.logged_out;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.Log;
|
||||
import android.widget.Toast;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.uber.rib.core.Bundle;
|
||||
import com.uber.rib.core.Interactor;
|
||||
import com.uber.rib.core.RibInteractor;
|
||||
import com.uber.rib.root.logged_out.LoggedOutBuilder.LoggedOutScope;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Coordinates Business Logic for {@link LoggedOutScope}.
|
||||
*/
|
||||
/** Coordinates Business Logic for {@link LoggedOutScope}. */
|
||||
@RibInteractor
|
||||
public class LoggedOutInteractor
|
||||
extends Interactor<LoggedOutInteractor.LoggedOutPresenter, LoggedOutRouter> {
|
||||
extends Interactor<LoggedOutInteractor.LoggedOutPresenter, LoggedOutRouter> {
|
||||
|
||||
@Inject LoggedOutPresenter presenter;
|
||||
@Inject LoggedOutPresenter presenter;
|
||||
|
||||
@Override
|
||||
protected void didBecomeActive(@Nullable Bundle savedInstanceState) {
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
presenter
|
||||
.loginName()
|
||||
.subscribe(new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(String name) throws Exception {
|
||||
Log.d("MOO", name);
|
||||
}
|
||||
@Override
|
||||
protected void didBecomeActive(@Nullable Bundle savedInstanceState) {
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
presenter
|
||||
.loginName()
|
||||
.subscribe(
|
||||
new Consumer<String>() {
|
||||
@Override
|
||||
public void accept(String name) throws Exception {
|
||||
Log.d("MOO", name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
*/
|
||||
interface LoggedOutPresenter {
|
||||
Observable<String> loginName();
|
||||
}
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface LoggedOutPresenter {
|
||||
Observable<String> loginName();
|
||||
}
|
||||
}
|
||||
|
||||
+21
-11
@@ -1,17 +1,27 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root.logged_out;
|
||||
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
|
||||
/**
|
||||
* Adds and removes children of {@link LoggedOutBuilder.LoggedOutScope}.
|
||||
*/
|
||||
public class LoggedOutRouter extends
|
||||
ViewRouter<LoggedOutView, LoggedOutInteractor> {
|
||||
/** Adds and removes children of {@link LoggedOutBuilder.LoggedOutScope}. */
|
||||
public class LoggedOutRouter extends ViewRouter<LoggedOutView, LoggedOutInteractor> {
|
||||
|
||||
public LoggedOutRouter(
|
||||
LoggedOutView view,
|
||||
LoggedOutInteractor interactor,
|
||||
LoggedOutBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
public LoggedOutRouter(
|
||||
LoggedOutView view, LoggedOutInteractor interactor, LoggedOutBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
+37
-26
@@ -1,44 +1,55 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root.logged_out;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.widget.FrameLayout;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.uber.rib.tutorial1.R;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Function;
|
||||
|
||||
/**
|
||||
* Top level view for {@link LoggedOutBuilder.LoggedOutScope}.
|
||||
*/
|
||||
/** Top level view for {@link LoggedOutBuilder.LoggedOutScope}. */
|
||||
public class LoggedOutView extends LinearLayout implements LoggedOutInteractor.LoggedOutPresenter {
|
||||
|
||||
public LoggedOutView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
public LoggedOutView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public LoggedOutView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
public LoggedOutView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public LoggedOutView(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
public LoggedOutView(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Observable<String> loginName() {
|
||||
return RxView.clicks(findViewById(R.id.login_button))
|
||||
.map(new Function<Object, String>() {
|
||||
@Override
|
||||
public String apply(Object o) throws Exception {
|
||||
TextView textView = (TextView) findViewById(R.id.edit_text);
|
||||
return textView.getText().toString();
|
||||
}
|
||||
@Override
|
||||
public Observable<String> loginName() {
|
||||
return RxView.clicks(findViewById(R.id.login_button))
|
||||
.map(
|
||||
new Function<Object, String>() {
|
||||
@Override
|
||||
public String apply(Object o) throws Exception {
|
||||
TextView textView = (TextView) findViewById(R.id.edit_text);
|
||||
return textView.getText().toString();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,18 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root;
|
||||
|
||||
import org.junit.Before;
|
||||
|
||||
@@ -1,7 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root;
|
||||
|
||||
import com.uber.rib.root.logged_out.LoggedOutBuilder;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
+26
-16
@@ -1,8 +1,21 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root.logged_out;
|
||||
|
||||
import com.uber.rib.core.RibTestBasePlaceholder;
|
||||
import com.uber.rib.core.InteractorHelper;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
@@ -11,22 +24,19 @@ import org.mockito.MockitoAnnotations;
|
||||
@SuppressWarnings("NullAway")
|
||||
public class LoggedOutInteractorTest extends RibTestBasePlaceholder {
|
||||
|
||||
@Mock LoggedOutInteractor.LoggedOutPresenter presenter;
|
||||
@Mock LoggedOutRouter router;
|
||||
@Mock LoggedOutInteractor.LoggedOutPresenter presenter;
|
||||
@Mock LoggedOutRouter router;
|
||||
|
||||
private LoggedOutInteractor interactor;
|
||||
private LoggedOutInteractor interactor;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
|
||||
interactor = TestLoggedOutInteractor.create(presenter);
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Delete this example and add real tests.
|
||||
*/
|
||||
@Test
|
||||
public void anExampleTest_withSomeConditions_shouldPass() { }
|
||||
interactor = TestLoggedOutInteractor.create(presenter);
|
||||
}
|
||||
|
||||
/** TODO: Delete this example and add real tests. */
|
||||
@Test
|
||||
public void anExampleTest_withSomeConditions_shouldPass() {}
|
||||
}
|
||||
|
||||
+23
-11
@@ -1,24 +1,36 @@
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
* 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.uber.rib.root.logged_out;
|
||||
|
||||
import com.uber.rib.core.RibTestBasePlaceholder;
|
||||
import com.uber.rib.core.RouterHelper;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.MockitoAnnotations;
|
||||
|
||||
@SuppressWarnings("NullAway")
|
||||
public class LoggedOutRouterTest extends RibTestBasePlaceholder {
|
||||
|
||||
@Mock LoggedOutBuilder.Component component;
|
||||
@Mock LoggedOutInteractor interactor;
|
||||
@Mock LoggedOutView view;
|
||||
@Mock LoggedOutBuilder.Component component;
|
||||
@Mock LoggedOutInteractor interactor;
|
||||
@Mock LoggedOutView view;
|
||||
|
||||
private LoggedOutRouter router;
|
||||
private LoggedOutRouter router;
|
||||
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
@Before
|
||||
public void setup() {
|
||||
MockitoAnnotations.initMocks(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user