package tonio.noa; import android.content.Intent; import android.graphics.Color; import android.os.Bundle; import android.view.MotionEvent; import android.view.View; import android.widget.ImageView; import android.widget.TextView; /** * Created by psyk on 24/01/18. */ public class Security1Activity extends MyPlayActivity implements View.OnTouchListener { private int win_counter = 0; private boolean done = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); lanceConsigne("Montre moi les objets qui peuvent ĂȘtre dangereux."); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); setContentView(R.layout.security1_display); TextView txtV = findViewById(R.id.cons_sec1); smallCons = "Touche les objets dangereux."; txtV.setText(smallCons); setTts(); findViewById(R.id.water).setOnTouchListener(this); findViewById(R.id.knife).setOnTouchListener(this); findViewById(R.id.bear).setOnTouchListener(this); findViewById(R.id.pan).setOnTouchListener(this); findViewById(R.id.pen).setOnTouchListener(this); findViewById(R.id.bleach).setOnTouchListener(this); findViewById(R.id.drugs).setOnTouchListener(this); findViewById(R.id.iron).setOnTouchListener(this); } @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (view == findViewById(R.id.iron) || view == findViewById(R.id.knife) || view == findViewById(R.id.pan) || view == findViewById(R.id.bleach) || view == findViewById(R.id.drugs)) { view.setVisibility(View.INVISIBLE); win_counter++; } else { ((ImageView) view).setColorFilter(Color.GRAY); view.setEnabled(false); } return true; } if (win_counter == 5 && !done) { done = true; this.bravoPage(null); return true; } else return false; } @Override protected void next() { this.backHome(null); } }