Java 类android.support.v7.app.AlertDialog.Builder 实例源码
项目:xlight_android_native
文件:PasswordResetActivity.java
public void onPasswordResetClicked(View v) {
SEGAnalytics.track("Auth: Request password reset");
final String email = emailView.getText().toString();
if (isEmailValid(email)) {
performReset();
} else {
new Builder(this)
.setTitle(getString(R.string.reset_password_dialog_title))
.setMessage(getString(R.string.reset_paassword_dialog_please_enter_a_valid_email))
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
emailView.requestFocus();
})
.show();
}
}
项目:xlight_android_native
文件:DiscoverDeviceActivity.java
private void onWifiDisabled() {
log.d("Wi-Fi disabled; prompting user");
new AlertDialog.Builder(this)
.setTitle(R.string.wifi_required)
.setPositiveButton(R.string.enable_wifi, (dialog, which) -> {
dialog.dismiss();
log.i("Enabling Wi-Fi at the user's request.");
wifiFacade.setWifiEnabled(true);
wifiListFragment.scanAsync();
})
.setNegativeButton(R.string.exit_setup, (dialog, which) -> {
dialog.dismiss();
finish();
})
.show();
}
项目:xlight_android_native
文件:DiscoverDeviceActivity.java
private void onMaxAttemptsReached() {
if (!isResumed) {
finish();
return;
}
String errorMsg = Phrase.from(this, R.string.unable_to_connect_to_soft_ap)
.put("device_name", getString(R.string.device_name))
.format().toString();
new AlertDialog.Builder(this)
.setTitle(R.string.error)
.setMessage(errorMsg)
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
startActivity(new Intent(DiscoverDeviceActivity.this, GetReadyActivity.class));
finish();
})
.show();
}
项目:boohee_v5.6
文件:SportDetailActivity.java
private void prepareDownload() {
if (!HttpUtils.isNetworkAvailable(this)) {
Helper.showToast((CharSequence) "当前处于无网环境,无法下载");
} else if (HttpUtils.isWifiConnection(this)) {
this.menuDownload.setTitle("下载中");
DownloadService.intentDownload(this, this.mRecord);
} else {
new Builder(this).setMessage(getString(R.string.jn)).setPositiveButton((CharSequence)
"继续下载", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
SportDetailActivity.this.menuDownload.setTitle("下载中");
DownloadService.intentDownload(SportDetailActivity.this, SportDetailActivity
.this.mRecord);
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
}
项目:boohee_v5.6
文件:DownloadManageActivity.java
private void showDeleteDialog() {
if (this.mAdapter.getSelectVideos().size() == 0) {
Helper.showToast((CharSequence) "请选择要删除的视频");
} else {
new Builder(this).setTitle((CharSequence) "清除视频缓存").setMessage((CharSequence)
"清除视频缓存后,已下载的运动视频需要重新下载").setPositiveButton((CharSequence) "确定清除", new
DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
DownloadHelper.getInstance().deleteDownload(DownloadManageActivity.this
.mAdapter.getSelectVideos());
DownloadManageActivity.this.mAdapter.setList(DownloadHelper.getInstance()
.getRecordsList());
DownloadManageActivity.this.changeEditMode(DownloadManageActivity.this
.menuEdit);
if (DownloadHelper.getInstance().getRecordsList().size() == 0) {
DownloadManageActivity.this.showEmpty();
}
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
}
项目:boohee_v5.6
文件:OrderListAdapter.java
private void submitOrder(final int orderId, final int position) {
new Builder(this.ctx).setTitle((CharSequence) "确认收货").setMessage((CharSequence)
"是否确认收货?").setPositiveButton((CharSequence) "确定", new DialogInterface
.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
ShopApi.finishOrder(orderId, OrderListAdapter.this.ctx, new JsonCallback
(OrderListAdapter.this.ctx) {
public void onFinish() {
OrderListAdapter.this.orders.remove(position);
OrderListAdapter.this.notifyDataSetChanged();
}
public void fail(String message) {
Helper.showToast((CharSequence) message);
}
});
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
项目:boohee_v5.6
文件:MenuDialogHelper.java
public void show(IBinder windowToken) {
MenuBuilder menu = this.mMenu;
Builder builder = new Builder(menu.getContext());
this.mPresenter = new ListMenuPresenter(builder.getContext(), R.layout.abc_list_menu_item_layout);
this.mPresenter.setCallback(this);
this.mMenu.addMenuPresenter(this.mPresenter);
builder.setAdapter(this.mPresenter.getAdapter(), this);
View headerView = menu.getHeaderView();
if (headerView != null) {
builder.setCustomTitle(headerView);
} else {
builder.setIcon(menu.getHeaderIcon()).setTitle(menu.getHeaderTitle());
}
builder.setOnKeyListener(this);
this.mDialog = builder.create();
this.mDialog.setOnDismissListener(this);
LayoutParams lp = this.mDialog.getWindow().getAttributes();
lp.type = CloseFrame.REFUSE;
if (windowToken != null) {
lp.token = windowToken;
}
lp.flags |= 131072;
this.mDialog.show();
}
项目:Chit-Chat
文件:ChatActivityFragment.java
public void showImageSelectionPopup(final Fragment fragment, final int requestCodeCapture, final int requestCodePick) {
new Builder(fragment.getContext()).setTitle(string.pick_image_from)
.setItems(array.pick_image_option_list_array, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
startPickImage();
} else if (which == 1) {
Intent PickImageintent = new Intent().setType("image/*").setAction(Intent.ACTION_GET_CONTENT);
if (PickImageintent.resolveActivity(fragment.getContext().getPackageManager()) != null) {
fragment.startActivityForResult(PickImageintent, requestCodePick);
} else {
Toast.makeText(fragment.getContext(), string.cc_error_img_picker, Toast.LENGTH_SHORT).show();
}
}
}
}).create().show();
}
项目:Chit-Chat
文件:IntentUtils.java
public static void showVideoSelectionPopup(final Fragment fragment, final int requestCodeCapture, final int requestCodePick) {
new Builder(fragment.getContext()).setTitle(string.cc_pick_video_from)
.setItems(array.pick_video_option_list_array, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (which == 0) {
Intent takePictureIntent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
if (takePictureIntent.resolveActivity(fragment.getContext().getPackageManager()) != null) {
fragment.startActivityForResult(takePictureIntent, requestCodeCapture);
} else {
Toast.makeText(fragment.getContext(), string.cc_no_camera_app, Toast.LENGTH_SHORT).show();
}
} else if (which == 1) {
Intent PickImageintent = new Intent().setType("video/*").setAction(Intent.ACTION_GET_CONTENT);
if (PickImageintent.resolveActivity(fragment.getContext().getPackageManager()) != null) {
fragment.startActivityForResult(PickImageintent, requestCodePick);
} else {
Toast.makeText(fragment.getContext(), string.cc_no_video_picker, Toast.LENGTH_SHORT).show();
}
}
}
}).create().show();
}
项目:azure-mobile-engagement-app-android
文件:OutOfAppPushNotificationsFragment.java
/**
* Methods that computes and displays the dialog content.
*
* @param isForAnnouncement boolean
*/
private final void computeDialogDisplay(boolean isForAnnouncement)
{
final Builder builder = new Builder(getContext());
builder.setTitle(R.string.out_of_app_push_notifications_dialog_title);
final View dialogContainerView = LayoutInflater.from(getContext()).inflate(R.layout.dialog_out_of_app_push_notifications, (ViewGroup) getView().getParent(), false);
iconTitleMessageButton = dialogContainerView.findViewById(R.id.iconTitleMessageButton);
iconTitleMessageBigTextButton = dialogContainerView.findViewById(R.id.iconTitleMessageBigTextButton);
iconTitleMessageBigImageButton = dialogContainerView.findViewById(R.id.iconTitleMessageBigImageButton);
this.isForAnnouncement = isForAnnouncement;
iconTitleMessageButton.setOnClickListener(this);
iconTitleMessageBigTextButton.setOnClickListener(this);
iconTitleMessageBigImageButton.setOnClickListener(this);
builder.setView(dialogContainerView);
this.alertDialog = builder.create();
this.alertDialog.show();
AzmeTracker.sendEvent(getActivity(), isForAnnouncement ? "display_out_of_app_announcement" : "display_out_of_app_notification_only");
}
项目:DialogShard
文件:MainActivity.java
@Override
public Dialog onCreateDialog(final Activity activity, final Bundle savedInstanceState) {
AlertDialog.Builder builder = new Builder(activity);
builder.setTitle("title");
builder.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
//activity.startActivity(new Intent(activity, MainActivity.class));
}
});
builder.setMessage("msg");
//new Handler().postDelayed(new Runnable() {
// @Override
// public void run() {
// activity.finish();
// }
//}, 1000);
return builder.create();
}
项目:spark-setup-android
文件:PasswordResetActivity.java
public void onPasswordResetClicked(View v) {
SEGAnalytics.track("Auth: Request password reset");
final String email = emailView.getText().toString();
if (isEmailValid(email)) {
performReset();
} else {
new Builder(this)
.setTitle(getString(R.string.reset_password_dialog_title))
.setMessage(getString(R.string.reset_paassword_dialog_please_enter_a_valid_email))
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
emailView.requestFocus();
})
.show();
}
}
项目:spark-setup-android
文件:DiscoverDeviceActivity.java
private void onWifiDisabled() {
log.d("Wi-Fi disabled; prompting user");
new AlertDialog.Builder(this)
.setTitle(R.string.wifi_required)
.setPositiveButton(R.string.enable_wifi, (dialog, which) -> {
dialog.dismiss();
log.i("Enabling Wi-Fi at the user's request.");
wifiFacade.setWifiEnabled(true);
wifiListFragment.scanAsync();
})
.setNegativeButton(R.string.exit_setup, (dialog, which) -> {
dialog.dismiss();
finish();
})
.show();
}
项目:spark-setup-android
文件:DiscoverDeviceActivity.java
private void onMaxAttemptsReached() {
if (!isResumed) {
finish();
return;
}
String errorMsg = Phrase.from(this, R.string.unable_to_connect_to_soft_ap)
.put("device_name", getString(R.string.device_name))
.format().toString();
new AlertDialog.Builder(this)
.setTitle(R.string.error)
.setMessage(errorMsg)
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
startActivity(new Intent(DiscoverDeviceActivity.this, GetReadyActivity.class));
finish();
})
.show();
}
项目:arcgis-runtime-samples-android
文件:MainActivity.java
/**
* Shows message in an AlertDialog.
*
* @param message contains identify results processed into a string.
*/
private void showAlertDialog(StringBuilder message) {
Builder alertDialogBuilder = new Builder(this);
// set title
alertDialogBuilder.setTitle("Number of elements found");
// set dialog message
alertDialogBuilder
.setMessage(message)
.setCancelable(false)
.setPositiveButton("Ok", new OnClickListener() {
@Override public void onClick(DialogInterface dialog, int id) {
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show the alert dialog
alertDialog.show();
}
项目:xlight_android_native
文件:PasswordResetActivity.java
private void onResetAttemptFinished(String content) {
new AlertDialog.Builder(this)
.setMessage(content)
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
finish();
})
.show();
}
项目:xlight_android_native
文件:DiscoverDeviceActivity.java
private void onLocationDisabled() {
log.d("Location disabled; prompting user");
new Builder(this).setTitle(R.string.location_required)
.setMessage(R.string.location_required_message)
.setPositiveButton(R.string.enable_location, ((dialog, which) -> {
dialog.dismiss();
log.i("Sending user to enabling Location services.");
startActivity(new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS));
}))
.setNegativeButton(R.string.exit_setup, ((dialog, which) -> {
dialog.dismiss();
finish();
}))
.show();
}
项目:xlight_android_native
文件:DiscoverDeviceActivity.java
private void onDeviceClaimedByOtherUser() {
String dialogMsg = getString(R.string.dialog_title_owned_by_another_user,
getString(R.string.device_name), sparkCloud.getLoggedInUsername());
new Builder(this)
.setTitle(getString(R.string.change_owner_question))
.setMessage(dialogMsg)
.setPositiveButton(getString(R.string.change_owner),
(dialog, which) -> {
dialog.dismiss();
log.i("Changing owner to " + sparkCloud.getLoggedInUsername());
// // FIXME: state mutation from another class. Not pretty.
// // Fix this by breaking DiscoverProcessWorker down into Steps
resetWorker();
discoverProcessWorker.needToClaimDevice = true;
discoverProcessWorker.gotOwnershipInfo = true;
discoverProcessWorker.isDetectedDeviceClaimed = false;
DeviceSetupState.deviceNeedsToBeClaimed = true;
showProgressDialog();
startConnectWorker();
})
.setNegativeButton(R.string.cancel,
(dialog, which) -> {
dialog.dismiss();
startActivity(new Intent(DiscoverDeviceActivity.this, GetReadyActivity.class));
finish();
})
.show();
}
项目:xlight_android_native
文件:PermissionsFragment.java
public void ensurePermission(final @NonNull String permission) {
Builder dialogBuilder = new AlertDialog.Builder(getActivity())
.setCancelable(false);
// FIXME: stop referring to these location permission-specific strings here,
// try to retrieve them from the client
if (ActivityCompat.checkSelfPermission(getActivity(), permission) != PERMISSION_GRANTED ||
ActivityCompat.shouldShowRequestPermissionRationale(getActivity(), permission)) {
dialogBuilder.setTitle(R.string.location_permission_dialog_title)
.setMessage(R.string.location_permission_dialog_text)
.setPositiveButton(R.string.got_it, (dialog, which) -> {
dialog.dismiss();
requestPermission(permission);
});
} else {
// user has explicitly denied this permission to setup.
// show a simple dialog and bail out.
dialogBuilder.setTitle(R.string.location_permission_denied_dialog_title)
.setMessage(R.string.location_permission_denied_dialog_text)
.setPositiveButton(R.string.settings, (dialog, which) -> {
dialog.dismiss();
Intent intent = new Intent(Settings.ACTION_APPLICATION_DETAILS_SETTINGS);
String pkgName = getActivity().getApplicationInfo().packageName;
intent.setData(Uri.parse("package:" + pkgName));
startActivity(intent);
})
.setNegativeButton(R.string.exit_setup, (dialog, which) -> {
Client client = (Client) getActivity();
client.onUserDeniedPermission(permission);
});
}
dialogBuilder.show();
}
项目:boohee_v5.6
文件:WeightRecordActivity.java
private void showUnbindDialog() {
new Builder(this).setMessage((CharSequence) "确定解绑体重秤?").setPositiveButton((CharSequence)
"确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
OnePreference.clearWeightScale();
WeightRecordActivity.this.scaleConnHelper.stopAll();
WeightRecordActivity.this.showWeightScale();
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
项目:boohee_v5.6
文件:DownloadAdapter.java
private void prepareDownload(final DownloadVH holder, final DownloadRecord record) {
if (!HttpUtils.isNetworkAvailable(this.mContext)) {
Helper.showToast((CharSequence) "当前处于无网环境,无法下载");
} else if (HttpUtils.isWifiConnection(this.mContext)) {
startDownload(holder, record);
} else {
new Builder(this.mContext).setMessage(String.format(this.mContext.getString(R.string
.jn), new Object[]{Integer.valueOf(record.videoSize)})).setPositiveButton(
(CharSequence) "继续下载", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
DownloadAdapter.this.startDownload(holder, record);
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
}
项目:boohee_v5.6
文件:HardwareActivity.java
private void showUnbindScaleDialog() {
new Builder(this).setMessage((CharSequence) "确定解绑体重秤?").setPositiveButton((CharSequence)
"确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
OnePreference.clearWeightScale();
HardwareActivity.this.refreshWeightScale();
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
项目:boohee_v5.6
文件:HardwareActivity.java
private void showUnbindClingDialog() {
new Builder(this).setMessage((CharSequence) "确定解绑Cling手表/手环").setPositiveButton(
(CharSequence) "确定", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
HardwareActivity.this.unbindCling();
}
}).setNegativeButton((CharSequence) "取消", null).show();
}
项目:boohee_v5.6
文件:OrderDetailsActivity.java
public void onClick(View v) {
switch (v.getId()) {
case R.id.btn_pay:
doPay(this.orderId);
return;
case R.id.ll_alipay:
this.payType = "alipay";
this.tb_alipay.setChecked(true);
this.tb_wechat.setChecked(false);
this.tb_upacp.setChecked(false);
return;
case R.id.ll_wechat:
this.payType = PayService.CHANNEL_WECHAT;
this.tb_wechat.setChecked(true);
this.tb_alipay.setChecked(false);
this.tb_upacp.setChecked(false);
return;
case R.id.ll_upacp:
this.payType = PayService.CHANNEL_UPACP;
this.tb_upacp.setChecked(true);
this.tb_alipay.setChecked(false);
this.tb_wechat.setChecked(false);
return;
case R.id.btn_receive:
new Builder(this).setTitle((CharSequence) "确认收货").setMessage((CharSequence)
"是否确认收货?").setPositiveButton((CharSequence) "确定", new DialogInterface
.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
OrderDetailsActivity.this.finishOrder();
}
}).setNegativeButton((CharSequence) "取消", null).create().show();
return;
default:
return;
}
}
项目:TaipeiTechRefined
文件:CourseFragment.java
private void showInfoDialog(int id, String courseName, CourseInfo course) {
selectedCourseNo = course.getCourseNo();
Builder course_dialog_builder = new AlertDialog.Builder(getActivity());
course_dialog_builder.setTitle(courseName);
String message = String.format(Locale.TAIWAN, "%s%s\n%s%s\n%s%s\n%s%s",
getString(R.string.course_courseid), course.getCourseNo(),
getString(R.string.course_classtime), TIME_ARRAY[id - 1],
getString(R.string.course_classplace), course.getCourseRoom(),
getString(R.string.course_classteacher), course.getCourseTeacher());
course_dialog_builder.setMessage(message);
course_dialog_builder.setPositiveButton(R.string.course_classdetail, courseDetailDialogLis);
course_dialog_builder.show();
}
项目:TaipeiTechRefined
文件:Utility.java
public static void showNotification(Context context, String title,
String message, boolean is_hint) {
if (context == null) {
return;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
builder.setStyle(
new NotificationCompat
.BigTextStyle(builder)
.bigText(message)
.setBigContentTitle(title))
.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.ic_notification)
.setTicker(message);
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
TaskStackBuilder stack_builder = TaskStackBuilder.create(context);
stack_builder.addParentStack(MainActivity.class);
stack_builder.addNextIntent(intent);
PendingIntent pending_intent = stack_builder
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pending_intent);
NotificationManager notify_manager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
notify_manager.notify(is_hint ? hint_notification_index
: notification_index, builder.build());
if (!is_hint) {
notification_index++;
}
}
项目:TaipeiTechRefined
文件:Utility.java
public static void showActivityNotification(Context context, String title,
String message, Bitmap bitmap){
if (context == null) {
return;
}
NotificationCompat.Builder builder = new NotificationCompat.Builder(
context);
builder.setContentTitle(title)
.setContentText(message)
.setSmallIcon(R.drawable.activity_icon)
.setLargeIcon(BitmapUtility.loadBitmap(context, R.drawable.ic_app))
.setStyle(
new NotificationCompat
.BigPictureStyle()
.bigPicture(bitmap)
.setSummaryText(message));
Intent intent = new Intent(context, MainActivity.class);
intent.setAction(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_LAUNCHER);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
TaskStackBuilder stack_builder = TaskStackBuilder.create(context);
stack_builder.addParentStack(MainActivity.class);
stack_builder.addNextIntent(intent);
PendingIntent pending_intent = stack_builder
.getPendingIntent(0, PendingIntent.FLAG_UPDATE_CURRENT);
builder.setContentIntent(pending_intent);
NotificationManager notify_manager = (NotificationManager) context
.getSystemService(Context.NOTIFICATION_SERVICE);
notify_manager.notify(notification_index, builder.build());
notification_index++;
}
项目:TaipeiTechRefined
文件:Utility.java
public static void showDialog(String title, String msg, Context context) {
Builder builder = new AlertDialog.Builder(context);
builder.setTitle(title);
builder.setMessage(msg);
builder.setPositiveButton(R.string.back, null);
builder.show();
}
项目:TaipeiTechRefined
文件:WifiFragment.java
public void scanWifi() {
if (!checkPermission()) {
if (activityContext instanceof MainActivity) {
((MainActivity) activityContext).requestPermission(Manifest.permission.ACCESS_COARSE_LOCATION, this);
}
return;
}
if (!WifiUtility.isWifiOpen(MainApplication.getInstance())) {
Builder checkDialog = new AlertDialog.Builder(activityContext);
checkDialog.setTitle(R.string.hint);
checkDialog.setMessage(R.string.wifi_needenable);
checkDialog.setPositiveButton(R.string.wifi_enable,
new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
if (!isScan) {
isScan = true;
WifiUtility.openWifi(MainApplication
.getInstance());
WifiUtility.startScan(activityContext,
wifiReceiver);
}
}
});
checkDialog.setNegativeButton(R.string.back, null);
checkDialog.show();
} else {
if (!isScan) {
isScan = true;
WifiUtility.startScan(activityContext, wifiReceiver);
}
}
}
项目:TaipeiTechRefined
文件:AccountSettingFragment.java
@Override
public void onClick(View v) {
int id = v.getId();
switch (id) {
case R.id.save_button:
if (!validateAccount()) {
return;
}
if (!validatePassword()) {
return;
}
NportalConnector.reset();
writeSettings();
Toast.makeText(getActivity(), R.string.save_success, Toast.LENGTH_SHORT).show();
break;
case R.id.clear_button:
Model.getInstance().deleteAccountPassword();
refreshView();
break;
case R.id.nportal_link:
if (WifiUtility.isNetworkAvailable(getActivity())) {
Intent intent = new Intent(getActivity(), PortalActivity.class);
getActivity().startActivity(intent);
} else {
Toast.makeText(getActivity(), R.string.check_network_available,
Toast.LENGTH_LONG).show();
}
break;
case R.id.right_link:
AlertDialog.Builder builder = new Builder(getActivity());
builder.setTitle(R.string.right_text);
builder.setMessage(R.string.right);
builder.setPositiveButton(R.string.back, null);
builder.show();
break;
default:
closeSoftKeyboard();
break;
}
}
项目:TaipeiTechRefined
文件:CalendarListAdapter.java
@Override
public void onClick(View v) {
selectedEvent = (EventInfo) v.getTag(R.id.data_tag);
Builder builder = new AlertDialog.Builder(getContext());
builder.setTitle(R.string.activity_detail);
String message = null;
if (selectedEvent.getStartDate().compareTo(selectedEvent.getEndDate()) == 0) {
message = String.format(
Locale.TAIWAN,
"%s\n\n" + getContext().getString(R.string.activity_date) + "%s",
selectedEvent.getEvent(),
Utility.getDateString("yyyy/MM/dd (E)",
selectedEvent.getStartDate(), getContext()));
} else {
message = String.format(
Locale.TAIWAN,
"%s\n\n" + getContext().getString(R.string.activity_startdate) + "%s\n" + getContext().getString(R.string.activity_enddate) + "%s",
selectedEvent.getEvent(),
Utility.getDateString("yyyy/MM/dd (E)",
selectedEvent.getStartDate(), getContext()),
Utility.getDateString("yyyy/MM/dd (E)",
selectedEvent.getEndDate(), getContext()));
}
builder.setMessage(message);
builder.setNegativeButton(R.string.add_to_calendar, this);
builder.setPositiveButton(R.string.share_using, this);
builder.show();
}
项目:testloopmanager
文件:TestLoopsActivity.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.set_timeout:
final EditText editText =
(EditText) getLayoutInflater().inflate(R.layout.view_edit_timeout, null, false);
editText.setText(String.valueOf(timeout / 1000));
new Builder(this)
.setTitle(R.string.set_timeout)
.setView(editText)
.setNegativeButton(R.string.cancel, null)
.setPositiveButton(R.string.okay, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
try {
timeout = Integer.parseInt(editText.getText().toString()) * 1000;
SharedPreferences prefs =
PreferenceManager.getDefaultSharedPreferences(TestLoopsActivity.this);
SharedPreferences.Editor editor = prefs.edit();
editor.putLong(TIMEOUT, timeout);
editor.apply();
} catch (NumberFormatException e) {
Toast.makeText(TestLoopsActivity.this, R.string.must_be_number, Toast.LENGTH_LONG)
.show();
}
}
})
.show();
return true;
case android.R.id.home:
onBackPressed();
return true;
}
return super.onOptionsItemSelected(item);
}
项目:Ymir
文件:AbstractEnumFieldEditor.java
@Override
@NonNull
@SuppressLint("InflateParams")
public Dialog onCreateDialog(Bundle savedInstanceState) {
Context context = getActivity();
LayoutInflater layoutInflater = LayoutInflater.from(getActivity());
View view = layoutInflater.inflate(R.layout.entity_field_editor_enum_dialog, null);
listView = (ListView) view.findViewById(R.id.entity_field_editor_enum_dialog_list);
emptyView = (TextView) view.findViewById(R.id.entity_field_editor_enum_dialog_empty_view);
progressBar = (ProgressBar) view.findViewById(R.id.entity_field_editor_enum_dialog_progress_bar);
listView.setOnItemClickListener(this);
tryLoadValues();
Builder builder = new Builder(context);
builder.setNegativeButton(android.R.string.cancel, null);
builder.setView(view);
//Se o fragmento foi restaurado, o editor pode n ter sido setado ainda.
if (editor != null) {
builder.setTitle(editor.getLabel());
} else {
AndroidBugsUtils.applyWorkaroundForAlertDialogWithInvisibleTitleBug(builder);
}
return builder.create();
}
项目:NCBSinfo
文件:Login.java
private void subscribe() {
viewModel.getUserDataReceived().observe(this, new Observer<Boolean>() {
@Override
public void onChanged(@Nullable Boolean aBoolean) {
if (aBoolean != null) {
if (aBoolean) {
toggleScreen();
Intent intent = new Intent(Login.this, Home.class);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
startActivity(intent);
animateTransition();
}
}
}
});
viewModel.getErrorOccured().observe(this, new Observer<String>() {
@Override
public void onChanged(@Nullable String s) {
if (s != null) {
toggleScreen();
new Builder(Login.this)
.setTitle(getString(R.string.oops))
.setMessage(s)
.setPositiveButton(ok, new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
}
}).show();
}
}
});
}
项目:NCBSinfo
文件:EditTransport.java
@Override
public void onBackPressed() {
DrawerLayout drawer = findViewById(R.id.drawer_layout);
if (drawer.isDrawerOpen(GravityCompat.START)) {
drawer.closeDrawer(GravityCompat.START);
} else {
if (currentFragmentIndex == 0) {
super.onBackPressed();
animateTransition();
} else {
new Builder(EditTransport.this)
.setTitle(getString(R.string.are_you_sure))
.setMessage(getString(R.string.et_back_press))
.setPositiveButton(getString(R.string.et_back_cancel), new OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
finish();
animateTransition();
}
}).setNegativeButton(getString(R.string.et_back_previous), new OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
viewModel.getCurrentStep().postValue(currentFragmentIndex - 1);
}
}).show();
}
}
}
项目:DialogShard
文件:MainActivity.java
@NonNull
@Override
public Dialog onCreateDialog(final Bundle savedInstanceState) {
final FragmentActivity activity = getActivity();
AlertDialog.Builder builder = new Builder(activity);
builder.setTitle("title");
builder.setPositiveButton("OK", new OnClickListener() {
@Override
public void onClick(final DialogInterface dialog, final int which) {
}
});
builder.setMessage("msg");
return builder.create();
}
项目:Cirrus
文件:CredentialsDialogFragment.java
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
// Create field for username
mUsernameET = new EditText(getActivity());
mUsernameET.setHint(getActivity().getText(R.string.auth_username));
// Create field for password
mPasswordET = new EditText(getActivity());
mPasswordET.setHint(getActivity().getText(R.string.auth_password));
mPasswordET.setInputType(InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD);
// Prepare LinearLayout for dialog
LinearLayout ll = new LinearLayout(getActivity());
ll.setOrientation(LinearLayout.VERTICAL);
ll.addView(mUsernameET);
ll.addView(mPasswordET);
ll.requestFocus();
setRetainInstance(true);
Builder authDialog = new AlertDialog
.Builder(getActivity())
.setTitle(getActivity().getText(R.string.saml_authentication_required_text))
.setView(ll)
.setCancelable(false)
.setPositiveButton(R.string.common_ok, this)
.setNegativeButton(R.string.common_cancel, this);
Dialog d = authDialog.create();
d.getWindow().setSoftInputMode(LayoutParams.SOFT_INPUT_STATE_VISIBLE);
return d;
}
项目:FMTech
文件:ListMenuPresenter.java
public final boolean onSubMenuSelected(SubMenuBuilder paramSubMenuBuilder)
{
if (!paramSubMenuBuilder.hasVisibleItems()) {
return false;
}
MenuDialogHelper localMenuDialogHelper = new MenuDialogHelper(paramSubMenuBuilder);
MenuBuilder localMenuBuilder = localMenuDialogHelper.mMenu;
AlertDialog.Builder localBuilder = new AlertDialog.Builder(localMenuBuilder.mContext);
localMenuDialogHelper.mPresenter = new ListMenuPresenter(localBuilder.P.mContext, R.layout.abc_list_menu_item_layout);
localMenuDialogHelper.mPresenter.mCallback = localMenuDialogHelper;
localMenuDialogHelper.mMenu.addMenuPresenter(localMenuDialogHelper.mPresenter);
ListAdapter localListAdapter = localMenuDialogHelper.mPresenter.getAdapter();
localBuilder.P.mAdapter = localListAdapter;
localBuilder.P.mOnClickListener = localMenuDialogHelper;
View localView = localMenuBuilder.mHeaderView;
if (localView != null) {
localBuilder.P.mCustomTitleView = localView;
}
for (;;)
{
localBuilder.setOnKeyListener(localMenuDialogHelper);
localMenuDialogHelper.mDialog = localBuilder.create();
localMenuDialogHelper.mDialog.setOnDismissListener(localMenuDialogHelper);
WindowManager.LayoutParams localLayoutParams = localMenuDialogHelper.mDialog.getWindow().getAttributes();
localLayoutParams.type = 1003;
localLayoutParams.flags = (0x20000 | localLayoutParams.flags);
localMenuDialogHelper.mDialog.show();
if (this.mCallback != null) {
this.mCallback.onOpenSubMenu(paramSubMenuBuilder);
}
return true;
Drawable localDrawable = localMenuBuilder.mHeaderIcon;
localBuilder.P.mIcon = localDrawable;
localBuilder.setTitle(localMenuBuilder.mHeaderTitle);
}
}
项目:OpeningHoursFragment
文件:TestFragment.java
@NonNull
@SuppressLint("InflateParams")
@Override
public AppCompatDialog onCreateDialog(Bundle savedInstanceState)
{
Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle("test fragment mode");
oh = getArguments().getString(KEY_OH);
builder.setPositiveButton(android.R.string.ok, null);
return builder.create();
}
项目:spark-setup-android
文件:PasswordResetActivity.java
private void onResetAttemptFinished(String content) {
new AlertDialog.Builder(this)
.setMessage(content)
.setPositiveButton(R.string.ok, (dialog, which) -> {
dialog.dismiss();
finish();
})
.show();
}