use of android.content.DialogInterface in project wire-android by wireapp.
the class PickUserFragment method onContactListContactClicked.
@Override
public void onContactListContactClicked(final ContactDetails contactDetails) {
getStoreFactory().getNetworkStore().doIfHasInternetOrNotifyUser(new DefaultNetworkAction() {
@Override
public void execute(NetworkMode networkMode) {
final int contactMethodsCount = contactDetails.getContactMethods().size();
final ContactMethod[] contactMethods = contactDetails.getContactMethods().toArray(new ContactMethod[contactMethodsCount]);
if (contactMethodsCount == 1 && contactMethods[0].getKind() == ContactMethod.Kind.SMS) {
// Launch SMS app directly if contact only has phone numner
final String number = contactMethods[0].getStringRepresentation();
sendSMSInvite(number);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.ADDRESSBOOK));
return;
}
final CharSequence[] itemNames = new CharSequence[contactMethodsCount];
for (int i = 0; i < contactMethodsCount; i++) {
ContactMethod contactMethod = contactMethods[i];
itemNames[i] = contactMethod.getStringRepresentation();
}
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setTitle(getResources().getString(R.string.people_picker__contact_list__invite_dialog__title)).setPositiveButton(getResources().getText(R.string.confirmation_menu__confirm_done), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
ListView lv = dialog.getListView();
int selected = lv.getCheckedItemPosition();
ContactMethod selectedContactMethod = null;
if (selected >= 0) {
selectedContactMethod = contactMethods[selected];
}
if (selectedContactMethod == null) {
return;
}
if (selectedContactMethod.getKind() == ContactMethod.Kind.SMS) {
final String number = String.valueOf(itemNames[selected]);
sendSMSInvite(number);
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).tagEvent(new OpenedGenericInviteMenuEvent(OpenedGenericInviteMenuEvent.EventContext.ADDRESSBOOK));
} else {
selectedContactMethod.invite(" ", null);
Toast.makeText(getActivity(), getResources().getString(R.string.people_picker__invite__sent_feedback), Toast.LENGTH_LONG).show();
boolean fromSearch = TextUtils.isEmpty(getControllerFactory().getPickUserController().getSearchFilter());
TrackingUtils.tagSentInviteToContactEvent(((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class), selectedContactMethod.getKind(), contactDetails.hasBeenInvited(), fromSearch);
}
}
}).setNegativeButton(getResources().getText(R.string.confirmation_menu__cancel), new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.cancel();
}
}).setSingleChoiceItems(itemNames, DEFAULT_SELECTED_INVITE_METHOD, null);
dialog = builder.create();
dialog.show();
((BaseScalaActivity) getActivity()).injectJava(GlobalTrackingController.class).onApplicationScreen(ApplicationScreen.SEND_PERSONAL_INVITE_MENU);
}
});
}
use of android.content.DialogInterface in project WordPress-Android by wordpress-mobile.
the class CommentsListFragment method confirmDeleteComments.
private void confirmDeleteComments() {
if (mCommentStatusFilter == CommentStatusCriteria.TRASH) {
AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(getActivity());
dialogBuilder.setTitle(getResources().getText(R.string.delete));
int resId = getAdapter().getSelectedCommentCount() > 1 ? R.string.dlg_sure_to_delete_comments : R.string.dlg_sure_to_delete_comment;
dialogBuilder.setMessage(getResources().getText(resId));
dialogBuilder.setPositiveButton(getResources().getText(R.string.yes), new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
deleteSelectedComments(true);
}
});
dialogBuilder.setNegativeButton(getResources().getText(R.string.no), null);
dialogBuilder.setCancelable(true);
dialogBuilder.create().show();
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(getActivity());
builder.setMessage(R.string.dlg_confirm_trash_comments);
builder.setTitle(R.string.trash);
builder.setCancelable(true);
builder.setPositiveButton(R.string.trash_yes, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
deleteSelectedComments(false);
}
});
builder.setNegativeButton(R.string.trash_no, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.show();
}
}
use of android.content.DialogInterface in project HumaneApp by Ganesh1010.
the class GPSTracker method showSettingsAlert.
/**
* Function to show settings alert dialog
*/
public void showSettingsAlert() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(mContext);
//Setting Dialog Title
alertDialog.setTitle("GPSAlertDialogTitle");
//Setting Dialog Message
alertDialog.setMessage("GPSAlertDialogMessage");
//On Pressing Setting button
alertDialog.setPositiveButton(R.string.action_settings, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_LOCATION_SOURCE_SETTINGS);
mContext.startActivity(intent);
}
});
//On pressing cancel button
alertDialog.setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
alertDialog.show();
}
use of android.content.DialogInterface in project HumaneApp by Ganesh1010.
the class OrganisationRegistrationFragment method onCreateView.
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
Bundle i = getArguments();
if (i != null) {
orgDetailsString = i.getString("COORDINATOR");
}
if (v == null)
v = inflater.inflate(R.layout.fragment_organisation_register_page, container, false);
landingPage = (LandingPage) getActivity();
orgNoEditText = (EditText) v.findViewById(R.id.org_register_num_editText_org_form);
orgNameEditText = (EditText) v.findViewById(R.id.org_name_editText_org_form);
orgaddressEditText = (EditText) v.findViewById(R.id.org_address_editText_org_form);
orgEmailEditText = (EditText) v.findViewById(R.id.org_email_editText_org_form);
orgMobNoEditText = (EditText) v.findViewById(R.id.org_phone_editText_org_form);
orgDescEditText = (EditText) v.findViewById(R.id.org_desc_editText_org_form);
orgTypeFromSpinner = (Spinner) v.findViewById(R.id.org_type_spinner_org_form);
orgRegisterButton = (Button) v.findViewById(R.id.submit_button_org_form);
chooseLocationButton = (Button) v.findViewById(R.id.map);
//v.getRootView().setBackgroundColor(Color.WHITE);
orgRegisterButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
register();
}
});
chooseLocationButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View arg0) {
// create class object
gps = new GPSTracker(landingPage);
// check if GPS enabled
if (gps.getIsGPSTrackingEnabled()) {
if (isNetworkAvailable()) {
Intent intent = new Intent(landingPage, MapActivity.class);
startActivityForResult(intent, 2);
} else {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(landingPage);
alertDialog.setTitle("Internet settings");
alertDialog.setMessage("Mobile data is not enabled. Do you want to go to settings menu?");
// On pressing Settings button
alertDialog.setPositiveButton("Settings", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(Settings.ACTION_SETTINGS);
startActivity(intent);
}
});
alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int which) {
dialog.cancel();
}
});
// Showing Alert Message
alertDialog.show();
}
} else {
gps.showSettingsAlert();
}
}
});
return v;
}
use of android.content.DialogInterface in project HumaneApp by Ganesh1010.
the class DonationConfirmationActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_donation_confirmation);
mainItemList = (LinearLayout) findViewById(R.id.mainItemNeedList);
for (int i = 0; i < 2; i++) {
ImageView mainItem = new ImageView(getApplicationContext());
mainItem.setBackgroundResource(R.drawable.ic_cloth_black);
mainItemList.addView(mainItem);
LinearLayout.LayoutParams margins = new LinearLayout.LayoutParams(mainItem.getLayoutParams());
margins.rightMargin = 20;
margins.leftMargin = 20;
mainItem.setLayoutParams(margins);
mainItem.setMinimumHeight(100);
mainItem.setMaxHeight(200);
mainItem.setMinimumWidth(100);
mainItem.setMaxWidth(200);
mainItem.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
AlertDialog.Builder builder = new AlertDialog.Builder(DonationConfirmationActivity.this);
builder.setTitle("Item Details");
LayoutInflater inflater = (LayoutInflater) getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
View dialogView = inflater.inflate(R.layout.donation_confirmation_item_display, null);
RecyclerView itemToDisplay = (RecyclerView) dialogView.findViewById(R.id.itemToDisplay);
itemToDisplay.setAdapter(new DonationConfirmationItemDisplayAdapter());
builder.setView(dialogView);
itemToDisplay.setAdapter(new DonationConfirmationItemDisplayAdapter());
builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
});
}
}
Aggregations