use of android.content.DialogInterface.OnShowListener in project bitcoin-wallet by bitcoin-wallet.
the class MaintenanceDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final View view = LayoutInflater.from(activity).inflate(R.layout.maintenance_dialog, null);
Coin value = Coin.ZERO;
Coin fee = Coin.ZERO;
for (final Transaction tx : determineMaintenanceTransactions()) {
value = value.add(tx.getValueSentFromMe(wallet));
fee = fee.add(tx.getFee());
}
final TextView messageView = (TextView) view.findViewById(R.id.maintenance_dialog_message);
final MonetaryFormat format = application.getConfiguration().getFormat();
messageView.setText(getString(R.string.maintenance_dialog_message, format.format(value), format.format(fee)));
passwordGroup = view.findViewById(R.id.maintenance_dialog_password_group);
passwordView = (EditText) view.findViewById(R.id.maintenance_dialog_password);
passwordView.setText(null);
badPasswordView = view.findViewById(R.id.maintenance_dialog_bad_password);
final DialogBuilder builder = new DialogBuilder(activity);
builder.setTitle(R.string.maintenance_dialog_title);
builder.setView(view);
// dummies, just to make buttons show
builder.setPositiveButton(R.string.maintenance_dialog_button_move, null);
builder.setNegativeButton(R.string.button_dismiss, null);
builder.setCancelable(false);
final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(final DialogInterface d) {
positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
positiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
log.info("user decided to do maintenance");
handleGo();
}
});
negativeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
log.info("user decided to dismiss");
dismissAllowingStateLoss();
}
});
passwordView.addTextChangedListener(textWatcher);
MaintenanceDialogFragment.this.dialog = dialog;
updateView();
}
});
log.info("showing maintenance dialog");
return dialog;
}
use of android.content.DialogInterface.OnShowListener in project bitcoin-wallet by bitcoin-wallet.
the class RaiseFeeDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final View view = LayoutInflater.from(activity).inflate(R.layout.raise_fee_dialog, null);
messageView = (TextView) view.findViewById(R.id.raise_fee_dialog_message);
passwordGroup = view.findViewById(R.id.raise_fee_dialog_password_group);
passwordView = (EditText) view.findViewById(R.id.raise_fee_dialog_password);
passwordView.setText(null);
badPasswordView = view.findViewById(R.id.raise_fee_dialog_bad_password);
final DialogBuilder builder = new DialogBuilder(activity);
builder.setTitle(R.string.raise_fee_dialog_title);
builder.setView(view);
// dummies, just to make buttons show
builder.setPositiveButton(R.string.raise_fee_dialog_button_raise, null);
builder.setNegativeButton(R.string.button_dismiss, null);
builder.setCancelable(false);
final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(final DialogInterface d) {
positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
positiveButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
handleGo();
}
});
negativeButton.setOnClickListener(new OnClickListener() {
@Override
public void onClick(final View v) {
dismissAllowingStateLoss();
}
});
passwordView.addTextChangedListener(textWatcher);
RaiseFeeDialogFragment.this.dialog = dialog;
updateView();
}
});
log.info("showing raise fee dialog");
return dialog;
}
use of android.content.DialogInterface.OnShowListener in project bitcoin-wallet by bitcoin-wallet.
the class EncryptKeysDialogFragment method onCreateDialog.
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final View view = LayoutInflater.from(activity).inflate(R.layout.encrypt_keys_dialog, null);
oldPasswordGroup = view.findViewById(R.id.encrypt_keys_dialog_password_old_group);
oldPasswordView = (EditText) view.findViewById(R.id.encrypt_keys_dialog_password_old);
oldPasswordView.setText(null);
newPasswordView = (EditText) view.findViewById(R.id.encrypt_keys_dialog_password_new);
newPasswordView.setText(null);
badPasswordView = view.findViewById(R.id.encrypt_keys_dialog_bad_password);
passwordStrengthView = (TextView) view.findViewById(R.id.encrypt_keys_dialog_password_strength);
showView = (CheckBox) view.findViewById(R.id.encrypt_keys_dialog_show);
final DialogBuilder builder = new DialogBuilder(activity);
builder.setTitle(R.string.encrypt_keys_dialog_title);
builder.setView(view);
// dummies, just to make buttons show
builder.setPositiveButton(R.string.button_ok, null);
builder.setNegativeButton(R.string.button_cancel, null);
builder.setCancelable(false);
final AlertDialog dialog = builder.create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnShowListener(new OnShowListener() {
@Override
public void onShow(final DialogInterface d) {
positiveButton = dialog.getButton(DialogInterface.BUTTON_POSITIVE);
negativeButton = dialog.getButton(DialogInterface.BUTTON_NEGATIVE);
positiveButton.setTypeface(Typeface.DEFAULT_BOLD);
positiveButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
handleGo();
}
});
negativeButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(final View v) {
dismissAllowingStateLoss();
}
});
oldPasswordView.addTextChangedListener(textWatcher);
newPasswordView.addTextChangedListener(textWatcher);
showView = (CheckBox) dialog.findViewById(R.id.encrypt_keys_dialog_show);
showView.setOnCheckedChangeListener(new ShowPasswordCheckListener(newPasswordView, oldPasswordView));
showView.setChecked(true);
EncryptKeysDialogFragment.this.dialog = dialog;
updateView();
}
});
return dialog;
}
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