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 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149
|
protected void onPrepareDialog(int id, Dialog dialog) {
/** Initialisation des pop-up de modification **/
final AlertDialog alertDialog = (AlertDialog) dialog;
final Wall selectedWall = plan.getSelectedWall();
switch (id) {
/**
* Cas d'un Mur
*/
case DIALOG_EDIT_WALL:
final EditText wall_name = (EditText) alertDialog
.findViewById(R.id.edit_wallName);
/**
* RadioGroup Mur Interieur/Exterieur
*/
final RadioGroup radioModeWall = (RadioGroup) findViewById(R.id.radioWall);
/**
* Nom du Mur
*/
wall_name.setText(selectedWall.getName_Elt());
wall_name.setVisibility(RelativeLayout.VISIBLE);
Button validbutton = (Button) alertDialog
.findViewById(R.id.valide_wall);
Button cancelbutton = (Button) alertDialog
.findViewById(R.id.cancel_wall);
/**
* Gestion du bouton de Validation
*/
validbutton.setOnClickListener(new OnClickListener() {
@SuppressWarnings("static-access")
public void onClick(View v) {
if (!plan
.getCurrentFloor()
.getPlanBatiment()
.containsWallWithName(
wall_name.getText().toString(),
selectedWall)) {
radioModeWall.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(RadioGroup group, int checkedId) {
RadioButton rb = (RadioButton) group.findViewById(checkedId);
if(null!=rb && checkedId >-1){
Toast.makeText(getApplicationContext(), rb.getText(), Toast.LENGTH_SHORT).show();
}
}
});
selectedWall
.setName_Elt(wall_name.getText().toString());
/**
* Verification si le nom du Mur n'est pas null
*/
if (wall_name.getText().toString().equals("")) {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater
.inflate(
R.layout.custom_toast,
(ViewGroup) findViewById(R.id.custom_toast_layout_id));
/** Image **/
ImageView image = (ImageView) layout
.findViewById(R.id.image);
image.setImageResource(R.drawable.warning);
/** Message **/
TextView text = (TextView) layout
.findViewById(R.id.text);
text.setText(" Champ Name null ");
text.setBackgroundColor(Color.WHITE);
/** Toast **/
Toast toast = new Toast(appContext);
toast.setDuration(Toast.LENGTH_SHORT);
toast.setGravity(Gravity.CENTER_VERTICAL, 380, -255);
toast.setView(layout);
toast.show();
wall_name.requestFocus();
return;
}
} else {
LayoutInflater inflater = getLayoutInflater();
View layout = inflater
.inflate(
R.layout.custom_toast,
(ViewGroup) findViewById(R.id.custom_toast_layout_id));
/** Image **/
ImageView image = (ImageView) layout
.findViewById(R.id.image);
image.setImageResource(R.drawable.warning);
/** Message **/
TextView text = (TextView) layout
.findViewById(R.id.text);
text.setText(" Demande Impossible !!! \n "
+ " Un Mur porte deja ce nom ");
text.setBackgroundColor(Color.WHITE);
/** Toast **/
Toast toast = new Toast(appContext);
toast.setDuration(Toast.LENGTH_LONG);
toast.setView(layout);
toast.show();
}
selectedWall.setSelected(false);
plan.setSelectedWall(null);
plan.getSelectionElementListener().setWallSelected(null);
changeToMenu(MENU_EDITION);
alertDialog.dismiss();
}
});
/**
* Gestion du bouton Annuler
*/
cancelbutton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
selectedWall.setSelected(false);
plan.setSelectedWall(null);
plan.getSelectionElementListener().setWallSelected(null);
changeToMenu(MENU_EDITION);
alertDialog.dismiss();
}
});
break; |