diff --git a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java index bc85a71..39a6088 100644 --- a/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java +++ b/app/src/main/java/org/ntlab/acanthus_client/views/animation/AnimationActivity.java @@ -5,6 +5,7 @@ import android.app.Activity; import android.content.Intent; import android.os.Bundle; +import android.view.MotionEvent; import android.view.View; import android.widget.Button; @@ -20,48 +21,108 @@ private ActivityPaintBinding binding; private View view; + //ボタン系 + private boolean buttonView = true; + private Button buttonPlayback; + private Button buttonReset; + private Button buttonClose; + private Button buttonDetail; + private Button buttonSkip; + private Button buttonBack; + + //animationCanvasの表示 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_animation); - animationCanvas = this.findViewById(R.id.animationMyCanvas); + //アニメーションの再生停止 - Button buttonPlayback = findViewById(R.id.button_playback); + buttonPlayback = findViewById(R.id.button_playback); buttonPlayback.setOnClickListener(new View.OnClickListener(){ - @Override public void onClick(View v) { - animationCanvas.onClickPlayback(); + if(animationCanvas.onClickPlayback() == 0){ + buttonPlayback.setText("Play"); + } + else { + buttonPlayback.setText("Stop"); + } } }); //最初に戻す - Button buttonReset = findViewById(R.id.button_reset); + buttonReset = findViewById(R.id.button_reset); buttonReset.setOnClickListener(new View.OnClickListener(){ - @Override public void onClick(View v) { animationCanvas.resetAnimationPage(); } }); + //5秒スキップ + buttonSkip = findViewById(R.id.button_skip); + buttonSkip.setOnClickListener(new View.OnClickListener(){ + public void onClick(View v) { + animationCanvas.setAnimationSkip(1); + } + }); + + //5秒巻き戻し + buttonBack = findViewById(R.id.button_back); + buttonBack.setOnClickListener(new View.OnClickListener(){ + public void onClick(View v) { + animationCanvas.setAnimationSkip(-1); + } + }); + + //閉じる - Button buttonClose = findViewById(R.id.button_close); + buttonClose = findViewById(R.id.button_close); buttonClose.setOnClickListener(new View.OnClickListener(){ - @Override public void onClick(View v) { finish(); } }); - Button buttonDetail = findViewById(R.id.button_detail); + //詳細画面へ移動 + buttonDetail = findViewById(R.id.button_detail); buttonDetail.setOnClickListener(new View.OnClickListener(){ - @Override public void onClick(View v) { Intent intent = new Intent(AnimationActivity.this, AnimationDetailActivity.class); startActivity(intent); } }); - } + + + //Activity内のボタンの表示/非表示 + @Override + public boolean onTouchEvent(MotionEvent motionEvent) { + switch (motionEvent.getAction()){ + case MotionEvent.ACTION_DOWN: + //画面タップで表示されてたら非表示にする。 + if(buttonView) { + buttonReset.setVisibility(View.INVISIBLE); + buttonPlayback.setVisibility(View.INVISIBLE); + buttonDetail.setVisibility(View.INVISIBLE); + buttonClose.setVisibility(View.INVISIBLE); + buttonSkip.setVisibility(View.INVISIBLE); + buttonBack.setVisibility(View.INVISIBLE); + + buttonView = false; + } + else { + buttonReset.setVisibility(View.VISIBLE); + buttonPlayback.setVisibility(View.VISIBLE); + buttonDetail.setVisibility(View.VISIBLE); + buttonClose.setVisibility(View.VISIBLE); + buttonSkip.setVisibility(View.VISIBLE); + buttonBack.setVisibility(View.VISIBLE); + + buttonView = true; + } + } + return false; + } + } \ No newline at end of file