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,18 +13,17 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import com.google.common.base.Optional;
|
||||
import com.uber.autodispose.AutoDispose;
|
||||
import com.uber.rave.Rave;
|
||||
import com.uber.rave.RaveException;
|
||||
import com.google.common.base.Optional;
|
||||
import com.uber.rib.core.RibActivity;
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
import com.uber.rib.root.RootBuilder;
|
||||
@@ -32,9 +31,6 @@ import com.uber.rib.root.RootInteractor;
|
||||
import com.uber.rib.root.RootRouter;
|
||||
import com.uber.rib.root.RootWorkflow;
|
||||
import com.uber.rib.root.WorkflowFactory;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import io.reactivex.functions.Consumer;
|
||||
|
||||
/** The sample app's single activity. */
|
||||
@@ -79,7 +75,5 @@ public class RootActivity extends RibActivity {
|
||||
}
|
||||
}
|
||||
|
||||
private class RootReturnValue {
|
||||
|
||||
}
|
||||
private class RootReturnValue {}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 com.uber.rib.workflow.core.ActionableItem;
|
||||
|
||||
@@ -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;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
@@ -32,9 +31,7 @@ import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/**
|
||||
* Builder for the {@link RootScope}.
|
||||
*/
|
||||
/** Builder for the {@link RootScope}. */
|
||||
public class RootBuilder extends ViewBuilder<RootView, RootRouter, RootBuilder.ParentComponent> {
|
||||
|
||||
public RootBuilder(ParentComponent dependency) {
|
||||
@@ -50,11 +47,12 @@ 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()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
Component component =
|
||||
DaggerRootBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.rootRouter();
|
||||
}
|
||||
|
||||
@@ -93,15 +91,12 @@ 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,
|
||||
LoggedInBuilder.ParentComponent,
|
||||
BuilderComponent {
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component
|
||||
extends InteractorBaseComponent<RootInteractor>,
|
||||
LoggedOutBuilder.ParentComponent,
|
||||
LoggedInBuilder.ParentComponent,
|
||||
BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
@@ -125,7 +120,5 @@ public class RootBuilder extends ViewBuilder<RootView, RootRouter, RootBuilder.P
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface RootScope {
|
||||
|
||||
}
|
||||
@interface 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,7 +13,6 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -23,12 +22,9 @@ import com.uber.rib.core.RibInteractor;
|
||||
import com.uber.rib.root.logged_out.LoggedOutInteractor;
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Coordinates Business Logic for {@link RootBuilder.RootScope}.
|
||||
*/
|
||||
/** Coordinates Business Logic for {@link RootBuilder.RootScope}. */
|
||||
@RibInteractor
|
||||
public class RootInteractor
|
||||
extends Interactor<RootInteractor.RootPresenter, RootRouter>
|
||||
public class RootInteractor extends Interactor<RootInteractor.RootPresenter, RootRouter>
|
||||
implements RootActionableItem {
|
||||
|
||||
@Inject RootPresenter presenter;
|
||||
@@ -49,8 +45,6 @@ public class RootInteractor
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
*/
|
||||
interface RootPresenter { }
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface RootPresenter {}
|
||||
}
|
||||
|
||||
@@ -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,11 @@
|
||||
* 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.jakewharton.rxrelay2.BehaviorRelay;
|
||||
import com.google.common.base.Optional;
|
||||
import com.jakewharton.rxrelay2.BehaviorRelay;
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
import com.uber.rib.root.logged_in.LoggedInActionableItem;
|
||||
import com.uber.rib.root.logged_in.LoggedInBuilder;
|
||||
@@ -27,9 +25,7 @@ import com.uber.rib.root.logged_in.LoggedInRouter;
|
||||
import com.uber.rib.root.logged_out.LoggedOutBuilder;
|
||||
import com.uber.rib.root.logged_out.LoggedOutRouter;
|
||||
|
||||
/**
|
||||
* Adds and removes children of {@link RootBuilder.RootScope}.
|
||||
*/
|
||||
/** Adds and removes children of {@link RootBuilder.RootScope}. */
|
||||
public class RootRouter extends ViewRouter<RootView, RootInteractor> {
|
||||
|
||||
private final LoggedOutBuilder loggedOutBuilder;
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1,10 +1,23 @@
|
||||
/*
|
||||
* 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 android.content.Intent;
|
||||
|
||||
import com.uber.rib.workflow.core.Step;
|
||||
import com.uber.rib.workflow.core.Workflow;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
|
||||
@@ -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 java.io.Serializable;
|
||||
|
||||
+15
-1
@@ -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 androidx.annotation.NonNull;
|
||||
|
||||
import com.uber.rave.BaseValidator;
|
||||
import com.uber.rave.ValidatorFactory;
|
||||
import com.uber.rave.annotation.Validated;
|
||||
|
||||
@@ -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 androidx.annotation.NonNull;
|
||||
|
||||
import com.google.auto.value.AutoValue;
|
||||
|
||||
@AutoValue
|
||||
|
||||
@@ -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 android.content.Intent;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
public class WorkflowFactory {
|
||||
|
||||
@@ -1,5 +1,20 @@
|
||||
/*
|
||||
* 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_in;
|
||||
|
||||
public interface GameKey {
|
||||
String gameName();
|
||||
}
|
||||
String gameName();
|
||||
}
|
||||
|
||||
+18
-4
@@ -1,11 +1,25 @@
|
||||
/*
|
||||
* 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_in;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
|
||||
public interface GameProvider extends GameKey {
|
||||
String gameName();
|
||||
ViewRouter viewRouter(ViewGroup viewGroup);
|
||||
}
|
||||
String gameName();
|
||||
|
||||
ViewRouter viewRouter(ViewGroup viewGroup);
|
||||
}
|
||||
|
||||
+16
-1
@@ -1,5 +1,20 @@
|
||||
/*
|
||||
* 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_in;
|
||||
|
||||
import com.uber.rib.workflow.core.ActionableItem;
|
||||
|
||||
public interface LoggedInActionableItem extends ActionableItem {}
|
||||
public interface LoggedInActionableItem extends ActionableItem {}
|
||||
|
||||
+44
-50
@@ -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,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.uber.rib.core.Builder;
|
||||
import com.uber.rib.core.EmptyPresenter;
|
||||
@@ -38,7 +36,6 @@ import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
@@ -56,17 +53,17 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
*/
|
||||
public LoggedInRouter build(UserName playerOne, UserName playerTwo) {
|
||||
LoggedInInteractor interactor = new LoggedInInteractor();
|
||||
Component component = DaggerLoggedInBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.interactor(interactor)
|
||||
.playerOne(playerOne)
|
||||
.playerTwo(playerTwo)
|
||||
.build();
|
||||
Component component =
|
||||
DaggerLoggedInBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.interactor(interactor)
|
||||
.playerOne(playerOne)
|
||||
.playerTwo(playerTwo)
|
||||
.build();
|
||||
|
||||
return component.loggedinRouter();
|
||||
}
|
||||
|
||||
|
||||
public interface ParentComponent {
|
||||
|
||||
RootView rootView();
|
||||
@@ -83,8 +80,8 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
|
||||
@LoggedInScope
|
||||
@Provides
|
||||
static LoggedInRouter router(Component component, LoggedInInteractor interactor,
|
||||
RootView rootView) {
|
||||
static LoggedInRouter router(
|
||||
Component component, LoggedInInteractor interactor, RootView rootView) {
|
||||
return new LoggedInRouter(
|
||||
interactor,
|
||||
component,
|
||||
@@ -97,8 +94,7 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
@LoggedInInternal
|
||||
@Provides
|
||||
static MutableScoreStream mutableScoreStream(
|
||||
@Named("player_one") UserName playerOne,
|
||||
@Named("player_two") UserName playerTwo) {
|
||||
@Named("player_one") UserName playerOne, @Named("player_two") UserName playerTwo) {
|
||||
return new MutableScoreStream(playerOne, playerTwo);
|
||||
}
|
||||
|
||||
@@ -110,11 +106,13 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
|
||||
@LoggedInScope
|
||||
@Binds
|
||||
abstract RandomWinnerInteractor.Listener randomWinnerListener(LoggedInInteractor.GameListener listener);
|
||||
abstract RandomWinnerInteractor.Listener randomWinnerListener(
|
||||
LoggedInInteractor.GameListener listener);
|
||||
|
||||
@LoggedInScope
|
||||
@Binds
|
||||
abstract TicTacToeInteractor.Listener ticTacToeGameListener(LoggedInInteractor.GameListener listener);
|
||||
abstract TicTacToeInteractor.Listener ticTacToeGameListener(
|
||||
LoggedInInteractor.GameListener listener);
|
||||
|
||||
@LoggedInScope
|
||||
@Provides
|
||||
@@ -130,28 +128,30 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
@Provides
|
||||
static List<GameProvider> gameProviders(final Component component) {
|
||||
// Decorate the game builders with a "name" key so we can treat them generically elsewhere.
|
||||
GameProvider ticTacToeGame = new GameProvider() {
|
||||
@Override
|
||||
public String gameName() {
|
||||
return "TicTacToe";
|
||||
}
|
||||
GameProvider ticTacToeGame =
|
||||
new GameProvider() {
|
||||
@Override
|
||||
public String gameName() {
|
||||
return "TicTacToe";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewRouter viewRouter(ViewGroup viewGroup) {
|
||||
return new TicTacToeBuilder(component).build(viewGroup);
|
||||
}
|
||||
};
|
||||
GameProvider randomWinnerGame = new GameProvider() {
|
||||
@Override
|
||||
public String gameName() {
|
||||
return "RandomWinner";
|
||||
}
|
||||
@Override
|
||||
public ViewRouter viewRouter(ViewGroup viewGroup) {
|
||||
return new TicTacToeBuilder(component).build(viewGroup);
|
||||
}
|
||||
};
|
||||
GameProvider randomWinnerGame =
|
||||
new GameProvider() {
|
||||
@Override
|
||||
public String gameName() {
|
||||
return "RandomWinner";
|
||||
}
|
||||
|
||||
@Override
|
||||
public ViewRouter viewRouter(ViewGroup viewGroup) {
|
||||
return new RandomWinnerBuilder(component).build(viewGroup);
|
||||
}
|
||||
};
|
||||
@Override
|
||||
public ViewRouter viewRouter(ViewGroup viewGroup) {
|
||||
return new RandomWinnerBuilder(component).build(viewGroup);
|
||||
}
|
||||
};
|
||||
return Lists.newArrayList(ticTacToeGame, randomWinnerGame);
|
||||
}
|
||||
|
||||
@@ -164,10 +164,10 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
public interface Component
|
||||
extends InteractorBaseComponent<LoggedInInteractor>,
|
||||
BuilderComponent,
|
||||
OffGameBuilder.ParentComponent,
|
||||
TicTacToeBuilder.ParentComponent,
|
||||
RandomWinnerBuilder.ParentComponent {
|
||||
BuilderComponent,
|
||||
OffGameBuilder.ParentComponent,
|
||||
TicTacToeBuilder.ParentComponent,
|
||||
RandomWinnerBuilder.ParentComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
@@ -185,7 +185,6 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
@BindsInstance
|
||||
Builder playerTwo(@Named("player_two") UserName playerTwo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
interface BuilderComponent {
|
||||
@@ -194,14 +193,9 @@ public class LoggedInBuilder extends Builder<LoggedInRouter, LoggedInBuilder.Par
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface LoggedInScope {
|
||||
|
||||
}
|
||||
|
||||
@interface LoggedInScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface LoggedInInternal {
|
||||
|
||||
}
|
||||
@interface LoggedInInternal {}
|
||||
}
|
||||
|
||||
+3
-11
@@ -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;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -26,18 +25,12 @@ import com.uber.rib.root.logged_in.LoggedInBuilder.LoggedInInternal;
|
||||
import com.uber.rib.root.logged_in.off_game.OffGameInteractor;
|
||||
import com.uber.rib.root.logged_in.random_winner.RandomWinnerInteractor;
|
||||
import com.uber.rib.root.logged_in.tic_tac_toe.TicTacToeInteractor;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
/**
|
||||
* Coordinates Business Logic for {@link LoggedInScope}.
|
||||
*/
|
||||
/** Coordinates Business Logic for {@link LoggedInScope}. */
|
||||
@RibInteractor
|
||||
public class LoggedInInteractor
|
||||
extends Interactor<EmptyPresenter, LoggedInRouter>
|
||||
public class LoggedInInteractor extends Interactor<EmptyPresenter, LoggedInRouter>
|
||||
implements LoggedInActionableItem {
|
||||
|
||||
@Inject @LoggedInInternal MutableScoreStream scoreStream;
|
||||
@@ -49,7 +42,6 @@ public class LoggedInInteractor
|
||||
|
||||
// when first logging in we should be in the OffGame state
|
||||
getRouter().attachOffGame();
|
||||
|
||||
}
|
||||
|
||||
class OffGameListener implements OffGameInteractor.Listener {
|
||||
|
||||
+3
-7
@@ -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;
|
||||
|
||||
import android.view.ViewGroup;
|
||||
@@ -23,11 +22,8 @@ import com.uber.rib.root.logged_in.off_game.OffGameBuilder;
|
||||
import com.uber.rib.root.logged_in.off_game.OffGameRouter;
|
||||
import com.uber.rib.root.logged_in.tic_tac_toe.TicTacToeBuilder;
|
||||
|
||||
/**
|
||||
* Adds and removes children of {@link LoggedInBuilder.LoggedInScope}.
|
||||
*/
|
||||
public class LoggedInRouter
|
||||
extends Router<LoggedInInteractor> {
|
||||
/** Adds and removes children of {@link LoggedInBuilder.LoggedInScope}. */
|
||||
public class LoggedInRouter extends Router<LoggedInInteractor> {
|
||||
|
||||
private final ViewGroup parentView;
|
||||
private final OffGameBuilder offGameBuilder;
|
||||
|
||||
+1
-3
@@ -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,11 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.jakewharton.rxrelay2.BehaviorRelay;
|
||||
import com.uber.rib.root.UserName;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
+1
-3
@@ -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,12 +13,10 @@
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.uber.rib.root.logged_in;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.uber.rib.root.UserName;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
|
||||
public interface ScoreStream {
|
||||
|
||||
+20
-20
@@ -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.off_game;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
@@ -31,14 +30,11 @@ import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.List;
|
||||
|
||||
import javax.inject.Named;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/**
|
||||
* Builder for the {@link OffGameScope}.
|
||||
*/
|
||||
/** Builder for the {@link OffGameScope}. */
|
||||
public class OffGameBuilder
|
||||
extends ViewBuilder<OffGameView, OffGameRouter, OffGameBuilder.ParentComponent> {
|
||||
|
||||
@@ -55,11 +51,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();
|
||||
}
|
||||
|
||||
@@ -69,10 +66,16 @@ public class OffGameBuilder
|
||||
}
|
||||
|
||||
public interface ParentComponent {
|
||||
@Named("player_one") UserName playerOne();
|
||||
@Named("player_two") UserName playerTwo();
|
||||
@Named("player_one")
|
||||
UserName playerOne();
|
||||
|
||||
@Named("player_two")
|
||||
UserName playerTwo();
|
||||
|
||||
OffGameInteractor.Listener listener();
|
||||
|
||||
ScoreStream scoreStream();
|
||||
|
||||
List<? extends GameKey> gameKeys();
|
||||
}
|
||||
|
||||
@@ -86,16 +89,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
|
||||
@@ -119,9 +119,9 @@ public class OffGameBuilder
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface OffGameScope { }
|
||||
@interface OffGameScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface OffGameInternal { }
|
||||
@interface OffGameInternal {}
|
||||
}
|
||||
|
||||
+29
-27
@@ -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.off_game;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
@@ -25,11 +24,9 @@ import com.uber.rib.core.RibInteractor;
|
||||
import com.uber.rib.root.UserName;
|
||||
import com.uber.rib.root.logged_in.GameKey;
|
||||
import com.uber.rib.root.logged_in.ScoreStream;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Consumer;
|
||||
import java.util.List;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@@ -37,14 +34,19 @@ import javax.inject.Named;
|
||||
public class OffGameInteractor
|
||||
extends Interactor<OffGameInteractor.OffGamePresenter, OffGameRouter> {
|
||||
|
||||
@Inject @Named("player_one") UserName playerOne;
|
||||
@Inject @Named("player_two") UserName playerTwo;
|
||||
@Inject
|
||||
@Named("player_one")
|
||||
UserName playerOne;
|
||||
|
||||
@Inject
|
||||
@Named("player_two")
|
||||
UserName playerTwo;
|
||||
|
||||
@Inject Listener listener;
|
||||
@Inject OffGamePresenter presenter;
|
||||
@Inject ScoreStream scoreStream;
|
||||
@Inject List<? extends GameKey> gameNames;
|
||||
|
||||
|
||||
@Override
|
||||
protected void didBecomeActive(@Nullable Bundle savedInstanceState) {
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
@@ -52,24 +54,26 @@ public class OffGameInteractor
|
||||
presenter.setPlayerNames(playerOne.getUserName(), playerTwo.getUserName());
|
||||
presenter
|
||||
.startGameRequest(gameNames)
|
||||
.subscribe(new Consumer<GameKey>() {
|
||||
@Override
|
||||
public void accept(GameKey gameKey) throws Exception {
|
||||
listener.onStartGame(gameKey);
|
||||
}
|
||||
});
|
||||
.subscribe(
|
||||
new Consumer<GameKey>() {
|
||||
@Override
|
||||
public void accept(GameKey gameKey) throws Exception {
|
||||
listener.onStartGame(gameKey);
|
||||
}
|
||||
});
|
||||
|
||||
scoreStream.scores()
|
||||
scoreStream
|
||||
.scores()
|
||||
.as(AutoDispose.<ImmutableMap<UserName, Integer>>autoDisposable(this))
|
||||
.subscribe(new Consumer<ImmutableMap<UserName,Integer>>() {
|
||||
@Override
|
||||
public void accept(ImmutableMap<UserName, Integer> scores)
|
||||
throws Exception {
|
||||
Integer playerOneScore = scores.get(playerOne);
|
||||
Integer playerTwoScore = scores.get(playerTwo);
|
||||
presenter.setScores(playerOneScore, playerTwoScore);
|
||||
}
|
||||
});
|
||||
.subscribe(
|
||||
new Consumer<ImmutableMap<UserName, Integer>>() {
|
||||
@Override
|
||||
public void accept(ImmutableMap<UserName, Integer> scores) throws Exception {
|
||||
Integer playerOneScore = scores.get(playerOne);
|
||||
Integer playerTwoScore = scores.get(playerTwo);
|
||||
presenter.setScores(playerOneScore, playerTwoScore);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public interface Listener {
|
||||
@@ -77,9 +81,7 @@ public class OffGameInteractor
|
||||
void onStartGame(GameKey gameKey);
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
*/
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface OffGamePresenter {
|
||||
|
||||
void setPlayerNames(String playerOne, String playerTwo);
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
|
||||
+14
-17
@@ -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,31 +13,26 @@
|
||||
* 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.view.LayoutInflater;
|
||||
import android.widget.Button;
|
||||
import android.widget.LinearLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.uber.rib.core.Initializer;
|
||||
import com.uber.rib.root.logged_in.GameKey;
|
||||
import com.uber.rib.tutorial4.R;
|
||||
|
||||
import io.reactivex.Observable;
|
||||
import io.reactivex.functions.Function;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Top level view for {@link OffGameBuilder.OffGameScope}.
|
||||
*/
|
||||
/** Top level view for {@link OffGameBuilder.OffGameScope}. */
|
||||
public class OffGameView extends LinearLayout implements OffGameInteractor.OffGamePresenter {
|
||||
|
||||
private TextView playerOneName;
|
||||
@@ -85,16 +80,18 @@ public class OffGameView extends LinearLayout implements OffGameInteractor.OffGa
|
||||
public Observable<GameKey> startGameRequest(List<? extends GameKey> gameKeys) {
|
||||
List<Observable<GameKey>> observables = new ArrayList<>();
|
||||
for (final GameKey gameKey : gameKeys) {
|
||||
Button button = (Button) LayoutInflater.from(getContext()).inflate(R.layout.game_button, this, false);
|
||||
Button button =
|
||||
(Button) LayoutInflater.from(getContext()).inflate(R.layout.game_button, this, false);
|
||||
button.setText(gameKey.gameName());
|
||||
Observable<GameKey> observable = RxView
|
||||
.clicks(button)
|
||||
.map(new Function<Object, GameKey>() {
|
||||
@Override
|
||||
public GameKey apply(Object o) throws Exception {
|
||||
return gameKey;
|
||||
}
|
||||
});
|
||||
Observable<GameKey> observable =
|
||||
RxView.clicks(button)
|
||||
.map(
|
||||
new Function<Object, GameKey>() {
|
||||
@Override
|
||||
public GameKey apply(Object o) throws Exception {
|
||||
return gameKey;
|
||||
}
|
||||
});
|
||||
observables.add(observable);
|
||||
addView(button);
|
||||
}
|
||||
|
||||
+91
-74
@@ -1,105 +1,122 @@
|
||||
/*
|
||||
* 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_in.random_winner;
|
||||
|
||||
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.root.UserName;
|
||||
|
||||
import dagger.Binds;
|
||||
import dagger.BindsInstance;
|
||||
import dagger.Provides;
|
||||
import java.lang.annotation.Retention;
|
||||
|
||||
import javax.inject.Named;
|
||||
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 RandomWinnerScope}. Not a real game. This just picks a random winner than exits.
|
||||
* Builder for the {@link RandomWinnerScope}. Not a real game. This just picks a random winner than
|
||||
* exits.
|
||||
*/
|
||||
public class RandomWinnerBuilder
|
||||
extends ViewBuilder<RandomWinnerView, RandomWinnerRouter, RandomWinnerBuilder.ParentComponent> {
|
||||
extends ViewBuilder<RandomWinnerView, RandomWinnerRouter, RandomWinnerBuilder.ParentComponent> {
|
||||
|
||||
public RandomWinnerBuilder(ParentComponent dependency) {
|
||||
super(dependency);
|
||||
}
|
||||
public RandomWinnerBuilder(ParentComponent dependency) {
|
||||
super(dependency);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds a new {@link RandomWinnerRouter}.
|
||||
*
|
||||
* @param parentViewGroup parent view group that this router's view will be added to.
|
||||
* @return a new {@link RandomWinnerRouter}.
|
||||
*/
|
||||
public RandomWinnerRouter build(ViewGroup parentViewGroup) {
|
||||
RandomWinnerView view = createView(parentViewGroup);
|
||||
RandomWinnerInteractor interactor = new RandomWinnerInteractor();
|
||||
Component component = DaggerRandomWinnerBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.randomwinnerRouter();
|
||||
}
|
||||
/**
|
||||
* Builds a new {@link RandomWinnerRouter}.
|
||||
*
|
||||
* @param parentViewGroup parent view group that this router's view will be added to.
|
||||
* @return a new {@link RandomWinnerRouter}.
|
||||
*/
|
||||
public RandomWinnerRouter build(ViewGroup parentViewGroup) {
|
||||
RandomWinnerView view = createView(parentViewGroup);
|
||||
RandomWinnerInteractor interactor = new RandomWinnerInteractor();
|
||||
Component component =
|
||||
DaggerRandomWinnerBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.randomwinnerRouter();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RandomWinnerView inflateView(LayoutInflater inflater, ViewGroup parentViewGroup) {
|
||||
// Just inflate a silly useless view that does nothing.
|
||||
return new RandomWinnerView(parentViewGroup.getContext());
|
||||
}
|
||||
@Override
|
||||
protected RandomWinnerView inflateView(LayoutInflater inflater, ViewGroup parentViewGroup) {
|
||||
// Just inflate a silly useless view that does nothing.
|
||||
return new RandomWinnerView(parentViewGroup.getContext());
|
||||
}
|
||||
|
||||
public interface ParentComponent {
|
||||
RandomWinnerInteractor.Listener randomWinnerListener();
|
||||
@Named("player_one") UserName playerOne();
|
||||
@Named("player_two") UserName playerTwo();
|
||||
}
|
||||
public interface ParentComponent {
|
||||
RandomWinnerInteractor.Listener randomWinnerListener();
|
||||
|
||||
@dagger.Module
|
||||
public abstract static class Module {
|
||||
@Named("player_one")
|
||||
UserName playerOne();
|
||||
|
||||
@RandomWinnerScope
|
||||
@Binds
|
||||
abstract RandomWinnerInteractor.RandomWinnerPresenter presenter(RandomWinnerView view);
|
||||
@Named("player_two")
|
||||
UserName playerTwo();
|
||||
}
|
||||
|
||||
@RandomWinnerScope
|
||||
@Provides
|
||||
static RandomWinnerRouter router(
|
||||
Component component,
|
||||
RandomWinnerView view,
|
||||
RandomWinnerInteractor interactor) {
|
||||
return new RandomWinnerRouter(view, interactor, component);
|
||||
}
|
||||
}
|
||||
@dagger.Module
|
||||
public abstract static class Module {
|
||||
|
||||
@RandomWinnerScope
|
||||
@dagger.Component(modules = Module.class,
|
||||
dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<RandomWinnerInteractor>, BuilderComponent {
|
||||
@Binds
|
||||
abstract RandomWinnerInteractor.RandomWinnerPresenter presenter(RandomWinnerView view);
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
Builder interactor(RandomWinnerInteractor interactor);
|
||||
@BindsInstance
|
||||
Builder view(RandomWinnerView view);
|
||||
Builder parentComponent(ParentComponent component);
|
||||
Component build();
|
||||
}
|
||||
@RandomWinnerScope
|
||||
@Provides
|
||||
static RandomWinnerRouter router(
|
||||
Component component, RandomWinnerView view, RandomWinnerInteractor interactor) {
|
||||
return new RandomWinnerRouter(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
interface BuilderComponent {
|
||||
RandomWinnerRouter randomwinnerRouter();
|
||||
@RandomWinnerScope
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<RandomWinnerInteractor>, BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
interface Builder {
|
||||
@BindsInstance
|
||||
Builder interactor(RandomWinnerInteractor interactor);
|
||||
|
||||
@BindsInstance
|
||||
Builder view(RandomWinnerView view);
|
||||
|
||||
Builder parentComponent(ParentComponent component);
|
||||
|
||||
Component build();
|
||||
}
|
||||
}
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface RandomWinnerScope { }
|
||||
interface BuilderComponent {
|
||||
RandomWinnerRouter randomwinnerRouter();
|
||||
}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface RandomWinnerInternal { }
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface RandomWinnerScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface RandomWinnerInternal {}
|
||||
}
|
||||
|
||||
+43
-27
@@ -1,47 +1,63 @@
|
||||
/*
|
||||
* 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_in.random_winner;
|
||||
|
||||
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.UserName;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
@RibInteractor
|
||||
public class RandomWinnerInteractor
|
||||
extends Interactor<RandomWinnerInteractor.RandomWinnerPresenter, RandomWinnerRouter> {
|
||||
extends Interactor<RandomWinnerInteractor.RandomWinnerPresenter, RandomWinnerRouter> {
|
||||
|
||||
@Inject Listener listener;
|
||||
@Inject @Named("player_one") UserName playerOne;
|
||||
@Inject @Named("player_two") UserName playerTwo;
|
||||
@Inject Listener listener;
|
||||
|
||||
@Override
|
||||
protected void didBecomeActive(@Nullable Bundle savedInstanceState) {
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
if (new Random(System.currentTimeMillis()).nextBoolean()) {
|
||||
listener.gameWon(playerOne);
|
||||
} else {
|
||||
listener.gameWon(playerTwo);
|
||||
}
|
||||
@Inject
|
||||
@Named("player_one")
|
||||
UserName playerOne;
|
||||
|
||||
@Inject
|
||||
@Named("player_two")
|
||||
UserName playerTwo;
|
||||
|
||||
@Override
|
||||
protected void didBecomeActive(@Nullable Bundle savedInstanceState) {
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
if (new Random(System.currentTimeMillis()).nextBoolean()) {
|
||||
listener.gameWon(playerOne);
|
||||
} else {
|
||||
listener.gameWon(playerTwo);
|
||||
}
|
||||
}
|
||||
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface RandomWinnerPresenter {}
|
||||
|
||||
public interface Listener {
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
* Called when the game is over.
|
||||
*
|
||||
* @param winner player that won, or null if it's a tie.
|
||||
*/
|
||||
interface RandomWinnerPresenter { }
|
||||
|
||||
public interface Listener {
|
||||
|
||||
/**
|
||||
* Called when the game is over.
|
||||
*
|
||||
* @param winner player that won, or null if it's a tie.
|
||||
*/
|
||||
void gameWon(UserName winner);
|
||||
}
|
||||
void gameWon(UserName winner);
|
||||
}
|
||||
}
|
||||
|
||||
+23
-9
@@ -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.logged_in.random_winner;
|
||||
|
||||
import com.uber.rib.core.ViewRouter;
|
||||
@@ -5,15 +20,14 @@ import com.uber.rib.core.ViewRouter;
|
||||
/**
|
||||
* Adds and removes children of {@link RandomWinnerBuilder.RandomWinnerScope}.
|
||||
*
|
||||
* TODO describe the possible child configurations of this scope.
|
||||
* <p>TODO describe the possible child configurations of this scope.
|
||||
*/
|
||||
public class RandomWinnerRouter extends
|
||||
ViewRouter<RandomWinnerView, RandomWinnerInteractor> {
|
||||
public class RandomWinnerRouter extends ViewRouter<RandomWinnerView, RandomWinnerInteractor> {
|
||||
|
||||
public RandomWinnerRouter(
|
||||
RandomWinnerView view,
|
||||
RandomWinnerInteractor interactor,
|
||||
RandomWinnerBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
public RandomWinnerRouter(
|
||||
RandomWinnerView view,
|
||||
RandomWinnerInteractor interactor,
|
||||
RandomWinnerBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
+26
-15
@@ -1,26 +1,37 @@
|
||||
/*
|
||||
* 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_in.random_winner;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.FrameLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* Top level view for {@link RandomWinnerBuilder.RandomWinnerScope}.
|
||||
*/
|
||||
/** Top level view for {@link RandomWinnerBuilder.RandomWinnerScope}. */
|
||||
class RandomWinnerView extends FrameLayout implements RandomWinnerInteractor.RandomWinnerPresenter {
|
||||
|
||||
public RandomWinnerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
public RandomWinnerView(Context context) {
|
||||
this(context, null);
|
||||
}
|
||||
|
||||
public RandomWinnerView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
public RandomWinnerView(Context context, @Nullable AttributeSet attrs) {
|
||||
this(context, attrs, 0);
|
||||
}
|
||||
|
||||
public RandomWinnerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
public RandomWinnerView(Context context, @Nullable AttributeSet attrs, int defStyle) {
|
||||
super(context, attrs, defStyle);
|
||||
}
|
||||
}
|
||||
|
||||
+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 {
|
||||
|
||||
+18
-23
@@ -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 static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
@@ -32,9 +31,7 @@ import javax.inject.Named;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/**
|
||||
* Builder for the {@link TicTacToeScope}.
|
||||
*/
|
||||
/** Builder for the {@link TicTacToeScope}. */
|
||||
public class TicTacToeBuilder
|
||||
extends ViewBuilder<TicTacToeView, TicTacToeRouter, TicTacToeBuilder.ParentComponent> {
|
||||
|
||||
@@ -51,11 +48,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();
|
||||
}
|
||||
|
||||
@@ -66,8 +64,12 @@ public class TicTacToeBuilder
|
||||
|
||||
public interface ParentComponent {
|
||||
TicTacToeInteractor.Listener ticTacToeListener();
|
||||
@Named("player_one") UserName playerOne();
|
||||
@Named("player_two") UserName playerTwo();
|
||||
|
||||
@Named("player_one")
|
||||
UserName playerOne();
|
||||
|
||||
@Named("player_two")
|
||||
UserName playerTwo();
|
||||
}
|
||||
|
||||
@dagger.Module
|
||||
@@ -80,16 +82,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 +113,9 @@ public class TicTacToeBuilder
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface TicTacToeScope {
|
||||
|
||||
}
|
||||
@interface TicTacToeScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface TicTacToeInternal {
|
||||
|
||||
}
|
||||
@interface TicTacToeInternal {}
|
||||
}
|
||||
|
||||
+11
-11
@@ -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 androidx.annotation.Nullable;
|
||||
@@ -27,9 +26,7 @@ import io.reactivex.functions.Consumer;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Named;
|
||||
|
||||
/**
|
||||
* Coordinates Business Logic for {@link TicTacToeScope}.
|
||||
*/
|
||||
/** Coordinates Business Logic for {@link TicTacToeScope}. */
|
||||
@RibInteractor
|
||||
public class TicTacToeInteractor
|
||||
extends Interactor<TicTacToeInteractor.TicTacToePresenter, TicTacToeRouter> {
|
||||
@@ -37,8 +34,14 @@ public class TicTacToeInteractor
|
||||
@Inject Board board;
|
||||
@Inject Listener listener;
|
||||
@Inject TicTacToePresenter presenter;
|
||||
@Inject @Named("player_one") UserName playerOne;
|
||||
@Inject @Named("player_two") UserName playerTwo;
|
||||
|
||||
@Inject
|
||||
@Named("player_one")
|
||||
UserName playerOne;
|
||||
|
||||
@Inject
|
||||
@Named("player_two")
|
||||
UserName playerTwo;
|
||||
|
||||
private MarkerType currentPlayer = MarkerType.CROSS;
|
||||
|
||||
@@ -92,10 +95,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();
|
||||
|
||||
|
||||
+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);
|
||||
}
|
||||
}
|
||||
|
||||
+18
-21
@@ -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,14 +13,13 @@
|
||||
* 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.tutorial4.R;
|
||||
@@ -28,11 +27,9 @@ 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;
|
||||
@@ -55,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);
|
||||
}
|
||||
|
||||
+12
-21
@@ -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_out;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.CLASS;
|
||||
@@ -30,9 +29,7 @@ import java.lang.annotation.Retention;
|
||||
import javax.inject.Qualifier;
|
||||
import javax.inject.Scope;
|
||||
|
||||
/**
|
||||
* Builder for the {@link LoggedOutScope}.
|
||||
*/
|
||||
/** Builder for the {@link LoggedOutScope}. */
|
||||
public class LoggedOutBuilder
|
||||
extends ViewBuilder<LoggedOutView, LoggedOutRouter, LoggedOutBuilder.ParentComponent> {
|
||||
|
||||
@@ -49,11 +46,12 @@ public class LoggedOutBuilder
|
||||
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();
|
||||
Component component =
|
||||
DaggerLoggedOutBuilder_Component.builder()
|
||||
.parentComponent(getDependency())
|
||||
.view(view)
|
||||
.interactor(interactor)
|
||||
.build();
|
||||
return component.loggedoutRouter();
|
||||
}
|
||||
|
||||
@@ -77,9 +75,7 @@ public class LoggedOutBuilder
|
||||
@LoggedOutScope
|
||||
@Provides
|
||||
static LoggedOutRouter router(
|
||||
Component component,
|
||||
LoggedOutView view,
|
||||
LoggedOutInteractor interactor) {
|
||||
Component component, LoggedOutView view, LoggedOutInteractor interactor) {
|
||||
return new LoggedOutRouter(view, interactor, component);
|
||||
}
|
||||
|
||||
@@ -87,8 +83,7 @@ public class LoggedOutBuilder
|
||||
}
|
||||
|
||||
@LoggedOutScope
|
||||
@dagger.Component(modules = Module.class,
|
||||
dependencies = ParentComponent.class)
|
||||
@dagger.Component(modules = Module.class, dependencies = ParentComponent.class)
|
||||
interface Component extends InteractorBaseComponent<LoggedOutInteractor>, BuilderComponent {
|
||||
|
||||
@dagger.Component.Builder
|
||||
@@ -113,13 +108,9 @@ public class LoggedOutBuilder
|
||||
|
||||
@Scope
|
||||
@Retention(CLASS)
|
||||
@interface LoggedOutScope {
|
||||
|
||||
}
|
||||
@interface LoggedOutScope {}
|
||||
|
||||
@Qualifier
|
||||
@Retention(CLASS)
|
||||
@interface LoggedOutInternal {
|
||||
|
||||
}
|
||||
@interface LoggedOutInternal {}
|
||||
}
|
||||
|
||||
+14
-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,11 +13,10 @@
|
||||
* 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.Pair;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.uber.rib.core.Bundle;
|
||||
import com.uber.rib.core.Interactor;
|
||||
import com.uber.rib.core.RibInteractor;
|
||||
@@ -27,9 +26,7 @@ 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> {
|
||||
@@ -42,23 +39,23 @@ public class LoggedOutInteractor
|
||||
super.didBecomeActive(savedInstanceState);
|
||||
presenter
|
||||
.playerNames()
|
||||
.subscribe(new Consumer<Pair<String, String>>() {
|
||||
@Override
|
||||
public void accept(Pair<String, String> names) throws Exception {
|
||||
if (!isEmpty(names.first) && !isEmpty(names.second)) {
|
||||
listener.requestLogin(UserName.create(names.first), UserName.create(names.second));
|
||||
}
|
||||
}
|
||||
});
|
||||
.subscribe(
|
||||
new Consumer<Pair<String, String>>() {
|
||||
@Override
|
||||
public void accept(Pair<String, String> names) throws Exception {
|
||||
if (!isEmpty(names.first) && !isEmpty(names.second)) {
|
||||
listener.requestLogin(
|
||||
UserName.create(names.first), UserName.create(names.second));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private boolean isEmpty(@Nullable String string) {
|
||||
return string == null || string.length() == 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Presenter interface implemented by this RIB's view.
|
||||
*/
|
||||
/** Presenter interface implemented by this RIB's view. */
|
||||
interface LoggedOutPresenter {
|
||||
|
||||
Observable<Pair<String, String>> playerNames();
|
||||
@@ -68,5 +65,4 @@ public class LoggedOutInteractor
|
||||
|
||||
void requestLogin(UserName playerOne, UserName playerTwo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+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_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) {
|
||||
LoggedOutView view, LoggedOutInteractor interactor, LoggedOutBuilder.Component component) {
|
||||
super(view, interactor, component);
|
||||
}
|
||||
}
|
||||
|
||||
+10
-14
@@ -1,12 +1,3 @@
|
||||
package com.uber.rib.root.logged_out;
|
||||
|
||||
import android.content.Context;
|
||||
import androidx.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
/*
|
||||
* Copyright (C) 2017. Uber Technologies
|
||||
*
|
||||
@@ -14,7 +5,7 @@ import android.widget.LinearLayout;
|
||||
* 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,
|
||||
@@ -22,17 +13,22 @@ import android.widget.LinearLayout;
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.uber.rib.root.logged_out;
|
||||
|
||||
import android.widget.TextView;
|
||||
import android.content.Context;
|
||||
import android.util.AttributeSet;
|
||||
import android.util.Pair;
|
||||
import android.widget.Button;
|
||||
import android.widget.EditText;
|
||||
import android.widget.LinearLayout;
|
||||
import androidx.annotation.Nullable;
|
||||
import com.jakewharton.rxbinding2.view.RxView;
|
||||
import com.uber.rib.core.Initializer;
|
||||
import com.uber.rib.tutorial4.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 {
|
||||
|
||||
private Button loginButton;
|
||||
|
||||
Reference in New Issue
Block a user