Skip to content

Commit

Permalink
Showing error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-i committed May 2, 2020
1 parent 3e2fe01 commit 86469fc
Showing 1 changed file with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.glowbom.mobileorders.view.ui.checkout

import android.annotation.SuppressLint
import android.app.AlertDialog
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
Expand Down Expand Up @@ -118,12 +119,12 @@ class CheckoutFragment : Fragment() {
AppManager.instance.clear()
checkoutViewModel.refresh()

Toast.makeText(activity, "Your order has been placed. See you soon!", Toast.LENGTH_SHORT).show()
showMessage("Thank you, " + AppManager.instance.name + "!", "Your order has been placed. See you soon!")
} else {
Toast.makeText(activity, "You didn't order anything.", Toast.LENGTH_SHORT).show()
showMessage("Order", "You didn't order anything.")
}
} else {
Toast.makeText(activity, "Please enter your name.", Toast.LENGTH_SHORT).show()
showMessage("Order", "Please enter your name.")
}
}

Expand All @@ -132,6 +133,15 @@ class CheckoutFragment : Fragment() {
checkoutViewModel.refresh()
}

private fun showMessage(title: String, message: String) {
val builder = AlertDialog.Builder(activity)
builder.setTitle(title)
builder.setMessage(message)
builder.setPositiveButton(android.R.string.yes) { dialog, which ->
}
builder.show()
}

private fun observeViewModel() {
checkoutViewModel.items.observe(viewLifecycleOwner, Observer { items ->
items?.let {
Expand Down

0 comments on commit 86469fc

Please sign in to comment.