diff --git a/app/src/main/java/com/example/sprout/refactor/activity/RoomListActivity.java b/app/src/main/java/com/example/sprout/refactor/activity/RoomListActivity.java index 00c00eb..1b901eb 100644 --- a/app/src/main/java/com/example/sprout/refactor/activity/RoomListActivity.java +++ b/app/src/main/java/com/example/sprout/refactor/activity/RoomListActivity.java @@ -1,16 +1,11 @@ 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.RfActivityRoomListBinding; import com.example.sprout.refactor.adapter.RoomListAdapter; -import com.example.sprout.refactor.common.ActivityEvent; -import com.example.sprout.refactor.contract.ViewContract; import com.example.sprout.refactor.viewmodel.RoomListViewModel; /** @@ -18,44 +13,29 @@ * * @author matsumoto_k */ -public class RoomListActivity extends AppCompatActivity implements ViewContract { +public class RoomListActivity extends BaseActivity { + + private RoomListViewModel roomMainViewModel = null; + private RfActivityRoomListBinding binding = null; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); - RfActivityRoomListBinding binding = DataBindingUtil.setContentView(this, R.layout.rf_activity_room_list); - RoomListViewModel roomMainViewModel = new RoomListViewModel(new RoomListAdapter(this), (ViewContract) this); + binding = DataBindingUtil.setContentView(this, R.layout.rf_activity_room_list); + roomMainViewModel = new RoomListViewModel(new RoomListAdapter(this)); binding.setViewModel(roomMainViewModel); getLifecycle().addObserver(roomMainViewModel); } @Override - public void startActivity(ActivityEvent event) { - switch (event) { - case CREATE_ROOM: - startActivity(new Intent(RoomListActivity.this, RoomCreateActivity.class)); - break; - case ROOM_MAIN: - startActivity(new Intent(RoomListActivity.this, RoomMainActivity.class)); - break; - case INPUT_KEY: - startActivity(new Intent(RoomListActivity.this, RoomInputKeyActivity.class)); - break; - } + protected void onResume() { + super.onResume(); + addUiObserver(roomMainViewModel); } @Override - public void finishActivity() { - - } - - @Override - public void showShortToast(String message) { - Toast.makeText(this, message, Toast.LENGTH_SHORT).show(); - } - - @Override - public void showLongToast(String message) { - Toast.makeText(this, message, Toast.LENGTH_LONG).show(); + protected void onPause() { + super.onPause(); + removeUiObserver(roomMainViewModel); } }