diff --git a/app/src/main/java/com/example/sprout/refactor/repository/RoomRepository.java b/app/src/main/java/com/example/sprout/refactor/repository/RoomRepository.java index 9d567b4..7df09c1 100644 --- a/app/src/main/java/com/example/sprout/refactor/repository/RoomRepository.java +++ b/app/src/main/java/com/example/sprout/refactor/repository/RoomRepository.java @@ -18,13 +18,10 @@ public class RoomRepository extends Repository { private SproutService sproutService = null; - private Observable roomListObservable = new Observable<>(); - private Observable enterRoomObservable = new Observable<>(); - private Observable createRoomObservable = new Observable<>(); private Observable roomObservable = new Observable<>(); - private Observable roomUpdateStateObservable = new Observable<>(); - private Observable exitRoomObservable = new Observable<>(); - private Observable enterRoomWithKeyObservable = new Observable<>(); + private Observable roomsObservable = new Observable<>(); + private Observable roomResponseObservable = new Observable<>(); + private Observable voidObservable = new Observable<>(); public RoomRepository(SproutService sproutService) { this.sproutService = sproutService; @@ -36,15 +33,15 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - roomListObservable.notifyObservers(response.body()); + roomsObservable.notifyObservers(response.body()); } else { - roomListObservable.notifyError(new Throwable("error")); + roomsObservable.notifyError(new Throwable("error")); } } @Override public void onFailure(Call call, Throwable t) { - roomListObservable.notifyError(t); + roomsObservable.notifyError(t); } }); } @@ -55,15 +52,15 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - enterRoomObservable.notifyObservers(response.body()); + roomResponseObservable.notifyObservers(response.body()); } else { - enterRoomObservable.notifyError(new Throwable("error")); + roomResponseObservable.notifyError(new Throwable("error")); } } @Override public void onFailure(Call call, Throwable t) { - enterRoomObservable.notifyError(t); + roomResponseObservable.notifyError(t); } }); } @@ -74,15 +71,15 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - createRoomObservable.notifyObservers(response.body()); + roomResponseObservable.notifyObservers(response.body()); } else { - createRoomObservable.notifyError(new Throwable("error")); + roomResponseObservable.notifyError(new Throwable("error")); } } @Override public void onFailure(Call call, Throwable t) { - createRoomObservable.notifyError(t); + roomResponseObservable.notifyError(t); } }); } @@ -112,15 +109,15 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - roomUpdateStateObservable.notifyObservers(response.body()); + roomResponseObservable.notifyObservers(response.body()); } else { - roomUpdateStateObservable.notifyError(new Throwable("error")); + roomResponseObservable.notifyError(new Throwable("error")); } } @Override public void onFailure(Call call, Throwable t) { - roomUpdateStateObservable.notifyError(t); + roomResponseObservable.notifyError(t); } }); } @@ -131,15 +128,15 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - exitRoomObservable.notifyObservers(response.body()); + voidObservable.notifyObservers(response.body()); } else { - exitRoomObservable.notifyError(new Throwable("error")); + voidObservable.notifyError(new Throwable("error")); } } @Override public void onFailure(Call call, Throwable t) { - exitRoomObservable.notifyError(t); + voidObservable.notifyError(t); } }); } @@ -150,44 +147,34 @@ @Override public void onResponse(Call call, Response response) { if (response.isSuccessful()) { - enterRoomWithKeyObservable.notifyObservers(response.body()); + roomResponseObservable.notifyObservers(response.body()); } else { - enterRoomWithKeyObservable.notifyError(new Throwable("error")); + roomResponseObservable.notifyError(new Throwable("error")); } } @Override public void onFailure(Call call, Throwable t) { - enterRoomWithKeyObservable.notifyError(t); + roomResponseObservable.notifyError(t); } }); } - public Observable getRoomListObservable() { - return roomListObservable; - } - - public Observable getEnterRoomObservable() { - return enterRoomObservable; - } - - public Observable getCreateRoomObservable() { - return createRoomObservable; - } - public Observable getRoomObservable() { return roomObservable; } - public Observable getRoomUpdateStateObservable() { - return roomUpdateStateObservable; + public Observable getRoomsObservable() { + return roomsObservable; } - public Observable getEnterRoomWithKeyObservable() { - return enterRoomWithKeyObservable; + public Observable getRoomResponseObservable() { + return roomResponseObservable; } - public Observable getExitRoomObservable() { - return exitRoomObservable; + public Observable getVoidObservable() { + return voidObservable; } + + }