meltingpotteam / geeft

geeve new life to old objects
http://geeft.rf.gd
4 stars 4 forks source link

[FRONT_END/ BACK_END] Logout from app: intent, database call #20

Closed UNOAlterEgo closed 8 years ago

UNOAlterEgo commented 8 years ago

Description: Allowing user to logout from app Requires: intent, calls to BaaS backend Status: Coding Time: 2 Hours

UNOAlterEgo commented 8 years ago

How can I implement an alert dialog to ask the user if they really want to logout?

vega-dev commented 8 years ago

you should write something like this:

           `AlertDialog.Builder alertDialog = new AlertDialog.Builder(CONTEXT_YOU_WANT)); //Read Update
            LayoutInflater inflater = getLayoutInflater();
            View dialogLayout = inflater.inflate(R.layout.geeft_image_dialog, null);
            alertDialog.setView(dialogLayout);
            alertDialog.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
               //the positive button should call the "logout method"
               @Override
                public void onClick(DialogInterface dialog, int which) {
                    //here you can add functions
                    LOGOUT_METHOD
                }
            });
            alertDialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
               //cancel the intent
               @Override
                public void onClick(DialogInterface dialog, int which) {
                    //here you can add functions
                   dialog.dismiss();
                }
            });
            //On click, the user visualize can visualize some infos about the geefter
            AlertDialog dialog = alertDialog.create();
            //the context i had to use is the context of the dialog! not the context of the 

           //set the title 
           dialog.setTitle("TITLE OF THE DIALOG")
           //if you don't want the title
           //use this: dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);

            dialog.getWindow().getAttributes().windowAnimations = R.style.dialog_animation;
            dialog.setMessage("MESSAGE YOU WANT TO RETURN TO THE USER");
            dialog.show();  //<-- See This!
UNOAlterEgo commented 8 years ago

thanks my code is similar but I created a style to handle the layout

UNOAlterEgo commented 8 years ago

logout implemented with alert dialog