use of android.content.DialogInterface.OnKeyListener in project android by nextcloud.
the class IndeterminateProgressDialog method onCreateDialog.
/**
* {@inheritDoc}
*/
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// / create indeterminate progress dialog
final ProgressDialog progressDialog = new ProgressDialog(getActivity(), R.style.ProgressDialogTheme);
progressDialog.setIndeterminate(true);
progressDialog.setOnShowListener(new DialogInterface.OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
ProgressBar v = progressDialog.findViewById(android.R.id.progress);
v.getIndeterminateDrawable().setColorFilter(ThemeColorUtils.primaryAccentColor(getContext()), android.graphics.PorterDuff.Mode.MULTIPLY);
}
});
// / set message
int messageId = getArguments().getInt(ARG_MESSAGE_ID, R.string.placeholder_sentence);
progressDialog.setMessage(getString(messageId));
// / set cancellation behavior
boolean cancelable = getArguments().getBoolean(ARG_CANCELABLE, false);
if (!cancelable) {
progressDialog.setCancelable(false);
// disable the back button
OnKeyListener keyListener = new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return keyCode == KeyEvent.KEYCODE_BACK;
}
};
progressDialog.setOnKeyListener(keyListener);
}
return progressDialog;
}
use of android.content.DialogInterface.OnKeyListener in project SmartMesh_Android by SmartMeshFoundation.
the class AddContactFriendsNewUI method initData.
@Override
protected void initData() {
setTitle(getString(R.string.contact_friends));
mList = new ArrayList<>();
mContactListAdapter = new AddContactFriendsAdapter(mList, AddContactFriendsNewUI.this);
mContactListAdapter.setContactListener(this);
mListView.setAdapter(mContactListAdapter);
contactReceiver = new RefreshContactReceiver();
IntentFilter filter = new IntentFilter(Constants.ACTION_SELECT_CONTACT_REFRESH);
filter.addAction(LoadDataService.ACTION_REFRESH_UNRECOMMENT);
LocalBroadcastManager.getInstance(this).registerReceiver(contactReceiver, filter);
mProgressDialog = LoadingDialog.showDialog(AddContactFriendsNewUI.this, null, null);
mProgressDialog.setCancelable(false);
mProgressDialog.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_BACK) {
isBack = true;
Utils.exitActivityAndBackAnim(AddContactFriendsNewUI.this, true);
}
return false;
}
});
mProgressDialog.show();
new ContactThread().start();
}
use of android.content.DialogInterface.OnKeyListener in project smartmodule by carozhu.
the class MyWebChromeHelper method onJsConfirm.
/**
* 覆盖默认的window.confirm展示界面,避免title里显示为“:来自file:////”
*/
@Override
public boolean onJsConfirm(WebView view, String url, String message, final JsResult result) {
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setTitle("lizongbo的Android webview测试confirm对话框").setMessage(message).setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm();
}
}).setNeutralButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
}
});
builder.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(DialogInterface dialog) {
result.cancel();
}
});
// 屏蔽keycode等于84之类的按键,避免按键后导致对话框消息而页面无法再弹出对话框的问题
builder.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
Log.v("onJsConfirm", "keyCode==" + keyCode + "event=" + event);
return true;
}
});
// 禁止响应按back键的事件
// builder.setCancelable(false);
AlertDialog dialog = builder.create();
dialog.show();
return true;
// return super.onJsConfirm(view, url, message, result);
}
use of android.content.DialogInterface.OnKeyListener in project smartmodule by carozhu.
the class MyWebChromeHelper method onJsPrompt.
/**
* 覆盖默认的window.prompt展示界面,避免title里显示为“:来自file:////”
* window.prompt('请输入您的域名地址', '618119.com');
*/
@Override
public boolean onJsPrompt(WebView view, String url, String message, String defaultValue, final JsPromptResult result) {
final AlertDialog.Builder builder = new AlertDialog.Builder(view.getContext());
builder.setTitle("lizongbo的Android webview测试prompt对话框").setMessage(message);
final EditText et = new EditText(view.getContext());
et.setSingleLine();
et.setText(defaultValue);
builder.setView(et);
builder.setPositiveButton("确定", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.confirm(et.getText().toString());
}
}).setNeutralButton("取消", new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
result.cancel();
}
});
// 屏蔽keycode等于84之类的按键,避免按键后导致对话框消息而页面无法再弹出对话框的问题
builder.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
Log.v("onJsPrompt", "keyCode==" + keyCode + "event=" + event);
return true;
}
});
// 禁止响应按back键的事件
// builder.setCancelable(false);
AlertDialog dialog = builder.create();
dialog.show();
return true;
// return super.onJsPrompt(view, url, message, defaultValue, result);
}
use of android.content.DialogInterface.OnKeyListener in project Android-DialogFragments by wada811.
the class AbstractDialogFragment method setOnKeyListener.
protected void setOnKeyListener(Dialog dialog) {
useOnKeyListener = true;
dialog.setOnKeyListener(new OnKeyListener() {
@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
return bindKeyListener(keyCode, event);
}
});
}
Aggregations