[Here from Dialog Box I keep 3 Check Box,One user can chose one or more that one as they want.As example if one chose clear history and dont ask me again than when i click yes button it clean all history and it never see the dialog in future.My problem is it work fine when chose only one but when chose more that one it get only 1st one .` @Override public void closeBrowserFromRightMenu() {
createExitDialog();
}
public void createExitDialog() {
dialog = new Dialog(this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
dialog.setCancelable(true);
//View view = LayoutInflater.from(this).inflate(this, R.layout.alert_layout, null);
View view = View.inflate(this, R.layout.alart_exit_dialog, null);
CheckBox dontShowAgain = view.findViewById(R.id.select_3);
CheckBox clearHistory = view.findViewById(R.id.select_1);
CheckBox clearCookies = view.findViewById(R.id.cat_select_2);
//noinspection Convert2Lambda
view.findViewById(R.id.ritsDialogCancle).setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
dialog.dismiss();
}
});
TextView title = view.findViewById(R.id.ritsDialogTitle);
title.setText(getResources().getString(R.string.exit_message));
// TextView message = view.findViewById(R.id.ritsDialogMessage);
//message.setVisibility(View.GONE);
Button confirm = view.findViewById(R.id.ritsDialogAgree);
//noinspection Convert2Lambda
confirm.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
String checkBoxResult = "NOT checked";
if (clearCookies.isChecked()) {
Log.e("hgguygujgjjyfg", "clear cookies");
WebUtils.clearCookies(BrowserActivity.this);
//mMessageHandler.sendEmptyMessage(2);
}
if (clearHistory.isChecked()) {
Log.e("hgguygujgjjyfg", "clear history");
WebUtils.clearHistory(BrowserActivity.this, mHistoryDatabase);
//mMessageHandler.sendEmptyMessage(1);
}
if (dontShowAgain.isChecked()) {
checkBoxResult = "checked";
SharedPreferences settings = getSharedPreferences(SETTINGS_ASK_ME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putString("skipMessage", checkBoxResult);
// Commit the edits!
editor.apply();
}
dialog.dismiss();
ExitActiivity.exitApplication(BrowserActivity.this);
}
});
SharedPreferences settings = getSharedPreferences(SETTINGS_ASK_ME, 0);
String skipMessage = settings.getString("skipMessage", "NOT checked");
if (!skipMessage.equals("checked")) {
dialog.setContentView(view);
dialog.show();
} else {
ExitActiivity.exitApplication(BrowserActivity.this);
}
}`][1]
Aucun commentaire:
Enregistrer un commentaire