Guest User

Untitled

a guest
Nov 3rd, 2017
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. import com.groupon.grox.Store;
  2. import com.groupon.grox.commands.rxjava1.Command;
  3. import com.groupon.grox.sample.rx.R;
  4. import rx.subscriptions.CompositeSubscription;
  5.  
  6. public class LoginActivity extends AppCompatActivity {
  7.  
  8. private LoginStateModel initialState = LoginStateModel.builder()
  9. .setLoginState(LOGIN_NOT_STARTED)
  10. .setLoggedInUser(null)
  11. .build();
  12. private Store<LoginStateModel> store = new Store<>(initialState);
  13. private CompositeSubscription subscription = new CompositeSubscription();
  14. private LoginApiClient loginApiClient;
  15.  
  16. @Override
  17. protected void onCreate(Bundle savedInstanceState) {
  18. super.onCreate(savedInstanceState);
  19. setContentView(R.layout.activity_main);
  20. final View loginButton = findViewById(R.id.loginButton);
  21. final EditText username = (TextView) findViewById(R.id.username);
  22. final EditText password = (TextView) findViewById(R.id.password);
  23.  
  24. subscription.add(states(store).observeOn(mainThread())
  25. .subscribe(this::updateUI)
  26. );
  27.  
  28. loginButton.setOnClickListener(v -> {
  29. subscription.add(new LoginCommand(username.getText(), password.getText(), loginApiClient)
  30. .actions()
  31. .subscribe(store::dispatch)
  32. );
  33. });
  34. }
Add Comment
Please, Sign In to add comment