1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
| public class DetailsCommentaireRestoActivity extends Activity {
private String idResto;
private ArrayList<Evaluer> listeCommentaire;
private String mail;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_details_commentaire_resto);
TextView txtCommentaire = (TextView) findViewById(R.id.txtCommentaire);
LinearLayout layoutScroll = (LinearLayout) findViewById(R.id.layoutScroll);
Intent intentReceived = getIntent();
if (intentReceived != null) {
String idR = intentReceived.getStringExtra("idR");
Log.d("idR", "ID RECEIVED IN LISTE COMMENTAIRE: " + idR);
idResto = idR;
}
EvaluerDAO commResto = new EvaluerDAO(this);
listeCommentaire = commResto.getCommentairesByidR(idResto);
if(listeCommentaire.size() == 0){
txtCommentaire.setText("aucun commentaire non traité pour ce restaurant");
}
//txtCommentaire.setText(listeCommentaire.get(0).getCommentaire());
for (int i = 0; i < listeCommentaire.size(); i++) {
LinearLayout Layout1 = new LinearLayout(this);
Layout1.setOrientation(LinearLayout.VERTICAL);
TextView txtComm = new TextView(this);
txtComm.setText(listeCommentaire.get(i).getCommentaire());
Layout1.addView(txtComm);
TextView txtNoteRecette = new TextView(this);
txtNoteRecette.setText("respect de la recette :"+listeCommentaire.get(i).isRespectRecette()+"/5");
Layout1.addView(txtNoteRecette);
TextView txtNoteEsteRepas = new TextView(this);
txtNoteEsteRepas.setText("esthetique du repas :"+listeCommentaire.get(i).getEsthetiquePlat()+"/5");
Layout1.addView(txtNoteEsteRepas);
TextView txtNoteCout = new TextView(this);
txtNoteCout.setText("cout du repas :"+listeCommentaire.get(i).getCout()+"/5");
Layout1.addView(txtNoteCout);
TextView txtNoteQualiteNourriture = new TextView(this);
txtNoteQualiteNourriture.setText("qualité de la nourriture :" +listeCommentaire.get(i).getQualiteNourriture()+"/5");
Layout1.addView(txtNoteQualiteNourriture);
final TextView txtMail = new TextView(this);
txtMail.setText(listeCommentaire.get(i).getMailU());
Layout1.addView(txtMail);
LinearLayout Layout2 = new LinearLayout(this);
Layout2.setOrientation(LinearLayout.HORIZONTAL);
Layout1.addView(Layout2);
Button AcceptComm = new Button(this);
AcceptComm.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
mail = (String) txtMail.getText();
AccepteComm(mail);
}
});
AcceptComm.setText("Valider");
Layout2.addView(AcceptComm);
Button SupprComm = new Button(this);
SupprComm.setOnClickListener( new View.OnClickListener() {
@Override
public void onClick(View view) {
mail = (String) txtMail.getText();
SuppreComm(mail);
}
});
SupprComm.setText("Supprimer");
Layout2.addView(SupprComm);
layoutScroll.addView(Layout1);
}
}
public void AccepteComm(String mail){
EvaluerDAO evalAcces = new EvaluerDAO(this);
evalAcces.updateCommVisible(idResto, mail);
}
public void SuppreComm(String mail) {
EvaluerDAO evalAcces = new EvaluerDAO(this);
evalAcces.deleteRComByIdrRMailu(idResto, mail);
}
} |
Partager