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 237a6e2..cbb2429 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 @@ -1,26 +1,35 @@ package org.ntlab.acanthus_client.views.animation; import androidx.appcompat.app.AppCompatActivity; +import androidx.lifecycle.Observer; +import androidx.lifecycle.ViewModelProvider; import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; +import android.webkit.WebView; +import android.webkit.WebViewClient; import android.widget.Button; import org.ntlab.acanthus_client.Acanthus; import org.ntlab.acanthus_client.R; -import org.ntlab.acanthus_client.databinding.ActivityPaintBinding; import org.ntlab.acanthus_client.views.animation_detail.AnimationDetailActivity; +import org.ntlab.acanthus_client.views.paint.PaintCanvas; +import org.ntlab.acanthus_client.views.paint.PaintToolBar; +import org.ntlab.acanthus_client.views.paint.PaintViewModel; // 表示ページ public class AnimationActivity extends AppCompatActivity { private AnimationCanvas animationCanvas; - private ActivityPaintBinding binding; + private AnimationViewModel animationViewModel; private View view; + private WebView webView; + private String url; + //ボタン系 private boolean buttonView = true; private Button buttonPlayback; @@ -34,19 +43,33 @@ //animationCanvasの表示 @Override protected void onCreate(Bundle savedInstanceState) { + init(); + super.onCreate(savedInstanceState); setContentView(R.layout.activity_animation); animationCanvas = this.findViewById(R.id.animationMyCanvas); + //wecView + webView = this.findViewById(R.id.animationWebview); + webView.setWebViewClient(new WebViewClient(){ + @Override + public boolean shouldOverrideUrlLoading(WebView view, String url) { + return false; + } + }); +// url = animationViewModel.getAnimationPage().getValue(); +// //url = "http://nitta-lab-www.is.konan-u.ac.jp/gallery/300/0/a300p0.png"; +// webView.loadUrl(url); + //アニメーションの再生停止 buttonPlayback = findViewById(R.id.button_playback); buttonPlayback.setOnClickListener(new View.OnClickListener(){ public void onClick(View v) { if(animationCanvas.onClickPlayback() == 0){ - buttonPlayback.setText("Play"); + buttonPlayback.setText("start"); } else { - buttonPlayback.setText("Stop"); + buttonPlayback.setText("stop"); } } }); @@ -94,6 +117,25 @@ }); } + public void init(){ + //初期化 + Acanthus acanthus = (Acanthus) getApplication(); + animationViewModel = new ViewModelProvider(this).get(AnimationViewModel.class); + animationViewModel.init(acanthus); + startObserver(); + } + //startobserve + private void startObserver(){ + animationViewModel.getAnimationPage().observe(this, new Observer() { + @Override + public void onChanged(String s) { + url = animationViewModel.getAnimationPage().getValue(); + //url = "http://nitta-lab-www.is.konan-u.ac.jp/gallery/300/0/a300p0.png"; + webView.loadUrl(url); + } + }); + } + //Activity内のボタンの表示/非表示 @Override