diff --git a/app/src/main/java/com/example/sprout/refactor/activity/RegistrationActivity.java b/app/src/main/java/com/example/sprout/refactor/activity/RegistrationActivity.java index 2b82507..7bc1441 100644 --- a/app/src/main/java/com/example/sprout/refactor/activity/RegistrationActivity.java +++ b/app/src/main/java/com/example/sprout/refactor/activity/RegistrationActivity.java @@ -1,29 +1,21 @@ package com.example.sprout.refactor.activity; -import android.content.Intent; import android.databinding.DataBindingUtil; import android.os.Bundle; -import android.support.v7.app.AppCompatActivity; -import android.widget.Toast; import com.example.sprout.R; import com.example.sprout.databinding.RfActivityRegistrationBinding; import com.example.sprout.refactor.viewmodel.RegistrationViewModel; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; - /** * アカウント登録のActivity * * @author matsumoto_k */ -public class RegistrationActivity extends AppCompatActivity { +public class RegistrationActivity extends BaseActivity { private RfActivityRegistrationBinding binding = null; private RegistrationViewModel registrationViewModel = null; - private final CompositeDisposable subscriptions = new CompositeDisposable(); @Override protected void onCreate(Bundle savedInstanceState) { @@ -37,48 +29,12 @@ @Override protected void onResume() { super.onResume(); - subscribe(); + addUiObserver(registrationViewModel); } @Override protected void onPause() { super.onPause(); - dispose(); - } - - private void subscribe() { - // トーストの購読 - subscriptions.add( - registrationViewModel.getToastMessanger() - .observeOn(AndroidSchedulers.mainThread()) - .subscribe(toastMessage -> { - switch (toastMessage.getLength()) { - case SHORT: - Toast.makeText(this, toastMessage.getMessage(), Toast.LENGTH_SHORT).show(); - break; - case LONG: - Toast.makeText(this, toastMessage.getMessage(), Toast.LENGTH_LONG).show(); - break; - } - }) - ); - // 画面遷移の購読 - subscriptions.add( - registrationViewModel.getNavigationMessenger() - .observeOn(Schedulers.computation()) - .subscribe(navigationMessage -> { - switch (navigationMessage.getType()) { - case Start: - startActivity(new Intent(RegistrationActivity.this, navigationMessage.getClazz())); - break; - case Finsih: - finish(); - } - }) - ); - } - - private void dispose() { - subscriptions.dispose(); + removeUiObserver(); } }