Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.groupon.grox.Store;
- import com.groupon.grox.commands.rxjava1.Command;
- import com.groupon.grox.sample.rx.R;
- import rx.subscriptions.CompositeSubscription;
- public class LoginActivity extends AppCompatActivity {
- private LoginStateModel initialState = LoginStateModel.builder()
- .setLoginState(LOGIN_NOT_STARTED)
- .setLoggedInUser(null)
- .build();
- private Store<LoginStateModel> store = new Store<>(initialState);
- private CompositeSubscription subscription = new CompositeSubscription();
- private LoginApiClient loginApiClient;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- final View loginButton = findViewById(R.id.loginButton);
- final EditText username = (TextView) findViewById(R.id.username);
- final EditText password = (TextView) findViewById(R.id.password);
- subscription.add(states(store).observeOn(mainThread())
- .subscribe(this::updateUI)
- );
- loginButton.setOnClickListener(v -> {
- subscription.add(new LoginCommand(username.getText(), password.getText(), loginApiClient)
- .actions()
- .subscribe(store::dispatch)
- );
- });
- }
Add Comment
Please, Sign In to add comment