mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 01:42:58 +08:00
Merge pull request #279 from infil00p/master
Clean-Up and Fix for Alert
This commit is contained in:
commit
64b770b761
@ -910,13 +910,32 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx);
|
AlertDialog.Builder dlg = new AlertDialog.Builder(this.ctx);
|
||||||
dlg.setMessage(message);
|
dlg.setMessage(message);
|
||||||
dlg.setTitle("Alert");
|
dlg.setTitle("Alert");
|
||||||
dlg.setCancelable(false);
|
//Don't let alerts break the back button
|
||||||
|
dlg.setCancelable(true);
|
||||||
dlg.setPositiveButton(android.R.string.ok,
|
dlg.setPositiveButton(android.R.string.ok,
|
||||||
new AlertDialog.OnClickListener() {
|
new AlertDialog.OnClickListener() {
|
||||||
public void onClick(DialogInterface dialog, int which) {
|
public void onClick(DialogInterface dialog, int which) {
|
||||||
result.confirm();
|
result.confirm();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
dlg.setOnCancelListener(
|
||||||
|
new DialogInterface.OnCancelListener() {
|
||||||
|
public void onCancel(DialogInterface dialog) {
|
||||||
|
result.confirm();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
|
//DO NOTHING
|
||||||
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
|
if(keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
|
{
|
||||||
|
result.confirm();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
});
|
||||||
dlg.create();
|
dlg.create();
|
||||||
dlg.show();
|
dlg.show();
|
||||||
return true;
|
return true;
|
||||||
@ -949,23 +968,23 @@ public class DroidGap extends PhonegapActivity {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setOnCancelListener(
|
dlg.setOnCancelListener(
|
||||||
new DialogInterface.OnCancelListener() {
|
new DialogInterface.OnCancelListener() {
|
||||||
public void onCancel(DialogInterface dialog) {
|
public void onCancel(DialogInterface dialog) {
|
||||||
result.cancel();
|
result.cancel();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
dlg.setOnKeyListener(new DialogInterface.OnKeyListener() {
|
||||||
//DO NOTHING
|
//DO NOTHING
|
||||||
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
|
||||||
if(keyCode == KeyEvent.KEYCODE_BACK)
|
if(keyCode == KeyEvent.KEYCODE_BACK)
|
||||||
{
|
{
|
||||||
result.cancel();
|
result.cancel();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
dlg.create();
|
dlg.create();
|
||||||
dlg.show();
|
dlg.show();
|
||||||
return true;
|
return true;
|
||||||
|
Loading…
Reference in New Issue
Block a user