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();
}
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();
}
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();
}
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);
}
}
});
}
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();
}
Aggregations