Esempio n. 1
0
 private void refuse(String txt, View v) {
   for (Invitation i : invitations) {
     if (i.getNomFoyer().equals(txt)) {
       repondre(i, "declined", v);
     }
   }
 }
Esempio n. 2
0
 private void accept(String txt, View v) {
   for (Invitation i : invitations) {
     if (i.getNomFoyer().equals(txt)) {
       repondre(i, "accepted", v);
     }
   }
 }
Esempio n. 3
0
  private void showInvitations() {

    GridLayout.Spec row;
    GridLayout.Spec column;
    GridLayout.LayoutParams params;

    for (Invitation i : invitations) {

      final TextView tempText = new TextView(getApplicationContext());
      tempText.setText(i.getNomFoyer());
      tempText.setTextSize(18);
      row = GridLayout.spec(mainLayout.getRowCount());
      column = GridLayout.spec(0);
      params = new GridLayout.LayoutParams(row, column);
      params.setGravity(Gravity.FILL_HORIZONTAL);
      tempText.setLayoutParams(params);
      mainLayout.addView(tempText);

      Button tempAcceptButton =
          new Button(getApplicationContext(), null, android.R.attr.buttonStyleSmall);
      tempAcceptButton.setText(R.string.show_invitations_accept);
      column = GridLayout.spec(1);
      params = new GridLayout.LayoutParams(row, column);
      tempAcceptButton.setLayoutParams(params);
      tempAcceptButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              accept(tempText.getText().toString(), mainLayout.getFocusedChild());
            }
          });
      mainLayout.addView(tempAcceptButton);

      Button tempRefuseButton =
          new Button(getApplicationContext(), null, android.R.attr.buttonStyleSmall);
      tempRefuseButton.setText(R.string.show_invitations_refuse);
      column = GridLayout.spec(2);
      params = new GridLayout.LayoutParams(row, column);
      tempRefuseButton.setLayoutParams(params);
      tempRefuseButton.setOnClickListener(
          new View.OnClickListener() {
            @Override
            public void onClick(View v) {
              refuse(tempText.getText().toString(), mainLayout.getFocusedChild());
            }
          });
      mainLayout.addView(tempRefuseButton);
    }
  }