Search in sources :

Example 56 with AlertDialog

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 57 with AlertDialog

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) SalesReport(com.example.asus.onlinecanteen.model.SalesReport)

Example 58 with AlertDialog

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) Intent(android.content.Intent)

Example 59 with AlertDialog

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));
    }
}
Also used : AlertDialog(android.support.v7.app.AlertDialog)

Example 60 with AlertDialog

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();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) Task(com.google.android.gms.tasks.Task) User(garbagecollectors.com.unipool.User) DatabaseReference(com.google.firebase.database.DatabaseReference) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) TripEntry(garbagecollectors.com.unipool.TripEntry) ProgressDialog(android.app.ProgressDialog) DataSnapshot(com.google.firebase.database.DataSnapshot)

Aggregations

AlertDialog (android.support.v7.app.AlertDialog)410 DialogInterface (android.content.DialogInterface)274 View (android.view.View)219 TextView (android.widget.TextView)165 Intent (android.content.Intent)117 EditText (android.widget.EditText)86 ImageView (android.widget.ImageView)69 Button (android.widget.Button)68 LayoutInflater (android.view.LayoutInflater)59 RecyclerView (android.support.v7.widget.RecyclerView)54 NonNull (android.support.annotation.NonNull)52 AdapterView (android.widget.AdapterView)51 SuppressLint (android.annotation.SuppressLint)50 ArrayList (java.util.ArrayList)49 Bundle (android.os.Bundle)47 ListView (android.widget.ListView)42 Context (android.content.Context)35 SharedPreferences (android.content.SharedPreferences)35 Uri (android.net.Uri)32 LinearLayout (android.widget.LinearLayout)30