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 Hygiene5Activity extends MyPlayActivity implements View.OnTouchListener { private int win_counter = 0; private boolean done = false; @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); lanceConsigne("Maintenant tu dois toucher le shampoing, le savon et la brosse à dent."); } protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); setContentView(R.layout.hygiene5_display); TextView txtV = findViewById(R.id.cons_hyg5); smallCons = "Touche le shampoing, le savon et la brosse à dent."; txtV.setText(smallCons); setTts(); findViewById(R.id.soap).setOnTouchListener(this); findViewById(R.id.shampoo).setOnTouchListener(this); findViewById(R.id.toothpaste).setOnTouchListener(this); findViewById(R.id.blue_toothbrush_pic).setOnTouchListener(this); findViewById(R.id.towel).setOnTouchListener(this); findViewById(R.id.toilet_bag).setOnTouchListener(this); } @Override public boolean onTouch(View view, MotionEvent event) { if (event.getAction() == MotionEvent.ACTION_DOWN) { if (view == findViewById(R.id.soap) || view == findViewById(R.id.shampoo) || view == findViewById(R.id.blue_toothbrush_pic)) { view.setVisibility(View.INVISIBLE); win_counter++; } else { ImageView imageV = (ImageView) view; imageV.setColorFilter(Color.GRAY); view.setEnabled(false); } return true; } if (win_counter == 3 && !done) { done = true; this.bravoPage(null); return true; } else return false; } @Override protected void next() { startActivity(new Intent(this, Hygiene6Activity.class)); } }