use of android.support.v7.app.AlertDialog in project OnlineCanteen by josephgunawan97.
the class MainUserActivity method logout.
// User Logout
public void logout() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.signOut_confirmation).setCancelable(false).setPositiveButton(R.string.signOut_confirm, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
firebaseAuth.getInstance().signOut();
Intent intent = new Intent(MainUserActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
}).setNegativeButton(R.string.signOut_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.setTitle(R.string.signOut_title);
alert.show();
}
use of android.support.v7.app.AlertDialog in project OnlineCanteen by josephgunawan97.
the class MerchantSettingsActivity method generateReport.
public void generateReport() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.salesReport_confirmation).setCancelable(false).setPositiveButton(R.string.salesReport_confirm, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
database = FirebaseDatabase.getInstance().getReference("salesreportrequest");
SalesReport salesReport = new SalesReport(merchant.getUid());
database.push().setValue(salesReport);
Toast.makeText(MerchantSettingsActivity.this, R.string.salesReport_reply, Toast.LENGTH_SHORT).show();
}
}).setNegativeButton(R.string.salesReport_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.setTitle(R.string.salesReport_title);
alert.show();
}
use of android.support.v7.app.AlertDialog in project OnlineCanteen by josephgunawan97.
the class MerchantSettingsActivity method logout.
// User Logout
public void logout() {
AlertDialog.Builder builder = new AlertDialog.Builder(this);
builder.setMessage(R.string.signOut_confirmation).setCancelable(false).setPositiveButton(R.string.signOut_confirm, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
firebaseAuth = FirebaseAuth.getInstance();
merchant = firebaseAuth.getCurrentUser();
firebaseAuth.getInstance().signOut();
Intent intent = new Intent(MerchantSettingsActivity.this, LoginActivity.class);
startActivity(intent);
finish();
}
}).setNegativeButton(R.string.signOut_cancel, new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int id) {
dialog.cancel();
}
});
AlertDialog alert = builder.create();
alert.setTitle(R.string.signOut_title);
alert.show();
}
use of android.support.v7.app.AlertDialog in project fdroidclient by f-droid.
the class CrashReportActivity method init.
@Override
protected void init(Bundle savedInstanceState) {
super.init(savedInstanceState);
final AlertDialog dialog = new AlertDialog.Builder(this).setTitle(R.string.crash_dialog_title).setView(R.layout.crash_report_dialog).setPositiveButton(R.string.ok, this).setNegativeButton(R.string.cancel, this).create();
dialog.setCanceledOnTouchOutside(false);
dialog.setOnDismissListener(this);
dialog.show();
comment = (EditText) dialog.findViewById(android.R.id.input);
if (savedInstanceState != null) {
comment.setText(savedInstanceState.getString(STATE_COMMENT));
}
}
use of android.support.v7.app.AlertDialog in project UniPool by divya21raj.
the class HomeActivityTEA method sendRequest.
private void sendRequest(View view, int position) {
alertDialogBuilder.setMessage("Send request to " + list.get(position).getName() + " ?");
alertDialogBuilder.setPositiveButton("YES", (dialog, which) -> {
progressDialog = new ProgressDialog(view.getContext());
progressDialog.setMessage("Please wait...");
User user = BaseActivity.getFinalCurrentUser();
TripEntry tripEntry = list.get(position);
if (tripEntry.getUser_id().equals(user.getUserId())) {
Toast.makeText(view.getContext(), "Can't pool with yourself, that feature isn't ready yet...", Toast.LENGTH_SHORT).show();
return;
}
progressDialog.show();
final User[] tripEntryUser = new User[1];
// the user that created the clicked tripEntry
Task userTask = accessUserDatabase("users/" + tripEntry.getUser_id());
userTask.addOnSuccessListener(aVoid -> {
DataSnapshot snapshot = (DataSnapshot) userTask.getResult();
tripEntryUser[0] = snapshot.getValue(User.class);
DatabaseReference userDatabaseReference = FirebaseDatabase.getInstance().getReference("users");
DatabaseReference notificationDatabaseReference = BaseActivity.getNotificationDatabaseReference();
HashMap<String, TripEntry> requestSent = user.getRequestSent();
HashMap<String, ArrayList<String>> requestsReceived = tripEntryUser[0].getRequestsReceived();
isAlreadyRequested = addRequestInList(requestSent, user.getPairUps(), tripEntry);
if (!isAlreadyRequested) {
isRequestAlreadyInMap = putInMap(requestsReceived, tripEntry.getEntry_id(), user.getUserId());
}
user.setRequestSent(requestSent);
tripEntryUser[0].setRequestsReceived(requestsReceived);
if (!isAlreadyRequested && !isRequestAlreadyInMap) {
// update firebase database to include arrayList that contains name of the item_trip_entry clicked in requests sent...
Task<Void> task1 = userDatabaseReference.child(user.getUserId()).child("requestSent").setValue(requestSent);
Task<Void> task2 = userDatabaseReference.child(tripEntryUser[0].getUserId()).child("requestsReceived").setValue(requestsReceived);
HashMap<String, String> notificationObject = new HashMap<>();
notificationObject.put("from", user.getUserId());
notificationObject.put("type", "requestCreated");
Task<Void> task3 = notificationDatabaseReference.child(tripEntryUser[0].getUserId()).push().setValue(notificationObject);
Task<Void> allTask = Tasks.whenAll(task1, task2, task3);
allTask.addOnSuccessListener(bVoid -> {
progressDialog.dismiss();
BaseActivity.setFinalCurrentUser(user);
Toast.makeText(view.getContext(), "Request Sent!", Toast.LENGTH_LONG).show();
});
allTask.addOnFailureListener(e -> {
progressDialog.dismiss();
// apologize profusely to the user!
Toast.makeText(view.getContext(), "FAIL", Toast.LENGTH_LONG).show();
});
} else {
progressDialog.dismiss();
Toast.makeText(view.getContext(), "You two are already paired up!", Toast.LENGTH_LONG).show();
}
});
});
alertDialogBuilder.setNegativeButton("NO", (dialog, which) -> dialog.dismiss());
AlertDialog alert = alertDialogBuilder.create();
alert.show();
}
Aggregations