mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Improve UI, fix some bug
This commit is contained in:
@@ -4,6 +4,7 @@ import com.capstone.foodify.Model.Category;
|
||||
import com.capstone.foodify.Model.Comment;
|
||||
import com.capstone.foodify.Model.DistrictWardResponse;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.Model.Response.Categories;
|
||||
import com.capstone.foodify.Model.Response.Comments;
|
||||
import com.capstone.foodify.Model.Response.CustomResponse;
|
||||
import com.capstone.foodify.Model.Response.Foods;
|
||||
@@ -50,8 +51,8 @@ public interface FoodApi {
|
||||
@GET("products")
|
||||
Call<Foods> listFood(@Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
|
||||
@GET("categories")
|
||||
Call<List<Category>> listCategory();
|
||||
@GET("categories/randoms?pageNo=0&pageSize=7")
|
||||
Call<Categories> listCategory();
|
||||
|
||||
@GET("products/categories")
|
||||
Call<Foods> listFoodByCategory(@Query("id") List<Integer> id, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
|
||||
@@ -86,4 +87,7 @@ public interface FoodApi {
|
||||
|
||||
@GET("products/{productId}/users/{userId}")
|
||||
Call<Comment> getUserComment(@Path("productId") int productId, @Path("userId") int userId);
|
||||
|
||||
@GET("shops/{id}")
|
||||
Call<Shop> getShopById(@Path("id") int id);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.capstone.foodify.Activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.Dialog;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Color;
|
||||
@@ -49,6 +50,10 @@ import com.mcdev.quantitizerlibrary.QuantitizerListener;
|
||||
import com.sjapps.library.customdialog.BasicDialog;
|
||||
import com.sjapps.library.customdialog.DialogButtonEvent;
|
||||
import com.sjapps.library.customdialog.DialogButtonEvents;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogAnimation;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
import com.willy.ratingbar.RotationRatingBar;
|
||||
import com.willy.ratingbar.ScaleRatingBar;
|
||||
|
||||
@@ -303,44 +308,61 @@ public class FoodDetailActivity extends AppCompatActivity {
|
||||
|
||||
private void addFoodToBasket(){
|
||||
if(horizontalQuantitizer.getValue() > 0){
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if(foodInBasket == null){
|
||||
//If item is not exist in basket
|
||||
if(Common.FINAL_SHOP == null && Common.LIST_BASKET_FOOD.size() == 0){
|
||||
Common.FINAL_SHOP = food.getShop().getName();
|
||||
}
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if(food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
String.valueOf(horizontalQuantitizer.getValue()), food.getDiscountPercent()));
|
||||
if(Common.FINAL_SHOP.equals(food.getShop().getName())){
|
||||
addFood();
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for(int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++){
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if(foodId.equals(food.getId())){
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + horizontalQuantitizer.getValue();
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new AestheticDialog.Builder(this, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Bạn chỉ có thể đặt những món ăn cùng cửa hàng, xin vui lòng kiểm tra lại giỏ hàng!")
|
||||
.setAnimation(DialogAnimation.SHRINK)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
Toast.makeText(FoodDetailActivity.this, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
onBackPressed();
|
||||
finish();
|
||||
|
||||
} else {
|
||||
Toast.makeText(FoodDetailActivity.this, "Bạn chưa chọn số lượng đồ ăn cần đặt!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
private void addFood() {
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if(foodInBasket == null){
|
||||
//If item is not exist in basket
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if(food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
String.valueOf(horizontalQuantitizer.getValue()), food.getDiscountPercent(), food.getShop().getId()));
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for(int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++){
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if(foodId.equals(food.getId())){
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + horizontalQuantitizer.getValue();
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Toast.makeText(FoodDetailActivity.this, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
onBackPressed();
|
||||
finish();
|
||||
}
|
||||
|
||||
private void getCommentUser(){
|
||||
FoodApi.apiService.getUserComment(Integer.parseInt(foodId), Common.CURRENT_USER.getId()).enqueue(new Callback<Comment>() {
|
||||
@Override
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.capstone.foodify.Activity;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.graphics.Typeface;
|
||||
@@ -40,6 +41,7 @@ import com.capstone.foodify.Model.GoogleMap.GoogleMapResponse;
|
||||
import com.capstone.foodify.Model.GoogleMap.Location;
|
||||
import com.capstone.foodify.Model.Order;
|
||||
import com.capstone.foodify.Model.OrderDetail;
|
||||
import com.capstone.foodify.Model.Shop;
|
||||
import com.capstone.foodify.R;
|
||||
import com.capstone.foodify.ZaloPay.Api.CreateOrder;
|
||||
import com.capstone.foodify.ZaloPay.Helper.Helpers;
|
||||
@@ -47,6 +49,7 @@ import com.google.android.gms.maps.model.LatLng;
|
||||
import com.google.android.material.textfield.TextInputLayout;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogAnimation;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
import com.thecode.aestheticdialogs.OnDialogClickListener;
|
||||
@@ -71,9 +74,9 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
private static final String TAKE_FOOD_FROM_SHOP = "Đến shop lấy";
|
||||
private static final String ZALO_PAYMENT_METHOD = "ZALO PAY";
|
||||
private static final String CASH_PAYMENT = "CASH";
|
||||
private static final Double LAT_SHOP = 16.0500622;
|
||||
private static final Double LNG_SHOP = 108.2351611;
|
||||
private static String finalAddress = null;
|
||||
private static Double LAT_SHOP = 0.0;
|
||||
private static Double LNG_SHOP = 0.0;
|
||||
private static String finalAddress, tempAddress = null;
|
||||
private static double finalLat, finalLng = 0;
|
||||
ImageView back_image;
|
||||
OrderDetailAdapter adapter;
|
||||
@@ -91,17 +94,7 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
private static final ArrayList<String> wardList = new ArrayList<>();
|
||||
private static final ArrayList<String> districtList = new ArrayList<>();
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_order_check_out);
|
||||
|
||||
//Check user is login or not!
|
||||
if(Common.CURRENT_USER == null)
|
||||
startActivity(new Intent(this, SignInActivity.class));
|
||||
|
||||
|
||||
//Init Component
|
||||
private void initComponent(){
|
||||
txt_userName = findViewById(R.id.txt_userName);
|
||||
txt_phone = findViewById(R.id.txt_phone);
|
||||
spn_list_address = findViewById(R.id.list_address);
|
||||
@@ -128,6 +121,22 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
txt_ship_cost = findViewById(R.id.txt_ship_cost);
|
||||
btn_ZaloPay = findViewById(R.id.btnZaloPay);
|
||||
btn_Pay = findViewById(R.id.btnPay);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
setContentView(R.layout.activity_order_check_out);
|
||||
|
||||
//Check user is login or not!
|
||||
if(Common.CURRENT_USER == null)
|
||||
startActivity(new Intent(this, SignInActivity.class));
|
||||
|
||||
|
||||
|
||||
|
||||
//Init Component
|
||||
initComponent();
|
||||
|
||||
//Reload user data
|
||||
Common.reloadUser(this);
|
||||
@@ -138,6 +147,8 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
txt_total.setText(Common.changeCurrencyUnit(total));
|
||||
}
|
||||
|
||||
getLocationShop();
|
||||
|
||||
StrictMode.ThreadPolicy policy = new
|
||||
StrictMode.ThreadPolicy.Builder().permitAll().build();
|
||||
StrictMode.setThreadPolicy(policy);
|
||||
@@ -161,10 +172,15 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
txt_userName.setText(Common.CURRENT_USER.getFullName());
|
||||
txt_phone.setText(Common.CURRENT_USER.getPhoneNumber());
|
||||
|
||||
|
||||
|
||||
//Set event for change address button
|
||||
change_address_button.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View v) {
|
||||
|
||||
finalAddress = null;
|
||||
|
||||
confirm_address_button.setEnabled(true);
|
||||
change_address_button.setVisibility(View.GONE);
|
||||
|
||||
@@ -187,7 +203,10 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
if(radio_button_selected == auto_detect_location){
|
||||
//Action 2
|
||||
|
||||
if(tempAddress == null)
|
||||
auto_detect_location.setText("Không thể lấy được vị trí! Vui lòng thử lại sau");
|
||||
else
|
||||
finalAddress = tempAddress;
|
||||
}
|
||||
|
||||
if(radio_button_selected == manual_input_address){
|
||||
@@ -207,7 +226,7 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
if(finalAddress == null){
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Bạn chưa chọn địa chỉ!", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Bạn chưa xác nhận địa chỉ!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
progress_layout.setVisibility(View.VISIBLE);
|
||||
confirm_address_button.setEnabled(false);
|
||||
@@ -215,7 +234,22 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
disableAllInputAddressOption();
|
||||
|
||||
getDistanceAndCalculateShipCost(finalAddress);
|
||||
if(radio_button_selected != take_food_from_shop){
|
||||
|
||||
if(LAT_SHOP != 0.0 && LNG_SHOP != 0.0)
|
||||
getDistanceAndCalculateShipCost(finalAddress);
|
||||
else {
|
||||
new AestheticDialog.Builder(OrderCheckOutActivity.this, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Chưa thể lấy được vị trí shop, vui lòng thử lại hoặc có thể chọn \"Đến shop lấy\" để tiếp tục!")
|
||||
.setAnimation(DialogAnimation.SHRINK)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -254,26 +288,36 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
}
|
||||
|
||||
private void getAddress() {
|
||||
GoogleMapApi.apiService.getAddress(Common.CURRENT_LOCATION.getLatitude() + "," + Common.CURRENT_LOCATION.getLongitude(), Common.MAP_API).enqueue(new Callback<GoogleMapResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<GoogleMapResponse> call, Response<GoogleMapResponse> response) {
|
||||
if(response.code() == 200){
|
||||
GoogleMapResponse responseData = response.body();
|
||||
|
||||
String address = responseData.getResults().get(0).getFormattedAddress();
|
||||
if(Common.tempCurrentAddressUser == null){
|
||||
GoogleMapApi.apiService.getAddress(Common.CURRENT_LOCATION.getLatitude() + "," + Common.CURRENT_LOCATION.getLongitude(), Common.MAP_API).enqueue(new Callback<GoogleMapResponse>() {
|
||||
@Override
|
||||
public void onResponse(Call<GoogleMapResponse> call, Response<GoogleMapResponse> response) {
|
||||
if(response.code() == 200){
|
||||
GoogleMapResponse responseData = response.body();
|
||||
|
||||
edt_address_detect.setText(address);
|
||||
String address = responseData.getResults().get(0).getFormattedAddress();
|
||||
|
||||
finalAddress = address;
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
Common.tempCurrentAddressUser = address;
|
||||
|
||||
edt_address_detect.setText(address);
|
||||
|
||||
tempAddress = address;
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<GoogleMapResponse> call, Throwable t) {
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Lỗi kết nối!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void onFailure(Call<GoogleMapResponse> call, Throwable t) {
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Lỗi kết nối!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
} else {
|
||||
edt_address_detect.setText(Common.tempCurrentAddressUser);
|
||||
|
||||
tempAddress = Common.tempCurrentAddressUser;
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -350,7 +394,7 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Bạn chưa chọn địa chỉ!", Toast.LENGTH_SHORT).show();
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Bạn chưa xác nhận địa chỉ!", Toast.LENGTH_SHORT).show();
|
||||
progress_layout.setVisibility(View.GONE);
|
||||
}
|
||||
|
||||
@@ -390,7 +434,7 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
@Override
|
||||
public void onClick(@NonNull AestheticDialog.Builder builder) {
|
||||
Common.LIST_BASKET_FOOD.clear();
|
||||
startActivity(new Intent(OrderCheckOutActivity.this, MainActivity.class));
|
||||
startActivity(new Intent(OrderCheckOutActivity.this, OrderActivity.class));
|
||||
builder.dismiss();
|
||||
finish();
|
||||
}
|
||||
@@ -458,6 +502,28 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
}
|
||||
|
||||
private void getLocationShop(){
|
||||
FoodApi.apiService.getShopById(Common.LIST_BASKET_FOOD.get(0).getShopId()).enqueue(new Callback<Shop>() {
|
||||
@Override
|
||||
public void onResponse(Call<Shop> call, Response<Shop> response) {
|
||||
if(response.code() == 200){
|
||||
Shop shopTemp = response.body();
|
||||
|
||||
LAT_SHOP = shopTemp.getLat();
|
||||
LNG_SHOP = shopTemp.getLng();
|
||||
} else {
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Lỗi hệ thống! Mã lỗi: " + response.code(), Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<Shop> call, Throwable t) {
|
||||
Toast.makeText(OrderCheckOutActivity.this, "Đã có lỗi kết nối đến hệ thống!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
public int CalculationByDistance(LatLng from, LatLng to) {
|
||||
int Radius = 6371;// radius of earth in Km
|
||||
double lat1 = from.latitude;
|
||||
@@ -543,9 +609,9 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
|
||||
private void enabledAllInputAddressOption(){
|
||||
list_address_input.setEnabled(true);
|
||||
auto_detect_location.setEnabled(true);
|
||||
manual_input_address.setEnabled(true);
|
||||
take_food_from_shop.setEnabled(true);
|
||||
auto_detect_location.setEnabled(true);
|
||||
|
||||
spn_list_address.setEnabled(true);
|
||||
edt_address.setEnabled(true);
|
||||
@@ -613,6 +679,11 @@ public class OrderCheckOutActivity extends AppCompatActivity {
|
||||
progress_layout.setVisibility(View.VISIBLE);
|
||||
if(Common.CURRENT_LOCATION != null)
|
||||
getAddress();
|
||||
else
|
||||
edt_address_detect.setText("Không thể lấy được vị trí do bạn chưa cấp quyền ứng dụng!");
|
||||
|
||||
//Reset address;
|
||||
finalAddress = null;
|
||||
}
|
||||
break;
|
||||
case R.id.manual_input_address:
|
||||
|
||||
@@ -40,7 +40,7 @@ import retrofit2.Response;
|
||||
|
||||
public class OrderDetailActivity extends AppCompatActivity {
|
||||
private static final String AWAITING = "AWAITING";
|
||||
private TextView order_tracking_number, user_name, phone, address, orderTime, total;
|
||||
private TextView order_tracking_number, user_name, phone, address, orderTime, total, status;
|
||||
private ImageView back_image;
|
||||
private List<Basket> listOrderDetails = new ArrayList<>();
|
||||
OrderDetailAdapter adapter;
|
||||
@@ -70,11 +70,13 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
address.setText("Địa chỉ: " + order.getAddress());
|
||||
orderTime.setText("Thời gian đặt: " + order.getOrderTime());
|
||||
total.setText("Tổng: " + Common.changeCurrencyUnit(order.getTotal()));
|
||||
status.setText("Trạng thái đơn hàng: " + translateStatus(order.getStatus()));
|
||||
|
||||
|
||||
for(OrderDetail tempFood: order.getOrderDetails()){
|
||||
Basket food = new Basket(tempFood.getFood().getId(), tempFood.getFood().getImages().get(0).getImageUrl(),
|
||||
tempFood.getFood().getName(), tempFood.getFood().getCost() ,tempFood.getFood().getShop().getName(), tempFood.getQuantity(),
|
||||
tempFood.getFood().getDiscountPercent());
|
||||
tempFood.getFood().getDiscountPercent(), tempFood.getFood().getShop().getId());
|
||||
listOrderDetails.add(food);
|
||||
}
|
||||
|
||||
@@ -170,5 +172,32 @@ public class OrderDetailActivity extends AppCompatActivity {
|
||||
recyclerView = findViewById(R.id.recycler_view_order_detail);
|
||||
back_image = findViewById(R.id.back_image);
|
||||
btn_cancel_order = findViewById(R.id.cancel_order_button);
|
||||
status = findViewById(R.id.status);
|
||||
}
|
||||
|
||||
private String translateStatus(String status){
|
||||
String statusHasTranslate = null;
|
||||
|
||||
if(status.equals("AWAITING")){
|
||||
statusHasTranslate = "Chờ xác nhận";
|
||||
}
|
||||
|
||||
if(status.equals("CONFIRMED")){
|
||||
statusHasTranslate = "Đã xác nhận";
|
||||
}
|
||||
|
||||
if(status.equals("SHIPPING")){
|
||||
statusHasTranslate = "Đang giao";
|
||||
}
|
||||
|
||||
if(status.equals("COMPLETED")){
|
||||
statusHasTranslate = "Đã giao";
|
||||
}
|
||||
|
||||
if(status.equals("CANCELED")){
|
||||
statusHasTranslate = "Đã huỷ";
|
||||
}
|
||||
|
||||
return statusHasTranslate;
|
||||
}
|
||||
}
|
||||
@@ -173,6 +173,7 @@ public class BasketAdapter extends RecyclerView.Adapter<BasketAdapter.BasketView
|
||||
|
||||
//Show notification empty basket
|
||||
if(listBasketFood.size() == 0){
|
||||
Common.FINAL_SHOP = null;
|
||||
hideRecyclerViewAndShowNotificationEmpty();
|
||||
} else {
|
||||
showRecycleViewAndHideNotificationEmpty();
|
||||
@@ -186,6 +187,7 @@ public class BasketAdapter extends RecyclerView.Adapter<BasketAdapter.BasketView
|
||||
|
||||
////Show notification empty basket
|
||||
if(listBasketFood.size() == 0){
|
||||
Common.FINAL_SHOP = null;
|
||||
hideRecyclerViewAndShowNotificationEmpty();
|
||||
} else {
|
||||
showRecycleViewAndHideNotificationEmpty();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.capstone.foodify.Adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -18,6 +19,10 @@ import com.capstone.foodify.Model.Basket;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.R;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogAnimation;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,11 +30,13 @@ public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.FoodViewHolder
|
||||
|
||||
private List<Food> listFood;
|
||||
private Context context;
|
||||
private Activity activity;
|
||||
|
||||
public FoodAdapter(Context context){
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
|
||||
public FoodAdapter() {}
|
||||
public void setData(List<Food> list) {
|
||||
this.listFood = list;
|
||||
@@ -67,7 +74,7 @@ public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.FoodViewHolder
|
||||
}
|
||||
|
||||
//Check value discountPercent
|
||||
float cost = 0;
|
||||
float cost;
|
||||
if(food.getDiscountPercent() > 0){
|
||||
|
||||
//Calculate final cost when apply discountPercent
|
||||
@@ -85,36 +92,21 @@ public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.FoodViewHolder
|
||||
holder.basket_icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if(foodInBasket == null){
|
||||
//If item is not exist in basket
|
||||
if(Common.FINAL_SHOP == null && Common.LIST_BASKET_FOOD.size() == 0){
|
||||
Common.FINAL_SHOP = food.getShop().getName();
|
||||
}
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if(food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
"1", food.getDiscountPercent()));
|
||||
if(Common.FINAL_SHOP.equals(food.getShop().getName())){
|
||||
Common.addFoodToBasket(food);
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for(int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++){
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if(foodId.equals(food.getId())){
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + 1;
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new AestheticDialog.Builder((Activity) context, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Bạn chỉ có thể đặt những món ăn cùng cửa hàng, xin vui lòng kiểm tra lại giỏ hàng!")
|
||||
.setAnimation(DialogAnimation.SHRINK)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@@ -125,7 +117,6 @@ public class FoodAdapter extends RecyclerView.Adapter<FoodAdapter.FoodViewHolder
|
||||
context.startActivity(intent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.capstone.foodify.Adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -20,6 +21,10 @@ import com.capstone.foodify.Model.Basket;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.R;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogAnimation;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -82,36 +87,21 @@ public class FoodFavoriteAdapter extends RecyclerView.Adapter<FoodFavoriteAdapt
|
||||
holder.basket_icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if(foodInBasket == null){
|
||||
//If item is not exist in basket
|
||||
if(Common.FINAL_SHOP == null && Common.LIST_BASKET_FOOD.size() == 0){
|
||||
Common.FINAL_SHOP = food.getShop().getName();
|
||||
}
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if(food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
"1", food.getDiscountPercent()));
|
||||
if(Common.FINAL_SHOP.equals(food.getShop().getName())){
|
||||
Common.addFoodToBasket(food);
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for(int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++){
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if(foodId.equals(food.getId())){
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + 1;
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new AestheticDialog.Builder((Activity) context, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Bạn chỉ có thể đặt những món ăn cùng cửa hàng, xin vui lòng kiểm tra lại giỏ hàng!")
|
||||
.setAnimation(DialogAnimation.SHRINK)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.capstone.foodify.Adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -14,10 +15,13 @@ import androidx.recyclerview.widget.RecyclerView;
|
||||
|
||||
import com.capstone.foodify.Activity.FoodDetailActivity;
|
||||
import com.capstone.foodify.Common;
|
||||
import com.capstone.foodify.Model.Basket;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.R;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogAnimation;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -99,36 +103,21 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
|
||||
holder.basket_icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if(foodInBasket == null){
|
||||
//If item is not exist in basket
|
||||
if(Common.FINAL_SHOP == null && Common.LIST_BASKET_FOOD.size() == 0){
|
||||
Common.FINAL_SHOP = food.getShop().getName();
|
||||
}
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if(food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
"1", food.getDiscountPercent()));
|
||||
if(Common.FINAL_SHOP.equals(food.getShop().getName())){
|
||||
Common.addFoodToBasket(food);
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for(int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++){
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if(foodId.equals(food.getId())){
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + 1;
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new AestheticDialog.Builder((Activity) context, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Bạn chỉ có thể đặt những món ăn cùng cửa hàng, xin vui lòng kiểm tra lại giỏ hàng!")
|
||||
.setAnimation(DialogAnimation.SHRINK)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
|
||||
@@ -150,7 +139,6 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
public static class FoodViewHolder extends RecyclerView.ViewHolder{
|
||||
|
||||
private final ImageView image, basket_icon;
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.capstone.foodify.Adapter;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.view.LayoutInflater;
|
||||
@@ -18,6 +19,10 @@ import com.capstone.foodify.Model.Basket;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.R;
|
||||
import com.squareup.picasso.Picasso;
|
||||
import com.thecode.aestheticdialogs.AestheticDialog;
|
||||
import com.thecode.aestheticdialogs.DialogAnimation;
|
||||
import com.thecode.aestheticdialogs.DialogStyle;
|
||||
import com.thecode.aestheticdialogs.DialogType;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -25,6 +30,7 @@ public class FoodShopAdapter extends RecyclerView.Adapter<FoodShopAdapter.FoodSh
|
||||
|
||||
private List<Food> listFoodShop;
|
||||
private Context context;
|
||||
private static final int MAX_CHARACTER = 35;
|
||||
|
||||
public FoodShopAdapter(Context context) {
|
||||
this.context = context;
|
||||
@@ -53,11 +59,42 @@ public class FoodShopAdapter extends RecyclerView.Adapter<FoodShopAdapter.FoodSh
|
||||
} else {
|
||||
Picasso.get().load(food.getImages().get(0).getImageUrl()).into(holder.imageView);
|
||||
}
|
||||
|
||||
holder.foodName.setText(food.getName());
|
||||
holder.quantitySoldOut.setText("1.2k đã bán");
|
||||
holder.price.setText(Common.changeCurrencyUnit(food.getCost()));
|
||||
|
||||
String foodName = food.getName();
|
||||
if(foodName.length() >= MAX_CHARACTER){
|
||||
StringBuilder stringBuilder = new StringBuilder(food.getName());
|
||||
stringBuilder.replace(MAX_CHARACTER, food.getName().length(), "..." );
|
||||
holder.foodName.setText(stringBuilder);
|
||||
} else {
|
||||
holder.foodName.setText(foodName);
|
||||
}
|
||||
|
||||
String description = food.getDescription();
|
||||
if(description.length() >= MAX_CHARACTER){
|
||||
StringBuilder stringBuilder = new StringBuilder(food.getDescription());
|
||||
stringBuilder.replace(MAX_CHARACTER, food.getDescription().length(), "..." );
|
||||
holder.description.setText(stringBuilder);
|
||||
} else {
|
||||
holder.description.setText(description);
|
||||
}
|
||||
|
||||
//Check value discountPercent
|
||||
float cost;
|
||||
if(food.getDiscountPercent() > 0){
|
||||
|
||||
//Calculate final cost when apply discountPercent
|
||||
cost = food.getCost() - (food.getCost() * food.getDiscountPercent()/100);
|
||||
|
||||
//Show discountPercent value on screen
|
||||
holder.discount.setVisibility(View.VISIBLE);
|
||||
holder.discount.setText("-" + food.getDiscountPercent()+ "%");
|
||||
} else {
|
||||
cost = food.getCost();
|
||||
}
|
||||
|
||||
holder.price.setText(Common.changeCurrencyUnit(cost));
|
||||
|
||||
holder.itemView.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
@@ -71,36 +108,21 @@ public class FoodShopAdapter extends RecyclerView.Adapter<FoodShopAdapter.FoodSh
|
||||
holder.basket_icon.setOnClickListener(new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if(foodInBasket == null){
|
||||
//If item is not exist in basket
|
||||
if(Common.FINAL_SHOP == null && Common.LIST_BASKET_FOOD.size() == 0){
|
||||
Common.FINAL_SHOP = food.getShop().getName();
|
||||
}
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if(food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
"1", food.getDiscountPercent()));
|
||||
if(Common.FINAL_SHOP.equals(food.getShop().getName())){
|
||||
Common.addFoodToBasket(food);
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for(int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++){
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if(foodId.equals(food.getId())){
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + 1;
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
new AestheticDialog.Builder((Activity) context, DialogStyle.FLAT, DialogType.INFO)
|
||||
.setTitle("Thông báo!")
|
||||
.setMessage("Bạn chỉ có thể đặt những món ăn cùng cửa hàng, xin vui lòng kiểm tra lại giỏ hàng!")
|
||||
.setAnimation(DialogAnimation.SHRINK)
|
||||
.setCancelable(true)
|
||||
.show();
|
||||
}
|
||||
Toast.makeText(context, "Đã thêm " + food.getName() + " vào giỏ hàng!", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -115,7 +137,7 @@ public class FoodShopAdapter extends RecyclerView.Adapter<FoodShopAdapter.FoodSh
|
||||
public class FoodShopViewHolder extends RecyclerView.ViewHolder {
|
||||
|
||||
ImageView imageView, basket_icon;
|
||||
TextView foodName, quantitySoldOut, price;
|
||||
TextView foodName, description, price, discount;
|
||||
|
||||
|
||||
public FoodShopViewHolder(@NonNull View itemView) {
|
||||
@@ -123,9 +145,10 @@ public class FoodShopAdapter extends RecyclerView.Adapter<FoodShopAdapter.FoodSh
|
||||
|
||||
imageView = itemView.findViewById(R.id.image_view);
|
||||
foodName = itemView.findViewById(R.id.food_name_text_view);
|
||||
quantitySoldOut = itemView.findViewById(R.id.quantity_sold_out);
|
||||
description = itemView.findViewById(R.id.description);
|
||||
price = itemView.findViewById(R.id.price_text_view);
|
||||
basket_icon = itemView.findViewById(R.id.basket_icon);
|
||||
discount = itemView.findViewById(R.id.discount);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,6 +21,7 @@ import com.capstone.foodify.Activity.MainActivity;
|
||||
import com.capstone.foodify.Activity.SignInActivity;
|
||||
import com.capstone.foodify.Fragment.HomeFragment;
|
||||
import com.capstone.foodify.Model.Basket;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.Model.User;
|
||||
import com.google.firebase.auth.FirebaseAuth;
|
||||
import com.google.firebase.auth.FirebaseUser;
|
||||
@@ -48,8 +49,10 @@ public class Common {
|
||||
public static final String PASSWORD_PATTERN = "^(?=.*[0-9])(?=.*[A-Z])(?=.*[@#$%^&+=!_])(?=\\S+$).{4,}$";
|
||||
public static final String PHONE_PATTERN = "^0[98753]{1}\\d{8}$";
|
||||
public static List<Basket> LIST_BASKET_FOOD = new ArrayList<>();
|
||||
public static String tempCurrentAddressUser = null;
|
||||
public static String TOKEN = null;
|
||||
public static User CURRENT_USER = null;
|
||||
public static String FINAL_SHOP = null;
|
||||
|
||||
public static String changeCurrencyUnit(float price){
|
||||
Locale locale = new Locale("vi", "VN");
|
||||
@@ -163,4 +166,36 @@ public class Common {
|
||||
public static Basket getFoodExistInBasket(String foodId) {
|
||||
return Common.LIST_BASKET_FOOD.stream().filter(food -> foodId.equals(food.getId())).findFirst().orElse(null);
|
||||
}
|
||||
|
||||
public static void addFoodToBasket(Food food) {
|
||||
Basket foodInBasket = Common.getFoodExistInBasket(food.getId());
|
||||
if (foodInBasket == null) {
|
||||
//If item is not exist in basket
|
||||
|
||||
//Check food image is null or not
|
||||
String imageTemp = null;
|
||||
if (food.getImages().size() > 0)
|
||||
imageTemp = food.getImages().get(0).getImageUrl();
|
||||
|
||||
Common.LIST_BASKET_FOOD.add(new Basket(food.getId(), imageTemp, food.getName(), food.getCost(), food.getShop().getName(),
|
||||
"1", food.getDiscountPercent(), food.getShop().getId()));
|
||||
} else {
|
||||
//If item is exist in basket
|
||||
|
||||
for (int i = 0; i < Common.LIST_BASKET_FOOD.size(); i++) {
|
||||
String foodId = Common.LIST_BASKET_FOOD.get(i).getId();
|
||||
//Find foodId exist
|
||||
if (foodId.equals(food.getId())) {
|
||||
//Get quantity food from basket
|
||||
String quantity = Common.LIST_BASKET_FOOD.get(i).getQuantity();
|
||||
|
||||
//Change quantity food from basket
|
||||
int quantityInt = Integer.parseInt(quantity) + 1;
|
||||
Common.LIST_BASKET_FOOD.get(i).setQuantity(String.valueOf(quantityInt));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,12 +60,12 @@ public class BasketFragment extends Fragment implements ItemTouchHelperListener
|
||||
//Init data
|
||||
total.setText(Common.changeCurrencyUnit(0));
|
||||
|
||||
//Get list food in basket
|
||||
getListBasketFood();
|
||||
|
||||
//Check list basket is null or not!
|
||||
checkListBasket();
|
||||
|
||||
//Get list food in basket
|
||||
getListBasketFood();
|
||||
|
||||
//Set layout recyclerview
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||
recyclerView_basket_food.setLayoutManager(linearLayoutManager);
|
||||
@@ -129,8 +129,8 @@ public class BasketFragment extends Fragment implements ItemTouchHelperListener
|
||||
adapter.removeItem(indexDelete, getContext());
|
||||
|
||||
//Show notification food has been delete
|
||||
Snackbar snackbar = Snackbar.make(listBasketFoodView, foodNameDelete + " remove!", Snackbar.LENGTH_LONG);
|
||||
snackbar.setAction("Undo", new View.OnClickListener() {
|
||||
Snackbar snackbar = Snackbar.make(listBasketFoodView, foodNameDelete + " đã xoá!", Snackbar.LENGTH_LONG);
|
||||
snackbar.setAction("Hoàn tác", new View.OnClickListener() {
|
||||
@Override
|
||||
public void onClick(View view) {
|
||||
adapter.undoItem(foodDelete, indexDelete, getContext());
|
||||
|
||||
@@ -34,8 +34,8 @@ public class CancelOrderFragment extends Fragment {
|
||||
private static final String STATUS = "CANCELED";
|
||||
private static int CURRENT_PAGE = 0;
|
||||
private static final int PAGE_SIZE = 8;
|
||||
private static final String SORT_BY = "id";
|
||||
private static final String SORT_DIR = "asc";
|
||||
private static final String SORT_BY = "orderTime";
|
||||
private static final String SORT_DIR = "desc";
|
||||
private static boolean LAST_PAGE;
|
||||
private List<Order> listOrders = new ArrayList<>();
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@@ -35,8 +35,8 @@ public class CompleteOrderFragment extends Fragment {
|
||||
private static final String STATUS = "COMPLETED";
|
||||
private static int CURRENT_PAGE = 0;
|
||||
private static final int PAGE_SIZE = 8;
|
||||
private static final String SORT_BY = "id";
|
||||
private static final String SORT_DIR = "asc";
|
||||
private static final String SORT_BY = "orderTime";
|
||||
private static final String SORT_DIR = "desc";
|
||||
private static boolean LAST_PAGE;
|
||||
private List<Order> listOrders = new ArrayList<>();
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@@ -34,8 +34,8 @@ public class PreparingFragment extends Fragment {
|
||||
private static final String STATUS = "CONFIRMED";
|
||||
private static int CURRENT_PAGE = 0;
|
||||
private static final int PAGE_SIZE = 8;
|
||||
private static final String SORT_BY = "id";
|
||||
private static final String SORT_DIR = "asc";
|
||||
private static final String SORT_BY = "orderTime";
|
||||
private static final String SORT_DIR = "desc";
|
||||
private static boolean LAST_PAGE;
|
||||
private List<Order> listOrders = new ArrayList<>();
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@@ -34,8 +34,8 @@ public class ProcessOderFragment extends Fragment {
|
||||
private static final String STATUS = "AWAITING";
|
||||
private static int CURRENT_PAGE = 0;
|
||||
private static final int PAGE_SIZE = 8;
|
||||
private static final String SORT_BY = "id";
|
||||
private static final String SORT_DIR = "asc";
|
||||
private static final String SORT_BY = "orderTime";
|
||||
private static final String SORT_DIR = "desc";
|
||||
private static boolean LAST_PAGE;
|
||||
private List<Order> listOrders = new ArrayList<>();
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@@ -35,8 +35,8 @@ public class ShipOrderFragment extends Fragment {
|
||||
private static final String STATUS = "SHIPPING";
|
||||
private static int CURRENT_PAGE = 0;
|
||||
private static final int PAGE_SIZE = 8;
|
||||
private static final String SORT_BY = "id";
|
||||
private static final String SORT_DIR = "asc";
|
||||
private static final String SORT_BY = "orderTime";
|
||||
private static final String SORT_DIR = "desc";
|
||||
private static boolean LAST_PAGE;
|
||||
private List<Order> listOrders = new ArrayList<>();
|
||||
RecyclerView recyclerView;
|
||||
|
||||
@@ -22,6 +22,7 @@ import com.capstone.foodify.Common;
|
||||
import com.capstone.foodify.Model.Category;
|
||||
import com.capstone.foodify.Model.Food;
|
||||
import com.capstone.foodify.Adapter.FoodSearchAdapter;
|
||||
import com.capstone.foodify.Model.Response.Categories;
|
||||
import com.capstone.foodify.Model.Response.Foods;
|
||||
import com.capstone.foodify.R;
|
||||
import com.google.android.material.chip.Chip;
|
||||
@@ -188,13 +189,12 @@ public class SearchFragment extends Fragment {
|
||||
private void getListCategory() {
|
||||
LayoutInflater inflater = LayoutInflater.from(getContext());
|
||||
|
||||
FoodApi.apiService.listCategory().enqueue(new Callback<List<Category>>() {
|
||||
FoodApi.apiService.listCategory().enqueue(new Callback<Categories>() {
|
||||
@Override
|
||||
public void onResponse(Call<List<Category>> call, Response<List<Category>> response) {
|
||||
List<Category> categoriesData = response.body();
|
||||
public void onResponse(Call<Categories> call, Response<Categories> response) {
|
||||
|
||||
if(categoriesData != null){
|
||||
for(Category tempCategory: categoriesData){
|
||||
if(response.code() == 200){
|
||||
for(Category tempCategory: response.body().getCategories()){
|
||||
Chip chip = (Chip) inflater.inflate(R.layout.chip_item, null, false);
|
||||
chip.setText(tempCategory.getName());
|
||||
chip.setEnabled(true);
|
||||
@@ -235,7 +235,7 @@ public class SearchFragment extends Fragment {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFailure(Call<List<Category>> call, Throwable t) {
|
||||
public void onFailure(Call<Categories> call, Throwable t) {
|
||||
//Check internet connection
|
||||
Common.showNotificationError(getContext(), getActivity());
|
||||
}
|
||||
|
||||
@@ -8,8 +8,9 @@ public class Basket {
|
||||
private String shopName;
|
||||
private String quantity;
|
||||
private float discountPercent;
|
||||
private int shopId;
|
||||
|
||||
public Basket(String id, String img, String name, float cost, String shopName, String quantity, float discountPercent) {
|
||||
public Basket(String id, String img, String name, float cost, String shopName, String quantity, float discountPercent, int shopId) {
|
||||
this.id = id;
|
||||
this.img = img;
|
||||
this.name = name;
|
||||
@@ -17,6 +18,7 @@ public class Basket {
|
||||
this.shopName = shopName;
|
||||
this.quantity = quantity;
|
||||
this.discountPercent = discountPercent;
|
||||
this.shopId = shopId;
|
||||
}
|
||||
|
||||
public String getId() {
|
||||
@@ -73,4 +75,12 @@ public class Basket {
|
||||
public void setDiscountPercent(float discountPercent) {
|
||||
this.discountPercent = discountPercent;
|
||||
}
|
||||
|
||||
public int getShopId() {
|
||||
return shopId;
|
||||
}
|
||||
|
||||
public void setShopId(int shopId) {
|
||||
this.shopId = shopId;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.capstone.foodify.Model.Response;
|
||||
|
||||
import com.capstone.foodify.Model.Category;
|
||||
import com.capstone.foodify.Model.Page;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Categories {
|
||||
private List<Category> categories;
|
||||
private Page page;
|
||||
|
||||
public List<Category> getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
public void setCategories(List<Category> categories) {
|
||||
this.categories = categories;
|
||||
}
|
||||
|
||||
public Page getPage() {
|
||||
return page;
|
||||
}
|
||||
|
||||
public void setPage(Page page) {
|
||||
this.page = page;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ public class Shop implements Serializable {
|
||||
private boolean isEnabled;
|
||||
private boolean isStudent;
|
||||
private int userId;
|
||||
private double lat;
|
||||
private double lng;
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
@@ -66,4 +68,20 @@ public class Shop implements Serializable {
|
||||
public void setUserId(int userId) {
|
||||
this.userId = userId;
|
||||
}
|
||||
|
||||
public double getLat() {
|
||||
return lat;
|
||||
}
|
||||
|
||||
public void setLat(double lat) {
|
||||
this.lat = lat;
|
||||
}
|
||||
|
||||
public double getLng() {
|
||||
return lng;
|
||||
}
|
||||
|
||||
public void setLng(double lng) {
|
||||
this.lng = lng;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,18 @@
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/status"
|
||||
android:text="Trạng thái đơn hàng: Đang giao"
|
||||
android:textSize="15sp"
|
||||
android:fontFamily="@font/opensans"
|
||||
android:textStyle="italic"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/order_time"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/total"
|
||||
android:text="Tổng đơn hàng: 1.200.000"
|
||||
@@ -109,7 +121,7 @@
|
||||
android:textStyle="bold"
|
||||
android:layout_width="wrap_content"
|
||||
android:layout_height="wrap_content"
|
||||
app:layout_constraintTop_toBottomOf="@id/order_time"
|
||||
app:layout_constraintTop_toBottomOf="@id/status"
|
||||
app:layout_constraintStart_toStartOf="parent"
|
||||
/>
|
||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||
|
||||
@@ -55,7 +55,9 @@
|
||||
android:src="@drawable/food"
|
||||
android:scaleType="centerCrop"
|
||||
app:riv_corner_radius="10dip"
|
||||
tools:ignore="ContentDescription" />
|
||||
tools:ignore="ContentDescription"
|
||||
android:layout_gravity="center_vertical"
|
||||
/>
|
||||
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
@@ -66,11 +68,11 @@
|
||||
<TextView
|
||||
android:id="@+id/food_name_text_view"
|
||||
android:text="@string/food_name"
|
||||
android:textSize="18sp"
|
||||
android:textSize="16sp"
|
||||
android:textColor="@color/black"
|
||||
android:fontFamily="@font/opensans"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="47dp"
|
||||
android:layout_height="45dp"
|
||||
android:layout_marginStart="5dp"
|
||||
android:layout_marginTop="5dp"
|
||||
android:layout_marginEnd="10dp"
|
||||
@@ -93,9 +95,9 @@
|
||||
>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/quantity_sold_out"
|
||||
android:text="1.2k đã bán"
|
||||
android:textSize="16sp"
|
||||
android:id="@+id/description"
|
||||
android:text="Descriptionssssssssssssssssssssssssssss"
|
||||
android:textSize="14sp"
|
||||
android:textColor="@color/gray"
|
||||
android:fontFamily="@font/opensans"
|
||||
android:layout_width="wrap_content"
|
||||
@@ -105,16 +107,32 @@
|
||||
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
||||
/>
|
||||
|
||||
<TextView
|
||||
android:id="@+id/price_text_view"
|
||||
android:text="$5.00"
|
||||
android:textSize="25sp"
|
||||
android:textColor="@color/primaryColor"
|
||||
android:fontFamily="@font/bebas"
|
||||
android:layout_width="220dp"
|
||||
<LinearLayout
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="wrap_content"
|
||||
android:layout_marginTop="2dp"
|
||||
/>
|
||||
>
|
||||
|
||||
<TextView
|
||||
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"
|
||||
/>
|
||||
|
||||
<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="visible"
|
||||
/>
|
||||
</LinearLayout>
|
||||
</LinearLayout>
|
||||
|
||||
<ImageView
|
||||
|
||||
Reference in New Issue
Block a user