package j4ckall.rxflux.ui.registration; import android.content.Intent; import android.databinding.ObservableField; import io.reactivex.disposables.CompositeDisposable; import j4ckall.rxflux.App; import j4ckall.rxflux.lib.architecture.BaseViewModel; import j4ckall.rxflux.ui.roomlist.RoomListActivity; public class RegistrationViewModel extends BaseViewModel { private final RegistrationStore registrationStore = RegistrationStore.get(); private final RegistrationActionCreater registrationActionCreater = new RegistrationActionCreater(); private final CompositeDisposable subscriptions = new CompositeDisposable(); private ObservableField<String> editUserName = new ObservableField<>(""); public RegistrationViewModel() { } @Override public void onResume() { subscriptions.add( registrationStore.getAccountObservbale().subscribe(account -> { // TODO:仮の呼び出しなので呼び出し方法を変える finishをしてないのでbackした時にここの処理が現状走ることになる Intent intent = new Intent(App.get(), RoomListActivity.class); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); App.get().startActivity(intent); }) ); } @Override public void onPause() { subscriptions.dispose(); } /** * 登録ボタンを押した時 * * @param userName */ public void registration(String userName) { registrationActionCreater.registration(userName); } public ObservableField<String> getEditUserName() { return editUserName; } }