I'm having a problem with this code
if ((equip != null) && equip.trim().equals("")){
final Dialog dialog = new Dialog(getActivity());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
dialog.setContentView(R.layout.dialog_layout_equip);
And my else is
final Dialog dialog = new Dialog(getActivity());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
dialog.setContentView(R.layout.dialog_layout);
So if my string is null or empty i use this dialog dialog.setContentView(R.layout.dialog_layout); Otherwise i use this one dialog.setContentView(R.layout.dialog_layout_equip);
My logcat gives me this output from this code
String equip = reserveComp.getString(TAG_EQUIP);
Log.d("Equip", equip);
D/Equip﹕ Projetor, so it open the
dialog.setContentView(R.layout.dialog_layout);
but when i have this output D/Equip﹕ null it open the same
So whats wrong?
UPDATE
This is my full block code
JSONObject reserveComp = reqFeitasDetail.getJSONObject(0);
String equip = reserveComp.getString(TAG_EQUIP);
Log.d("Equip", equip);
if ((equip == null) || equip.trim().equals("")){
final Dialog dialog = new Dialog(getActivity());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
dialog.setContentView(R.layout.dialog_layout);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
Button img = (Button) dialog.findViewById(R.id.close_button);
TextView data = (TextView) dialog.findViewById(R.id.data);
TextView sala = (TextView) dialog.findViewById(R.id.sala);
TextView hora = (TextView) dialog.findViewById(R.id.hora_inicial);
TextView fim = (TextView) dialog.findViewById(R.id.hora_final);
data.setText(reserveComp.getString(TAG_DATA));
sala.setText(reserveComp.getString(TAG_NOME));
hora.setText(reserveComp.getString(TAG_TEMPO));
fim.setText(reserveComp.getString(TAG_TEMPOFIM));
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
} else {
final Dialog dialog = new Dialog(getActivity());
dialog.getWindow().requestFeature(Window.FEATURE_NO_TITLE);
dialog.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_LAYOUT_IN_SCREEN);
dialog.setContentView(R.layout.dialog_layout_equip);
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
dialog.show();
Button img = (Button) dialog.findViewById(R.id.close_button);
TextView data = (TextView) dialog.findViewById(R.id.data);
TextView sala = (TextView) dialog.findViewById(R.id.sala);
TextView equipamento = (TextView) dialog.findViewById(R.id.equip);
TextView hora = (TextView) dialog.findViewById(R.id.hora_inicial);
TextView fim = (TextView) dialog.findViewById(R.id.hora_final);
data.setText(reserveComp.getString(TAG_DATA));
sala.setText(reserveComp.getString(TAG_NOME));
equipamento.setText(reserveComp.getString(TAG_EQUIP));
hora.setText(reserveComp.getString(TAG_TEMPO));
fim.setText(reserveComp.getString(TAG_TEMPOFIM));
img.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dialog.dismiss();
}
});
}
And i had this logcat output
D/Reserva Sala completa﹕ {"tag":"reqEquipFull","success":1,"error":0,"reqEquipFull":[{"data":"2015-06-12","sala":"21","inicio":"14:05:00","fim":"15:45:00","nome":null}]}
D/Equip﹕ null
And i still have the same problem with the dialog, all (null and non null) open this dialog
dialog.setContentView(R.layout.dialog_layout_equip);
equipis empty you can use :if(TextUtils.isEmpty(equip))