diff --git a/app/src/main/java/org/ntlab/irisclient/DrawingActivity.java b/app/src/main/java/org/ntlab/irisclient/DrawingActivity.java index 81a4051..fde74de 100644 --- a/app/src/main/java/org/ntlab/irisclient/DrawingActivity.java +++ b/app/src/main/java/org/ntlab/irisclient/DrawingActivity.java @@ -4,20 +4,24 @@ import androidx.lifecycle.Observer; import androidx.lifecycle.ViewModelProvider; +import android.content.Intent; import android.os.Bundle; import android.view.View; +import android.widget.TextView; import org.ntlab.irisclient.viewmodels.DrawingStateViewModel; +import java.util.List; + public class DrawingActivity extends AppCompatActivity implements View.OnClickListener { + DrawingStateViewModel drawingStateViewModel = new ViewModelProvider(this).get(DrawingStateViewModel.class); + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_drawing); - DrawingStateViewModel drawingStateViewModel = new ViewModelProvider(this).get(DrawingStateViewModel.class); - //Irisから必要な情報を取得 Iris iris = (Iris) this.getApplication(); String rid = iris.getRid(); @@ -27,31 +31,36 @@ drawingStateViewModel.setRid(rid); drawingStateViewModel.setNickName(nickName); - //タイマースタート呼び出し - //drawingStateViewModel.start(100ms); - findViewById(R.id.okButtton).setOnClickListener(this);//お絵描き終了ボタン + TextView textKeyword =(TextView)findViewById(R.id.textKeyword);//keywordのTextView + //getKeywords + List keywords = drawingStateViewModel.getKeywords(rid); + + //getDno drawingStateViewModel.getDno().observe(this, new Observer() { - private Integer dno; @Override public void onChanged(Integer dno) { - this.dno = dno; + String keyword = keywords.get(dno); + textKeyword.setText(keyword); } }); + //getState drawingStateViewModel.getState().observe(this, new Observer() { - private Integer state; @Override public void onChanged(Integer state) { - this.state = state; + //stateが変わったらゲーム画面へ遷移 + Intent intent = new Intent(DrawingActivity.this, GameActivity.class); + startActivity(intent); } }); + //タイマースタート呼び出し + drawingStateViewModel.start(500); } @Override public void onClick(View v){ - DrawingStateViewModel drawingStateViewModel = new ViewModelProvider(this).get(DrawingStateViewModel.class); if(v.getId() == R.id.okButtton) { //okButtonが押された処理 drawingStateViewModel.putDrawing();