diff --git a/app/src/main/java/org/ntlab/irisclient/viewmodels/DrawingStateViewModel.java b/app/src/main/java/org/ntlab/irisclient/viewmodels/DrawingStateViewModel.java index 9bae5ef..6903fc7 100644 --- a/app/src/main/java/org/ntlab/irisclient/viewmodels/DrawingStateViewModel.java +++ b/app/src/main/java/org/ntlab/irisclient/viewmodels/DrawingStateViewModel.java @@ -24,13 +24,16 @@ final private MutableLiveData stateMutableLiveData=new MutableLiveData<>(); final private MutableLiveData dnoMutableLiveData=new MutableLiveData<>(); final private MutableLiveData drawingMutableLiveData = new MutableLiveData<>(); + final private MutableLiveData> keywordsMutableLiveData = new MutableLiveData<>(); final private Retrofit retrofit; private Integer drawingStatePreData; private Integer dnoPreData = null; + private String drawingPreData; private String rid; private String nickName; + private List keywords; //フィールド public DrawingStateViewModel() { @@ -102,22 +105,36 @@ }); } - public List getKeywords(String rid){ + + + public void updateKeywords(String rid){ final DrawingRest drawingRest = retrofit.create(DrawingRest.class); Call> keywordsCall = drawingRest.getKeywords(rid); - try { - Response> keywords = keywordsCall.execute(); - return keywords.body(); - } catch (IOException e) { - e.printStackTrace(); - return null; - } + + keywordsCall.enqueue(new Callback>() { + @Override + public void onResponse(Call> keywordsCall, Response> response) { + if (response.isSuccessful()){ + keywordsMutableLiveData.setValue(response.body()); + } + } + + @Override + public void onFailure(Call> keywordsCall, Throwable t) { + } + }); + } + // public LiveData> getMembers(String rid){ // RoomViewModel members = new RoomViewModel(); // return members.getMembersLiveData(); // } + + public LiveData> getKeywords(){ + return this.keywordsMutableLiveData; + } public LiveData getDno(){ return this.dnoMutableLiveData; } @@ -128,10 +145,17 @@ public void setRid(String rid){ this.rid = rid; } - + public void setKeywords(List keywords){ + this.keywords = keywords; + } public void setNickName(String nickName){ this.nickName = nickName; } + + public void init(){ + updateKeywords(rid); + } + @Override public void update() { updateState(rid);