diff --git a/app/src/main/java/com/example/sprout/refactor/activity/RoomCreateActivity.java b/app/src/main/java/com/example/sprout/refactor/activity/RoomCreateActivity.java index 746e6f1..b8d890e 100644 --- a/app/src/main/java/com/example/sprout/refactor/activity/RoomCreateActivity.java +++ b/app/src/main/java/com/example/sprout/refactor/activity/RoomCreateActivity.java @@ -1,27 +1,19 @@ 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.RfActivityRoomCreateBinding; import com.example.sprout.refactor.viewmodel.RoomCreateViewModel; -import io.reactivex.android.schedulers.AndroidSchedulers; -import io.reactivex.disposables.CompositeDisposable; -import io.reactivex.schedulers.Schedulers; - /** * ルーム作成のActivity * * @author matsumoto_k */ -public class RoomCreateActivity extends AppCompatActivity { +public class RoomCreateActivity extends BaseActivity { - private CompositeDisposable subscriptions = null; private RoomCreateViewModel roomCreateViewModel = null; private RfActivityRoomCreateBinding binding = null; @@ -37,39 +29,6 @@ @Override protected void onResume() { super.onResume(); - subscribe(); - } - - private void subscribe() { - subscriptions = new CompositeDisposable(); - // トーストの購読 - subscriptions.add( - roomCreateViewModel.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( - roomCreateViewModel.getNavigationMessenger() - .observeOn(Schedulers.computation()) - .subscribe(navigationMessage -> { - switch (navigationMessage.getType()) { - case Start: - startActivity(new Intent(RoomCreateActivity.this, navigationMessage.getClazz())); - break; - case Finsih: - finish(); - } - }) - ); + addUiObserver(roomCreateViewModel); } }