use of android.content.DialogInterface.OnShowListener in project bitcoin-wallet by bitcoin-wallet.
the class RestoreWalletFromExternalDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final View view = LayoutInflater.from(activity).inflate(R.layout.restore_wallet_from_external_dialog, null);
passwordView = (EditText) view.findViewById(R.id.import_keys_from_content_dialog_password);
showView = (CheckBox) view.findViewById(R.id.import_keys_from_content_dialog_show);
replaceWarningView = view.findViewById(R.id.restore_wallet_from_content_dialog_replace_warning);
final DialogBuilder builder = new DialogBuilder(activity);
builder.setTitle(R.string.import_keys_dialog_title);
builder.setView(view);
builder.setPositiveButton(R.string.import_keys_dialog_button_import, new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
final String password = passwordView.getText().toString().trim();
// get rid of it asap
passwordView.setText(null);
handleRestore(password);
}
});
builder.setNegativeButton(R.string.button_cancel, new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
// get rid of it asap
passwordView.setText(null);
activity.finish();
}
});
builder.setOnCancelListener(new OnCancelListener() {
@Override
public void onCancel(final DialogInterface dialog) {
// get rid of it asap
passwordView.setText(null);
activity.finish();
}
});
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(final DialogInterface d) {
final ImportDialogButtonEnablerListener dialogButtonEnabler = new ImportDialogButtonEnablerListener(passwordView, dialog) {
@Override
protected boolean hasFile() {
return true;
}
};
passwordView.addTextChangedListener(dialogButtonEnabler);
RestoreWalletFromExternalDialogFragment.this.dialog = dialog;
updateView();
}
});
return dialog;
}
use of android.content.DialogInterface.OnShowListener in project packages_apps_Contacts by AOKP.
the class LabeledEditorView method createCustomDialog.
/**
* Prepare dialog for entering a custom label. The input value is trimmed: white spaces before
* and after the input text is removed.
* <p>
* If the final value is empty, this change request is ignored;
* no empty text is allowed in any custom label.
*/
private Dialog createCustomDialog() {
final AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
final LayoutInflater layoutInflater = LayoutInflater.from(builder.getContext());
builder.setTitle(R.string.customLabelPickerTitle);
final View view = layoutInflater.inflate(R.layout.contact_editor_label_name_dialog, null);
final EditText editText = (EditText) view.findViewById(R.id.custom_dialog_content);
editText.setInputType(INPUT_TYPE_CUSTOM);
editText.setSaveEnabled(true);
builder.setView(view);
editText.requestFocus();
builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
final String customText = editText.getText().toString().trim();
if (ContactsUtils.isGraphic(customText)) {
final List<EditType> allTypes = RawContactModifier.getValidTypes(mState, mKind, null, true, null, true);
mType = null;
for (EditType editType : allTypes) {
if (editType.customColumn != null) {
mType = editType;
break;
}
}
if (mType == null)
return;
mEntry.put(mKind.typeColumn, mType.rawValue);
mEntry.put(mType.customColumn, customText);
rebuildLabel();
requestFocusForFirstEditField();
onLabelRebuilt();
}
}
});
builder.setNegativeButton(android.R.string.cancel, null);
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialogInterface) {
updateCustomDialogOkButtonState(dialog, editText);
}
});
editText.addTextChangedListener(new TextWatcher() {
@Override
public void onTextChanged(CharSequence s, int start, int before, int count) {
}
@Override
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
}
@Override
public void afterTextChanged(Editable s) {
updateCustomDialogOkButtonState(dialog, editText);
}
});
dialog.getWindow().setSoftInputMode(WindowManager.LayoutParams.SOFT_INPUT_STATE_ALWAYS_VISIBLE);
return dialog;
}
use of android.content.DialogInterface.OnShowListener in project Android-DialogFragments by wada811.
the class AbstractDialogFragment method setOnShowListener.
protected void setOnShowListener(Dialog dialog) {
useOnShowListener = true;
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
bindShowListener();
}
});
}
use of android.content.DialogInterface.OnShowListener in project Osmand by osmandapp.
the class IntermediatePointsDialog method applySortTargets.
private static void applySortTargets(AlertDialog dlg, final Activity activity, final List<TargetPoint> intermediates, final TIntArrayList originalPositions, final ArrayAdapter<TargetPoint> listadapter, final ProgressBar pb, final TextView textInfo) {
dlg.setOnShowListener(new OnShowListener() {
@Override
public void onShow(DialogInterface dialog) {
((AlertDialog) dialog).getButton(AlertDialog.BUTTON_NEUTRAL).setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
new AsyncTask<Void, Void, int[]>() {
protected void onPreExecute() {
pb.setVisibility(View.VISIBLE);
textInfo.setVisibility(View.VISIBLE);
}
protected int[] doInBackground(Void[] params) {
OsmandApplication app = (OsmandApplication) activity.getApplication();
Location cll = app.getLocationProvider().getLastKnownLocation();
ArrayList<TargetPoint> lt = new ArrayList<TargetPoint>(intermediates);
TargetPoint start;
if (cll != null) {
LatLon ll = new LatLon(cll.getLatitude(), cll.getLongitude());
start = TargetPoint.create(ll, null);
} else if (app.getTargetPointsHelper().getPointToStart() != null) {
TargetPoint ps = app.getTargetPointsHelper().getPointToStart();
LatLon ll = new LatLon(ps.getLatitude(), ps.getLongitude());
start = TargetPoint.create(ll, null);
// } else if(activity instanceof MapActivity) {
// LatLon ll = new LatLon(((MapActivity) activity).getMapView().getLatitude(), ((MapActivity) activity).getMapView().getLongitude());
// start = TargetPoint.create(ll, null);
} else {
start = lt.get(0);
}
TargetPoint end = lt.remove(lt.size() - 1);
ArrayList<LatLon> al = new ArrayList<LatLon>();
for (TargetPoint p : lt) {
al.add(p.point);
}
return new TspAnt().readGraph(al, start.point, end.point).solve();
}
protected void onPostExecute(int[] result) {
pb.setVisibility(View.GONE);
List<TargetPoint> alocs = new ArrayList<TargetPoint>();
TIntArrayList newOriginalPositions = new TIntArrayList();
for (int i = 0; i < result.length; i++) {
if (result[i] > 0) {
TargetPoint loc = intermediates.get(result[i] - 1);
alocs.add(loc);
newOriginalPositions.add(originalPositions.get(intermediates.indexOf(loc)));
}
}
intermediates.clear();
intermediates.addAll(alocs);
originalPositions.clear();
originalPositions.addAll(newOriginalPositions);
listadapter.notifyDataSetChanged();
}
}.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR, new Void[0]);
}
});
}
});
}
use of android.content.DialogInterface.OnShowListener in project AndFrameWorks by scwang90.
the class AfDialogBuilder method inputText.
/**
* 弹出一个文本输入框
*
* @param title 标题
* @param defaul 默认值
* @param type android.text.InputType
* @param listener 监听器
*/
@Override
public Dialog inputText(CharSequence title, final CharSequence defaul, int type, final InputTextListener listener) {
final EditText input = new EditText(mContext);
final int defaullength = defaul != null ? defaul.length() : 0;
input.setText(defaul);
input.clearFocus();
input.setInputType(type);
final CharSequence oKey = "确定";
final CharSequence msgKey = "$inputText$";
OnClickListener cancleListener = (dialog, which) -> {
AfSoftKeyboard.hideSoftKeyboard(input);
if (listener instanceof InputTextCancelable) {
((InputTextCancelable) listener).onInputTextCancel(input);
}
if (dialog != null) {
dialog.dismiss();
}
};
final OnClickListener okListener = (dialog, which) -> {
if (listener.onInputTextComfirm(input, input.getText().toString())) {
AfSoftKeyboard.hideSoftKeyboard(input);
if (dialog != null) {
dialog.dismiss();
}
}
};
final OnShowListener showListener = dialog -> {
AfSoftKeyboard.showSoftkeyboard(input);
if (defaullength > 3 && defaul.toString().matches("[^.]+\\.[a-zA-Z]\\w{1,3}")) {
input.setSelection(0, defaul.toString().lastIndexOf('.'));
} else {
input.setSelection(0, defaullength);
}
};
if (mBuildNative) {
Builder builder = new AlertDialog.Builder(mContext);
builder.setView(input);
builder.setCancelable(false);
builder.setTitle(title);
builder.setPositiveButton("确定", new SafeListener());
builder.setNegativeButton("取消", cancleListener);
final AlertDialog dialog = builder.create();
dialog.setOnShowListener(showListener);
dialog.show();
dialog.getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener(v -> new SafeListener(okListener).onClick(dialog, 0));
return dialog;
} else {
final Dialog dialog = showDialog(title, msgKey, oKey, okListener, "取消", cancleListener);
new Handler(Looper.getMainLooper()).postDelayed(() -> {
FindTextViewWithText builderHelper = FindTextViewWithText.invoke((ViewGroup) dialog.getWindow().getDecorView(), msgKey);
if (builderHelper != null) {
builderHelper.parent.removeViewAt(builderHelper.index);
builderHelper.parent.addView(input, builderHelper.index, builderHelper.textView.getLayoutParams());
showListener.onShow(dialog);
builderHelper = FindTextViewWithText.invoke((ViewGroup) dialog.getWindow().getDecorView(), oKey);
if (builderHelper != null) {
builderHelper.textView.setOnClickListener(v -> new SafeListener(okListener).onClick(dialog, 0));
}
}
}, mBuildDelayed);
return dialog;
}
}
Aggregations