This commit is contained in:
Nezumi
2023-03-31 22:23:32 +07:00
parent ddf47a03e0
commit 5f2a6a9e4d
21 changed files with 142 additions and 96 deletions
@@ -31,7 +31,7 @@ public interface FoodApi {
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create(); Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").setLenient().create();
FoodApi apiService = new Retrofit.Builder() FoodApi apiService = new Retrofit.Builder()
.baseUrl("https://foodify-backend-production.up.railway.app/api/").addConverterFactory(GsonConverterFactory.create(gson)) .baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
.build() .build()
.create(FoodApi.class); .create(FoodApi.class);
@@ -50,7 +50,7 @@ public interface FoodApiToken {
FoodApiToken apiService = new Retrofit.Builder() FoodApiToken apiService = new Retrofit.Builder()
.client(client) .client(client)
.baseUrl("https://foodify-backend-production.up.railway.app/api/").addConverterFactory(GsonConverterFactory.create(gson)) .baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
.build() .build()
.create(FoodApiToken.class); .create(FoodApiToken.class);
@@ -99,4 +99,7 @@ public interface FoodApiToken {
@DELETE("users/{userId}/orders/{orderId}") @DELETE("users/{userId}/orders/{orderId}")
Call<CustomResponse> deleteOrder(@Path("userId") int userId, @Path("orderId") int orderId); Call<CustomResponse> deleteOrder(@Path("userId") int userId, @Path("orderId") int orderId);
@PUT("users/{userId}/orders/{orderId}/status")
Call<CustomResponse> updateOrderStatus(@Path("userId") int userId, @Path("orderId") int orderId, @Query("status") String status);
} }
@@ -333,7 +333,8 @@ public class FoodDetailActivity extends AppCompatActivity {
} }
Toast.makeText(FoodDetailActivity.this, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show(); Toast.makeText(FoodDetailActivity.this, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
startActivity(new Intent(FoodDetailActivity.this, MainActivity.class)); onBackPressed();
finish();
} else { } else {
Toast.makeText(FoodDetailActivity.this, "Bạn chưa chọn số lượng đồ ăn cần đặt!", Toast.LENGTH_SHORT).show(); Toast.makeText(FoodDetailActivity.this, "Bạn chưa chọn số lượng đồ ăn cần đặt!", Toast.LENGTH_SHORT).show();
@@ -362,6 +362,8 @@ public class OrderCheckOutActivity extends AppCompatActivity {
} }
}); });
progress_layout.setVisibility(View.GONE);
} }
private void createOrderFood(String transactionId, String paymentMethod) { private void createOrderFood(String transactionId, String paymentMethod) {
@@ -127,13 +127,13 @@ public class OrderDetailActivity extends AppCompatActivity {
} }
private void deleteOrderUser(){ private void deleteOrderUser(){
FoodApiToken.apiService.deleteOrder(Common.CURRENT_USER.getId(), order.getId()).enqueue(new Callback<CustomResponse>() { FoodApiToken.apiService.updateOrderStatus(Common.CURRENT_USER.getId(), order.getId(), "CANCELED").enqueue(new Callback<CustomResponse>() {
@Override @Override
public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) { public void onResponse(Call<CustomResponse> call, Response<CustomResponse> response) {
if(response.code() == 200){ if(response.code() == 200){
new AestheticDialog.Builder(OrderDetailActivity.this, DialogStyle.RAINBOW, DialogType.SUCCESS) new AestheticDialog.Builder(OrderDetailActivity.this, DialogStyle.RAINBOW, DialogType.SUCCESS)
.setTitle("Thông báo!") .setTitle("Thông báo!")
.setMessage("Đã xoá đơn thành công!") .setMessage("Đã huỷ đơn thành công!")
.setCancelable(false) .setCancelable(false)
.setOnClickListener(new OnDialogClickListener() { .setOnClickListener(new OnDialogClickListener() {
@Override @Override
@@ -225,6 +225,7 @@ public class SignInActivity extends AppCompatActivity {
progressLayout.setVisibility(View.GONE); progressLayout.setVisibility(View.GONE);
startActivity(new Intent(SignInActivity.this, MainActivity.class)); startActivity(new Intent(SignInActivity.this, MainActivity.class));
finish();
} else { } else {
Toast.makeText(SignInActivity.this, "Tài khoản không hợp lệ! Vui lòng kiểm tra lại!", Toast.LENGTH_SHORT).show(); Toast.makeText(SignInActivity.this, "Tài khoản không hợp lệ! Vui lòng kiểm tra lại!", Toast.LENGTH_SHORT).show();
FirebaseAuth.getInstance().signOut(); FirebaseAuth.getInstance().signOut();
@@ -61,6 +61,17 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
holder.name.setText(foodName); holder.name.setText(foodName);
} }
String shopName = food.getShop().getName();
if(shopName.length() >= 18){
StringBuilder stringBuilder = new StringBuilder(food.getShop().getName());
stringBuilder.replace(18, food.getShop().getName().length(), "..." );
holder.shopName.setText(stringBuilder);
} else {
holder.shopName.setText(shopName);
}
//When food does not have image //When food does not have image
if(food.getImages().size() == 0){ if(food.getImages().size() == 0){
holder.image.setImageResource(R.drawable.default_image_food); holder.image.setImageResource(R.drawable.default_image_food);
@@ -143,7 +154,7 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
public static class FoodViewHolder extends RecyclerView.ViewHolder{ public static class FoodViewHolder extends RecyclerView.ViewHolder{
private final ImageView image, basket_icon; private final ImageView image, basket_icon;
private final TextView price, name, discount; private final TextView price, name, discount, shopName;
public FoodViewHolder(@NonNull View itemView) { public FoodViewHolder(@NonNull View itemView) {
super(itemView); super(itemView);
@@ -153,6 +164,7 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
price = itemView.findViewById(R.id.price_text_view); price = itemView.findViewById(R.id.price_text_view);
discount = itemView.findViewById(R.id.discount); discount = itemView.findViewById(R.id.discount);
basket_icon = itemView.findViewById(R.id.basket_icon); basket_icon = itemView.findViewById(R.id.basket_icon);
shopName = itemView.findViewById(R.id.shop_name_text_view);
} }
} }
} }
@@ -43,10 +43,30 @@ public class OrderDetailAdapter extends RecyclerView.Adapter<OrderDetailAdapter.
return; return;
Picasso.get().load(food.getImg()).into(holder.image_view); Picasso.get().load(food.getImg()).into(holder.image_view);
holder.food_name.setText(food.getName());
holder.shop_name.setText(food.getShopName()); holder.shop_name.setText(food.getShopName());
holder.quantity.setText("Số lượng: " + food.getQuantity()); holder.quantity.setText("Số lượng: " + food.getQuantity());
String foodName = food.getName();
if(foodName.length() >= 35){
StringBuilder stringBuilder = new StringBuilder(food.getName());
stringBuilder.replace(35, food.getName().length(), "..." );
holder.food_name.setText(stringBuilder);
} else {
holder.food_name.setText(foodName);
}
String shopName = food.getShopName();
if(shopName.length() >= 18){
StringBuilder stringBuilder = new StringBuilder(food.getShopName());
stringBuilder.replace(18, food.getShopName().length(), "..." );
holder.shop_name.setText(stringBuilder);
} else {
holder.shop_name.setText(shopName);
}
//Check value discountPercent //Check value discountPercent
float cost = 0; float cost = 0;
if(food.getDiscountPercent() > 0){ if(food.getDiscountPercent() > 0){
@@ -14,11 +14,10 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -27,7 +26,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="35dp"
android:fontFamily="@font/bebas" android:fontFamily="@font/bebas"
android:text="@string/account_and_profile" android:text="@string/account_and_profile"
android:textColor="@color/black" android:textColor="@color/black"
@@ -17,12 +17,10 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:background="@drawable/circle_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -14,11 +14,10 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -20,11 +20,12 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:layout_marginTop="15dp"
android:layout_marginStart="5dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -14,11 +14,12 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:layout_marginStart="5dp"
android:layout_marginTop="20dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
+5 -6
View File
@@ -11,19 +11,18 @@
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:orientation="horizontal"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginBottom="10dp" android:layout_marginBottom="10dp"
> >
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginEnd="20dp" app:layout_constraintStart_toStartOf="parent"
android:layout_gravity="center_vertical" app:layout_constraintTop_toTopOf="parent" />
/>
<TextView <TextView
android:id="@+id/textView" android:id="@+id/textView"
@@ -19,11 +19,12 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="20dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -14,14 +14,14 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:src="@drawable/back_button" android:padding="8dp"
android:layout_marginTop="10dp"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="20dp" android:src="@drawable/back_button"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent" />
/>
<androidx.cardview.widget.CardView <androidx.cardview.widget.CardView
android:layout_width="match_parent" android:layout_width="match_parent"
@@ -32,8 +32,8 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="28dp" android:layout_width="30dp"
android:layout_height="wrap_content" android:layout_height="30dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp" android:layout_marginStart="10dp"
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
+6 -5
View File
@@ -14,11 +14,12 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:layout_marginTop="10dp"
android:layout_marginStart="5dp"
android:padding="8dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -27,7 +28,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="35dp" android:layout_marginTop="45dp"
android:fontFamily="@font/bebas" android:fontFamily="@font/bebas"
android:text="@string/sign_in_text" android:text="@string/sign_in_text"
android:textColor="@color/black" android:textColor="@color/black"
+4 -4
View File
@@ -22,10 +22,10 @@
<ImageView <ImageView
android:id="@+id/back_image" android:id="@+id/back_image"
android:layout_width="20dp" android:layout_width="40dp"
android:layout_height="20dp" android:layout_height="40dp"
android:padding="8dp"
android:src="@drawable/back_button" android:src="@drawable/back_button"
android:layout_marginStart="10dp"
android:layout_marginTop="25dp" android:layout_marginTop="25dp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" /> app:layout_constraintTop_toTopOf="parent" />
@@ -35,7 +35,7 @@
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="30dp"
android:fontFamily="@font/bebas" android:fontFamily="@font/bebas"
android:text="@string/sign_up_text" android:text="@string/sign_up_text"
android:textColor="@color/black" android:textColor="@color/black"
+46 -38
View File
@@ -16,8 +16,8 @@
<ImageView <ImageView
android:id="@+id/image_view" android:id="@+id/image_view"
android:layout_width="110dp" android:layout_width="100dp"
android:layout_height="110dp" android:layout_height="100dp"
android:src="@drawable/food" android:src="@drawable/food"
android:scaleType="centerCrop" android:scaleType="centerCrop"
app:riv_corner_radius="10dip" app:riv_corner_radius="10dip"
@@ -25,7 +25,7 @@
<LinearLayout <LinearLayout
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="vertical" android:orientation="vertical"
android:layout_weight="1" android:layout_weight="1"
> >
@@ -33,60 +33,68 @@
<TextView <TextView
android:id="@+id/food_name_text_view" android:id="@+id/food_name_text_view"
android:text="Food Name" android:text="Food Name"
android:textSize="18sp" android:textSize="15sp"
android:textColor="@color/black" android:textColor="@color/black"
android:fontFamily="@font/opensans" android:fontFamily="@font/opensans"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="47dp" android:layout_height="0dp"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_weight="0.5"
android:layout_marginTop="5dp" android:layout_marginTop="5dp"
app:layout_constraintStart_toEndOf="@id/image_view" app:layout_constraintStart_toEndOf="@id/image_view"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
/> />
<TextView
android:id="@+id/shop_name_text_view"
android:text="Shop Name"
android:textSize="18sp"
android:textColor="@color/secondary"
android:fontFamily="@font/opensans"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
app:layout_constraintStart_toEndOf="@id/image_view"
app:layout_constraintTop_toBottomOf="@id/text_view_1"
/>
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="0dp"
android:layout_marginTop="2dp" android:layout_weight="0.5"
android:orientation="vertical"
> >
<TextView <TextView
android:id="@+id/price_text_view" android:id="@+id/shop_name_text_view"
android:text="$5.00" android:text="Shop Name"
android:textSize="25sp" android:textSize="15sp"
android:textColor="@color/primaryColor" android:textColor="@color/secondary"
android:fontFamily="@font/bebas" android:fontFamily="@font/opensans"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_marginStart="12dp" android:layout_marginStart="12dp"
android:layout_marginTop="2dp"
app:layout_constraintStart_toEndOf="@id/image_view"
app:layout_constraintTop_toBottomOf="@id/text_view_1"
/> />
<TextView <LinearLayout
android:id="@+id/discount" android:layout_width="match_parent"
android:text="-59%" android:layout_height="wrap_content"
android:textSize="8sp" android:layout_marginTop="2dp"
android:textColor="@color/red" >
android:layout_width="wrap_content"
android:layout_height="match_parent" <TextView
android:visibility="gone" android:id="@+id/price_text_view"
/> android:text="$5.00"
android:textSize="20sp"
android:textColor="@color/primaryColor"
android:fontFamily="@font/bebas"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
/>
<TextView
android:id="@+id/discount"
android:text="-59%"
android:textSize="7sp"
android:textColor="@color/red"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout> </LinearLayout>
</LinearLayout> </LinearLayout>
<LinearLayout <LinearLayout
@@ -63,7 +63,7 @@
<TextView <TextView
android:id="@+id/shop_name_text_view" android:id="@+id/shop_name_text_view"
android:text="Shop Name" android:text="Shop Name"
android:textSize="15sp" android:textSize="13sp"
android:textColor="@color/secondary" android:textColor="@color/secondary"
android:fontFamily="@font/opensans" android:fontFamily="@font/opensans"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@@ -106,7 +106,7 @@
android:text="Số lượng: 10" android:text="Số lượng: 10"
android:fontFamily="@font/opensans" android:fontFamily="@font/opensans"
android:textColor="@color/black" android:textColor="@color/black"
android:textSize="16sp" android:textSize="13sp"
android:layout_width="0dp" android:layout_width="0dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"