Search in sources :

Example 51 with AlertDialog

use of android.support.v7.app.AlertDialog in project mongol-library by suragch.

the class MongolTextViewActivity method onTextClick.

// Button click methods
public void onTextClick(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Text");
    final String[] textLengths = { "TEXT 1", "TEXT 2", "TEXT 3" };
    builder.setSingleChoiceItems(textLengths, mCheckedTextItem, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            String text = TEXT_1;
            switch(which) {
                case 0:
                    text = TEXT_1;
                    break;
                case 1:
                    text = TEXT_2;
                    break;
                case 2:
                    text = TEXT_3;
                    break;
            }
            mtvExample.setText(text);
            mCheckedTextItem = which;
            dialog.dismiss();
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint)

Example 52 with AlertDialog

use of android.support.v7.app.AlertDialog in project mongol-library by suragch.

the class MongolTextViewActivity method onAlignmentClick.

public void onAlignmentClick(View view) {
    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setTitle("Alignment");
    final String[] alignments = { "TOP", "CENTER", "BOTTOM" };
    builder.setSingleChoiceItems(alignments, mCheckedAlignmentItem, new DialogInterface.OnClickListener() {

        @Override
        public void onClick(DialogInterface dialog, int which) {
            int gravity = Gravity.TOP;
            switch(which) {
                case 0:
                    gravity = Gravity.TOP;
                    break;
                case 1:
                    gravity = Gravity.CENTER;
                    break;
                case 2:
                    gravity = Gravity.BOTTOM;
                    break;
            }
            mtvExample.setGravity(gravity);
            mCheckedAlignmentItem = which;
            dialog.dismiss();
        }
    });
    AlertDialog dialog = builder.create();
    dialog.show();
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) DialogInterface(android.content.DialogInterface) SpannableString(android.text.SpannableString) TextPaint(android.text.TextPaint)

Example 53 with AlertDialog

use of android.support.v7.app.AlertDialog in project OnlineCanteen by josephgunawan97.

the class MainActivity 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(MainActivity.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 54 with AlertDialog

use of android.support.v7.app.AlertDialog in project OnlineCanteen by josephgunawan97.

the class MainActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.AppTheme);
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    // Initialize Navigation View
    DrawerLayout drawerLayout = findViewById(R.id.main_drawer_layout);
    ActionBarDrawerToggle drawerToggle = new ActionBarDrawerToggle(this, drawerLayout, R.string.navigation_open, R.string.navigation_close);
    drawerLayout.addDrawerListener(drawerToggle);
    drawerToggle.syncState();
    NavigationView navigationView = findViewById(R.id.main_navigation_view);
    navigationView.setNavigationItemSelectedListener(new MainNavigationListener());
    // Get User
    firebaseAuth = FirebaseAuth.getInstance();
    user = firebaseAuth.getCurrentUser();
    // Initialize References
    databaseUsers = FirebaseDatabase.getInstance().getReference("users");
    databaseProducts = FirebaseDatabase.getInstance().getReference("products");
    databaseStore = FirebaseDatabase.getInstance().getReference("store");
    databaseWallet = FirebaseDatabase.getInstance().getReference("wallet");
    // Product List
    ArrayList<Product> productArrayList = new ArrayList<>();
    menuListAdapter = new MenuListAdapter(this, productArrayList);
    // Initialize ListView
    productListView = findViewById(R.id.list);
    productListView.setAdapter(menuListAdapter);
    // Cart Button and Click Handler
    placeOrder = findViewById(R.id.OrderButton);
    placeOrder.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {
            cart = menuListAdapter.getList();
            // Check empty cart
            boolean emptyCart = true;
            for (Cart c : cart) {
                if (c.getQuantity() != 0) {
                    emptyCart = false;
                    break;
                }
            }
            if (emptyCart == true) {
                // Alert dialog if there are no items in cart
                AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
                builder.setMessage("You don't have any items in your cart!").setCancelable(false).setNegativeButton("Ok", new DialogInterface.OnClickListener() {

                    public void onClick(DialogInterface dialog, int id) {
                        dialog.cancel();
                    }
                });
                AlertDialog alert = builder.create();
                alert.setTitle("Error");
                alert.show();
            } else {
                // Remove item if qty is 0
                ArrayList<Cart> toRemove = new ArrayList<>();
                for (Cart c : cart) {
                    if (c.getQuantity() == 0) {
                        toRemove.add(c);
                    }
                }
                cart.removeAll(toRemove);
                // Go to cart
                Intent intent = new Intent(MainActivity.this, CartActivity.class);
                intent.putExtra("Cart", cart);
                intent.putExtra("Seller", menuListAdapter.getSeller());
                startActivity(intent);
            }
        }
    });
}
Also used : AlertDialog(android.support.v7.app.AlertDialog) NavigationView(android.support.design.widget.NavigationView) DialogInterface(android.content.DialogInterface) ActionBarDrawerToggle(android.support.v7.app.ActionBarDrawerToggle) ArrayList(java.util.ArrayList) Product(com.example.asus.onlinecanteen.model.Product) Intent(android.content.Intent) NavigationView(android.support.design.widget.NavigationView) View(android.view.View) TextView(android.widget.TextView) ListView(android.widget.ListView) DrawerLayout(android.support.v4.widget.DrawerLayout) MenuListAdapter(com.example.asus.onlinecanteen.adapter.MenuListAdapter) Cart(com.example.asus.onlinecanteen.model.Cart)

Example 55 with AlertDialog

use of android.support.v7.app.AlertDialog in project OnlineCanteen by josephgunawan97.

the class MainActivityAdmin 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(MainActivityAdmin.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)

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