Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. package com.brothers.cailles.spotthecage;
  2.  
  3. import android.app.Activity;
  4. import android.app.AlertDialog;
  5. import android.graphics.Bitmap;
  6. import android.graphics.BitmapFactory;
  7. import android.graphics.drawable.BitmapDrawable;
  8. import android.graphics.drawable.Drawable;
  9. import android.media.Image;
  10. import android.graphics.Matrix;
  11. import android.os.Bundle;
  12. import android.os.CountDownTimer;
  13. import android.provider.ContactsContract;
  14. import android.util.ArrayMap;
  15. import android.util.Log;
  16. import android.view.MotionEvent;
  17. import android.view.View;
  18. import android.widget.ImageView;
  19. import android.view.View.OnTouchListener;
  20. import android.widget.TextView;
  21.  
  22. import com.github.chrisbanes.photoview.OnPhotoTapListener;
  23. import com.github.chrisbanes.photoview.PhotoView;
  24.  
  25. import java.util.ArrayList;
  26. import java.util.List;
  27. import java.lang.Math;
  28.  
  29.  
  30. /**
  31. * Created by solal vallee on 20/03/2017.
  32. */
  33.  
  34. public class cageActivity extends Activity {
  35.  
  36. private double[][] nicolasPosition = new double[][]{{0.34, 0.365, 0.54, 0.60}, {0.20, 0.23, 0.52, 0.57}};
  37. private int[] picturesNicolas = new int[]{R.drawable.cageee, R.drawable.cage2};
  38. private int randomChoice = (int) (Math.random() * 2);
  39. private int compteur = 0;
  40.  
  41. protected void onCreate(Bundle savedInstanceState) {
  42. super.onCreate(savedInstanceState);
  43. setContentView(R.layout.cage1);
  44.  
  45. PhotoView photoView = (PhotoView) findViewById(R.id.photo_view);
  46. photoView.setImageResource(picturesNicolas[randomChoice]);
  47.  
  48. photoView.setOnPhotoTapListener(test);
  49. }
  50.  
  51.  
  52. OnPhotoTapListener test = new OnPhotoTapListener() {
  53. @Override
  54. public void onPhotoTap(ImageView view, float x, float y) {
  55.  
  56. AlertDialog.Builder customAlert = new AlertDialog.Builder(cageActivity.this);
  57.  
  58. CountDownTimer myTimer = new CountDownTimer(2000,1000) {
  59.  
  60. public void onTick ( long millisUntilFinished){
  61. compteur = 1;
  62. }
  63.  
  64. public void onFinish() {
  65. compteur = 0;
  66. }
  67. }.start();
  68.  
  69. Log.d("click : ", Float.toString(compteur));
  70.  
  71. Log.d("x : ", Float.toString(x));
  72. Log.d("y : ", Float.toString(y));
  73.  
  74. String a = "ca marche";
  75. String b = "ca marche pas";
  76.  
  77. Double c = nicolasPosition[randomChoice][0];
  78. Log.d("X1 : ", Double.toString(c));
  79.  
  80. TextView myText = (TextView) findViewById(R.id.textView);
  81. myText.setText(" X : " + Float.toString(x) + " Y : " + Float.toString(y));
  82.  
  83. if(compteur == 0 ){
  84. if ((x > nicolasPosition[randomChoice][0] && x < nicolasPosition[randomChoice][1]) && (y > nicolasPosition[randomChoice][2] && y < nicolasPosition[randomChoice][3])) {
  85. customAlert.setMessage("WINNNNNNER").create();
  86. customAlert.show();
  87. Log.d("TU PEUX Y ALLER", "OIJDOIJCOIDS");
  88. }
  89.  
  90. }
  91. else {
  92. customAlert.setMessage("TU ES NIKE TU DOIS ATTENDRE ").create();
  93. customAlert.show();
  94. }
  95. }
  96. };
  97.  
  98.  
  99.  
  100. /*public void onTouch
  101. OnTouchListener monTouch = PhotoView.OnTouchListener() {
  102.  
  103. @Override
  104. public boolean onTouch(PhotoView view, MotionEvent event) {
  105. float eventX = event.getX();
  106. float eventY = event.getY();
  107. float[] eventXY = new float[]{eventX, eventY};
  108. String x = Float.toString(eventX);
  109. String y = Float.toString(eventY);
  110.  
  111. //monTexte.setText(test);
  112. monTexteX.setText(" X : "+x+" Y : " +y);
  113. }};*/
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement