Add comment and show detail order

This commit is contained in:
phanhuuloi27
2022-06-13 21:23:26 +07:00
parent 6f1439e375
commit f26cacbfa5
11 changed files with 420 additions and 38 deletions
@@ -9,6 +9,7 @@ import androidx.recyclerview.widget.RecyclerView;
import android.content.DialogInterface;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.EditText;
@@ -18,6 +19,7 @@ import android.widget.Toast;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.rengwuxian.materialedittext.MaterialEditText;
import com.waterbase.foodify.Common.Common;
import com.waterbase.foodify.Database.Database;
import com.waterbase.foodify.Model.Order;
@@ -85,19 +87,20 @@ public class Cart extends AppCompatActivity {
private void showAlertDialog() {
AlertDialog.Builder alertDialog = new AlertDialog.Builder(Cart.this);
alertDialog.setTitle("One more step!");
alertDialog.setMessage("Enter your address: ");
alertDialog.setTitle("Còn 1 bước nữa!");
alertDialog.setMessage("Xin vui lòng điền thông tin dưới đây: ");
final EditText edtAddress = new EditText(Cart.this);
LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
LinearLayout.LayoutParams.MATCH_PARENT,
LinearLayout.LayoutParams.MATCH_PARENT
);
edtAddress.setLayoutParams(lp);
alertDialog.setView(edtAddress); //Add edit text to Dialog
LayoutInflater inflater = this.getLayoutInflater();
View order_address_comment = inflater.inflate(R.layout.order_address_comment, null);
MaterialEditText edtAddress = (MaterialEditText) order_address_comment.findViewById(R.id.edtAddress);
MaterialEditText edtComment = (MaterialEditText) order_address_comment.findViewById(R.id.edtComment);
alertDialog.setView(order_address_comment);
alertDialog.setIcon(R.drawable.ic_baseline_shopping_cart_24);
alertDialog.setPositiveButton("YES", new DialogInterface.OnClickListener() {
alertDialog.setPositiveButton("Đặt", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
//Create new Request
@@ -106,6 +109,8 @@ public class Cart extends AppCompatActivity {
Common.currentUser.getName(),
edtAddress.getText().toString(),
txtTotalPrice.getText().toString(),
"0",
edtComment.getText().toString(),
cart
);
@@ -120,7 +125,7 @@ public class Cart extends AppCompatActivity {
}
});
alertDialog.setNegativeButton("NO", new DialogInterface.OnClickListener() {
alertDialog.setNegativeButton("Thoát", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
@@ -8,26 +8,20 @@ public class Request {
private String address;
private String total;
private String status;
private String comment;
private List<Order> foods; // list of food order
public Request() {
}
public Request(String phone, String name, String address, String total, List<Order> foods) {
public Request(String phone, String name, String address, String total, String status, String comment, List<Order> foods) {
this.phone = phone;
this.name = name;
this.address = address;
this.total = total;
this.foods = foods;
this.status = "0"; // Default is 0, 0: Placed, 1: Shipping, 2: Shipped
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
this.comment = comment;
this.foods = foods;
}
public String getPhone() {
@@ -62,6 +56,22 @@ public class Request {
this.total = total;
}
public String getStatus() {
return status;
}
public void setStatus(String status) {
this.status = status;
}
public String getComment() {
return comment;
}
public void setComment(String comment) {
this.comment = comment;
}
public List<Order> getFoods() {
return foods;
}
@@ -0,0 +1,52 @@
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:clickable="true"
app:cardElevation="4dp"
>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="16dp"
>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/edtAddress"
android:hint="Địa chỉ"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/colorPrimary"
android:text=""
android:textColor="@color/colorPrimary"
android:textSize="34sp"
android:inputType="text"
app:met_baseColor="@color/colorPrimary"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorPrimary"
app:met_singleLineEllipsis="true"
/>
<com.rengwuxian.materialedittext.MaterialEditText
android:id="@+id/edtComment"
android:hint="Ghi chú"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/colorPrimary"
android:text=""
android:textColor="@color/colorPrimary"
android:textSize="24sp"
android:inputType="textMultiLine"
app:met_baseColor="@color/colorPrimary"
app:met_floatingLabel="highlight"
app:met_primaryColor="@color/colorPrimary"
app:met_singleLineEllipsis="true"
/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>