Merge API from back-end to Search Fragment

This commit is contained in:
Nezumi
2023-03-10 16:39:53 +07:00
parent 435d3f8fd2
commit 1553dbd55e
12 changed files with 249 additions and 58 deletions
@@ -26,7 +26,7 @@ public interface FoodApi {
Gson gson = new GsonBuilder().setDateFormat("HH:mm:ss dd-MM-yyyy").create();
FoodApi apiService = new Retrofit.Builder()
.baseUrl("http://10.0.2.2:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
.baseUrl("http://192.168.1.183:8080/api/").addConverterFactory(GsonConverterFactory.create(gson))
.build()
.create(FoodApi.class);
@@ -39,17 +39,17 @@ public interface FoodApi {
@GET("shops?pageNo=0&pageSize=10&sortBy=id&sortDir=asc")
Call<Shops> allShops();
@GET("products/search/")
Call<List<Food>> listFood(@Path("search") String search, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
@GET("products/search/{name}")
Call<Foods> searchFoodByName(@Path("name") String name, @Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
@GET("listFood")
Call<List<Food>> listFood(@Query("page") int page, @Query("limit") int limit);
@GET("products")
Call<Foods> listFood(@Query("pageNo") int pageNo, @Query("pageSize") int pageSize, @Query("sortBy") String sortBy, @Query("sortDir") String sortDir);
@GET("Category")
@GET("categories")
Call<List<Category>> listCategory();
@GET("Category/{id}/food")
Call<List<Food>> listFoodByCategory(@Path("id") String id);
@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);
@GET("detail/{id}")
Call<Food> detailFood(@Path("id") String id);
@@ -7,6 +7,7 @@ import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
@@ -25,10 +26,12 @@ import com.capstone.foodify.Common;
import com.capstone.foodify.Model.Category.Category;
import com.capstone.foodify.Model.Food.Food;
import com.capstone.foodify.Model.Food.FoodSearchAdapter;
import com.capstone.foodify.Model.Response.Foods;
import com.capstone.foodify.R;
import com.google.android.material.chip.Chip;
import com.google.android.material.chip.ChipGroup;
import java.nio.file.LinkOption;
import java.util.ArrayList;
import java.util.List;
@@ -38,13 +41,15 @@ import retrofit2.Response;
public class SearchFragment extends Fragment {
private static int CURRENT_PAGE = 1;
private static final int LIMIT = 18;
private static int TOTAL_PAGE = 5;
private static int CURRENT_PAGE = 0;
private static final int LIMIT = 8;
private static int TOTAL_PAGE = 0;
private static int ACTION_CODE = -1;
private static final int LIST_FOOD = -1;
private static final int SEARCH_FOOD = 0;
private static final int LIST_FOOD_BY_CATEGORY = 2;
private String searchQuery = "";
private LinearLayout searchNotFound;
private RecyclerView recycler_view_search;
private NestedScrollView nestedScrollView;
private TextView end_of_list_text_view;
@@ -52,7 +57,7 @@ public class SearchFragment extends Fragment {
private ProgressBar progressBar;
private static final List<Food> listFoodSearch = new ArrayList<>();
private ChipGroup list_Category;
private final List<String> statusCategoryChecked = new ArrayList<>();
private final List<Integer> statusCategoryChecked = new ArrayList<>();
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
@@ -67,6 +72,7 @@ public class SearchFragment extends Fragment {
foodAdapter = new FoodSearchAdapter(getContext());
progressBar = view.findViewById(R.id.progress_bar);
end_of_list_text_view = view.findViewById(R.id.end_of_list_text);
searchNotFound = view.findViewById(R.id.search_not_found);
getListCategory();
@@ -76,10 +82,11 @@ public class SearchFragment extends Fragment {
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL);
recycler_view_search.addItemDecoration(itemDecoration);
//Fix for lagging when scrolling
recycler_view_search.setNestedScrollingEnabled(false);
recycler_view_search.setAdapter(foodAdapter);
getListFoodByPagination(1);
getListFood(0);
if (nestedScrollView != null) {
nestedScrollView.setOnScrollChangeListener(new NestedScrollView.OnScrollChangeListener() {
@Override
@@ -94,8 +101,13 @@ public class SearchFragment extends Fragment {
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String query) {
//Hide UI search not found
searchNotFound.setVisibility(View.GONE);
//Set action code
ACTION_CODE = SEARCH_FOOD;
CURRENT_PAGE = 1;
CURRENT_PAGE = 0;
listFoodSearch.clear();
showProgressBarAndHideEndOfListText();
if (!query.isEmpty()) {
@@ -110,12 +122,14 @@ public class SearchFragment extends Fragment {
if (searchView.getQuery().length() == 0) {
listFoodSearch.clear();
CURRENT_PAGE = 1;
CURRENT_PAGE = 0;
ACTION_CODE = LIST_FOOD;
showProgressBarAndHideEndOfListText();
foodAdapter.setData(listFood);
foodAdapter.notifyDataSetChanged();
hideProgressBarAndShowEndOfListText();
//Hide UI search not found
searchNotFound.setVisibility(View.GONE);
getListFood(0);
}
return true;
}
@@ -134,27 +148,44 @@ public class SearchFragment extends Fragment {
end_of_list_text_view.setVisibility(View.VISIBLE);
}
private void getListFoodBySearch(String query, int page) {
FoodApi.apiService.listFood(query, page, LIMIT, "id", "asc").enqueue(new Callback<List<Food>>() {
FoodApi.apiService.searchFoodByName(query, page, LIMIT, "id", "asc").enqueue(new Callback<Foods>() {
@Override
public void onResponse(Call<List<Food>> call, Response<List<Food>> response) {
public void onResponse(Call<Foods> call, Response<Foods> response) {
//Init total page and total elements value
TOTAL_PAGE = response.body().getPage().getTotalPages();
loadFoodAdapter(response);
}
@Override
public void onFailure(Call<List<Food>> call, Throwable t) {
Toast.makeText(getContext(), "Lỗi" + t, Toast.LENGTH_LONG).show();
public void onFailure(Call<Foods> call, Throwable t) {
}
});
}
private void loadFoodAdapter(Response<List<Food>> response) {
List<Food> foodData = response.body();
private void loadFoodAdapter(Response<Foods> response) {
Foods foodData = response.body();
listFoodSearch.addAll(foodData);
List<Food> tempFood = foodData.getProducts();
listFoodSearch.addAll(tempFood);
foodAdapter.setData(listFoodSearch);
foodAdapter.notifyDataSetChanged();
hideProgressBarAndShowEndOfListText();
//If list data don't have pagination
if(TOTAL_PAGE == 1)
hideProgressBarAndShowEndOfListText();
//If search not found
if(listFoodSearch.size() == 0){
searchNotFound.setVisibility(View.VISIBLE);
progressBar.setVisibility(View.GONE);
}
}
private void getListCategory() {
@@ -174,12 +205,19 @@ public class SearchFragment extends Fragment {
chip.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton compoundButton, boolean b) {
loadFoodByCategory(tempCategory.getId());
//Add category to list category have checked
if(b) {
statusCategoryChecked.add(tempCategory.getId());
statusCategoryChecked.add(Integer.parseInt(tempCategory.getId()));
} else {
statusCategoryChecked.remove(tempCategory.getId());
statusCategoryChecked.remove(Integer.valueOf(tempCategory.getId()));
}
ACTION_CODE = LIST_FOOD_BY_CATEGORY;
listFoodSearch.clear();
CURRENT_PAGE = 0;
showProgressBarAndHideEndOfListText();
getListFoodByCategory(CURRENT_PAGE);
Toast.makeText(getContext(), "Category check: " + statusCategoryChecked, Toast.LENGTH_SHORT).show();
}
});
@@ -203,16 +241,17 @@ public class SearchFragment extends Fragment {
});
}
private void loadFoodByCategory(String id) {
FoodApi.apiService.listFoodByCategory(id).enqueue(new Callback<List<Food>>() {
private void getListFoodByCategory(int page) {
FoodApi.apiService.listFoodByCategory(statusCategoryChecked, page, LIMIT, "id", "asc").enqueue(new Callback<Foods>() {
@Override
public void onResponse(Call<List<Food>> call, Response<List<Food>> response) {
public void onResponse(Call<Foods> call, Response<Foods> response) {
//Init total page and total elements value
TOTAL_PAGE = response.body().getPage().getTotalPages();
loadFoodAdapter(response);
}
@Override
public void onFailure(Call<List<Food>> call, Throwable t) {
public void onFailure(Call<Foods> call, Throwable t) {
//Check internet connection
if(Common.checkInternetConnection(getContext())){
//Has internet connection
@@ -225,15 +264,16 @@ public class SearchFragment extends Fragment {
});
}
private void getListFoodByPagination(int page){
FoodApi.apiService.listFood(page, LIMIT).enqueue(new Callback<List<Food>>() {
private void getListFood(int page){
FoodApi.apiService.listFood(page, LIMIT, "id", "asc").enqueue(new Callback<Foods>() {
@Override
public void onResponse(Call<List<Food>> call, Response<List<Food>> response) {
public void onResponse(Call<Foods> call, Response<Foods> response) {
TOTAL_PAGE = response.body().getPage().getTotalPages();
loadFoodAdapter(response);
}
@Override
public void onFailure(Call<List<Food>> call, Throwable t) {
public void onFailure(Call<Foods> call, Throwable t) {
//Check internet connection
if(Common.checkInternetConnection(getContext())){
//Has internet connection
@@ -249,21 +289,29 @@ public class SearchFragment extends Fragment {
private void dataLoadMore() {
switch (ACTION_CODE){
case LIST_FOOD:{
if(CURRENT_PAGE < TOTAL_PAGE){
getListFoodByPagination(++CURRENT_PAGE);
if(CURRENT_PAGE < TOTAL_PAGE - 1){
getListFood(++CURRENT_PAGE);
} else {
hideProgressBarAndShowEndOfListText();
}
break;
}
case SEARCH_FOOD:{
if(CURRENT_PAGE < TOTAL_PAGE){
if(CURRENT_PAGE < TOTAL_PAGE - 1){
getListFoodBySearch(searchQuery, ++CURRENT_PAGE);
} else {
hideProgressBarAndShowEndOfListText();
}
break;
}
case LIST_FOOD_BY_CATEGORY:{
if(CURRENT_PAGE < TOTAL_PAGE - 1){
getListFoodByCategory(++CURRENT_PAGE);
} else {
hideProgressBarAndShowEndOfListText();
}
break;
}
}
}
@@ -3,6 +3,7 @@ package com.capstone.foodify.Model.Category;
public class Category {
private String id;
private String name;
private String imageUrl;
public String getId() {
return id;
@@ -19,4 +20,12 @@ public class Category {
public void setName(String name) {
this.name = name;
}
public String getImageUrl() {
return imageUrl;
}
public void setImageUrl(String imageUrl) {
this.imageUrl = imageUrl;
}
}
@@ -116,4 +116,21 @@ public class Food implements Comparable<Food>{
}
return getName().compareTo(food.getName());
}
@Override
public String toString() {
return "Food{" +
"id='" + id + '\'' +
", name='" + name + '\'' +
", description='" + description + '\'' +
", isEnabled=" + isEnabled +
", discountPercent=" + discountPercent +
", cost=" + cost +
", averageRating=" + averageRating +
", reviewCount='" + reviewCount + '\'' +
", shop=" + shop +
", categories=" + categories +
", images=" + images +
'}';
}
}
@@ -18,6 +18,7 @@ import java.util.List;
public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.FoodViewHolder>{
public static final int LENGTH_CHARACTER = 40;
private List<Food> listFood;
private Context context;
@@ -45,18 +46,38 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
return;
}
//Init data
String foodName = food.getName();
if(foodName.length() >= 19){
if(foodName.length() >= LENGTH_CHARACTER){
StringBuilder stringBuilder = new StringBuilder(food.getName());
stringBuilder.replace(19, food.getName().length(), "..." );
stringBuilder.replace(LENGTH_CHARACTER, food.getName().length(), "..." );
holder.name.setText(stringBuilder);
} else {
holder.name.setText(foodName);
}
// Picasso.get().load(food.getImg()).into(holder.image);
//
//
// holder.price.setText(Common.changeCurrencyUnit(Float.parseFloat(food.getPrice())));
//When food does not have image
if(food.getImages().size() == 0){
holder.image.setImageResource(R.drawable.default_image_food);
} else {
Picasso.get().load(food.getImages().get(0).getImageUrl()).into(holder.image);
}
//Check value discountPercent
float cost = 0;
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));
}
@Override
@@ -70,7 +91,7 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
public static class FoodViewHolder extends RecyclerView.ViewHolder{
private final ImageView image;
private final TextView price, name;
private final TextView price, name, discount;
public FoodViewHolder(@NonNull View itemView) {
super(itemView);
@@ -78,7 +99,7 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
image = itemView.findViewById(R.id.image_view);
name = itemView.findViewById(R.id.food_name_text_view);
price = itemView.findViewById(R.id.price_text_view);
discount = itemView.findViewById(R.id.discount);
}
}
}
@@ -24,4 +24,12 @@ public class Foods {
public void setPage(Page page) {
this.page = page;
}
@Override
public String toString() {
return "Foods{" +
"products=" + products +
", page=" + page +
'}';
}
}
Binary file not shown.

After

Width:  |  Height:  |  Size: 18 KiB

+36
View File
@@ -0,0 +1,36 @@
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:pathData="M415.89,279.29L415.89,279.29c0,-89.48 -72.85,-161.98 -161.98,-161.98c-42.6,0 -82.72,17.5 -107.98,41.35l0,0c-34.44,30.86 -54,74.5 -54,120.62l0,0c0,45.33 18.97,89.23 54,120.62l0,0c30.31,26.94 67.92,41.35 107.98,41.35C342.28,441.26 415.89,369.54 415.89,279.29z"
android:fillColor="#E4EAF8"/>
<path
android:pathData="M253.91,172.84c-58.69,0 -106.44,47.75 -106.44,106.44s47.75,106.44 106.44,106.44c58.69,0 106.44,-47.75 106.44,-106.44S312.6,172.84 253.91,172.84z"
android:fillColor="#D8DCE5"/>
<path
android:pathData="M165.93,399.91L165.93,399.91c-71.95,-64.48 -72.04,-176.69 0,-241.25l0,0c23.29,-22 59.22,-38.58 98.08,-41.03c-3.34,-0.21 -6.71,-0.32 -10.11,-0.32c-42.6,0 -82.72,17.5 -107.98,41.35l0,0c-71.95,64.48 -72.04,176.69 0,241.25l0,0c30.31,26.94 67.92,41.35 107.98,41.35c3.33,0 6.64,-0.11 9.92,-0.31C227.56,438.73 193.68,424.58 165.93,399.91z"
android:fillColor="#D8DCE5"/>
<path
android:pathData="M167.47,279.29c0,-55.32 42.42,-100.91 96.44,-105.97c-3.29,-0.31 -6.63,-0.47 -10,-0.47c-58.69,0 -106.44,47.75 -106.44,106.44c0,58.69 47.75,106.44 106.44,106.44c3.37,0 6.71,-0.17 10,-0.47C209.89,380.2 167.47,334.61 167.47,279.29z"
android:fillColor="#C3C8D1"/>
<path
android:pathData="M118.99,78C93.91,71.28 64.83,98.51 54.03,138.82c-4.66,17.38 -4.04,30.22 0.17,39.74c8.37,18.9 9.28,40.28 3.93,60.25L8.53,423.93c-2.45,9.15 2.98,18.56 12.13,21.02l0,0c9.15,2.45 18.56,-2.98 21.02,-12.13L91.28,247.69c5.35,-19.97 16.83,-38.02 33.53,-50.21C155.16,175.34 160.35,89.08 118.99,78z"
android:fillColor="#FFC850"/>
<path
android:pathData="M28.53,423.93l49.6,-185.12c5.35,-19.97 4.44,-41.34 -3.93,-60.25c-4.21,-9.52 -4.83,-22.35 -0.17,-39.74c8.27,-30.88 27.27,-54.06 46.97,-60.21c-0.66,-0.22 -1.33,-0.43 -2.02,-0.62C93.91,71.28 64.83,98.51 54.03,138.82c-4.66,17.38 -4.04,30.22 0.17,39.74c8.37,18.9 9.28,40.28 3.93,60.25L8.53,423.93c-2.45,9.15 2.98,18.56 12.13,21.02c5.17,1.38 10.42,0.25 14.45,-2.64C29.48,438.26 26.63,431.03 28.53,423.93z"
android:fillColor="#F9B428"/>
<path
android:pathData="M459.93,157.46l-83.5,22.37l7.35,27.44c1.98,7.4 7.28,13.69 14.96,16.46c11.27,4.07 19.97,13.18 23.07,24.76l49.26,183.86c2.39,8.93 11.31,14.77 20.33,12.8c9.64,-2.1 15.46,-11.79 12.94,-21.21l-48.92,-182.57c-3.18,-11.86 -1.01,-24.86 7.55,-35.23c4.79,-5.81 6.34,-13.64 4.39,-20.92L459.93,157.46z"
android:fillColor="#FFC850"/>
<path
android:pathData="M491.97,432.36l-49.26,-183.86c-3.1,-11.57 -11.8,-20.69 -23.07,-24.76c-7.68,-2.77 -12.97,-9.06 -14.95,-16.46l-8.93,-32.62l-19.31,5.17l7.35,27.44c1.98,7.4 7.28,13.69 14.96,16.46c11.27,4.07 19.97,13.18 23.07,24.76l49.26,183.86c2.39,8.93 11.31,14.77 20.33,12.8c2.62,-0.57 4.94,-1.72 6.91,-3.25C495.31,439.58 493.02,436.26 491.97,432.36z"
android:fillColor="#F9B428"/>
<path
android:fillColor="#FF000000"
android:pathData="M272.21,166.73c-4.1,-0.68 -7.95,2.08 -8.63,6.17c-0.68,4.09 2.08,7.95 6.17,8.63c47.9,7.96 82.67,49.01 82.67,97.6c0,54.56 -44.38,98.94 -98.94,98.94c-54.56,0 -98.94,-44.38 -98.94,-98.94c0,-48.59 34.77,-89.64 82.67,-97.6c4.09,-0.68 6.85,-4.54 6.17,-8.63c-0.68,-4.09 -4.54,-6.85 -8.63,-6.17c-26.29,4.37 -50.38,18 -67.84,38.38c-63.12,73.71 -10.42,187.96 86.57,187.96c62.83,0 113.94,-51.11 113.94,-113.94C367.42,222.83 326.28,175.71 272.21,166.73z"/>
<path
android:fillColor="#FF000000"
android:pathData="M511.17,421.84l-34.07,-127.16c-1.07,-4 -5.18,-6.38 -9.19,-5.3c-4,1.07 -6.38,5.18 -5.3,9.19l34.07,127.15c0.69,2.58 0.31,5.25 -1.08,7.53c-4.49,7.38 -15.43,5.49 -17.7,-3l-49.26,-183.86c-2.67,-9.97 -8.88,-18.5 -17.04,-24.27c-9.35,-6.6 -17.93,-5.55 -20.99,-16.95l-5.41,-20.2l69,-18.49l5.5,20.51c1.35,5.04 0.25,10.35 -2.93,14.2c-9.71,11.77 -13,27.06 -9.01,41.95l5.47,20.41c1.07,4 5.18,6.38 9.19,5.3c4,-1.07 6.38,-5.18 5.3,-9.19l-5.47,-20.41c-2.72,-10.14 -0.5,-20.54 6.09,-28.52c6.26,-7.59 8.45,-17.92 5.85,-27.63l0,0c-0,-0.01 0,0.01 0,0l-31.73,-118.4c-1.07,-4 -5.18,-6.38 -9.19,-5.3c-4,1.07 -6.38,5.18 -5.3,9.19l22.35,83.39l-13.34,3.58l-22.35,-83.39c-1.07,-4 -5.18,-6.38 -9.19,-5.3c-4,1.07 -6.38,5.18 -5.3,9.19l22.35,83.39l-13.34,3.58L386.79,79.64c-1.07,-4 -5.18,-6.38 -9.19,-5.3c-4,1.07 -6.38,5.18 -5.3,9.19l22.35,83.39l-11.59,3.11c-0.9,-1.07 -1.81,-2.13 -2.73,-3.17l-21.37,-79.76c-1.07,-4 -5.18,-6.38 -9.19,-5.3c-4,1.07 -6.38,5.18 -5.3,9.19l14.97,55.88c-56.8,-45.84 -140.55,-51.16 -203.84,-6.03c4.08,-69.85 -48.34,-93.33 -86.04,-49.28c-19.8,23.13 -34.09,64.08 -22.66,89.89c7.37,16.65 8.63,36.28 3.55,55.27l-49.6,185.12c-1.71,6.36 -0.83,13.01 2.46,18.71c10.91,18.89 39.48,15.32 45.18,-5.95l36.5,-136.21c0.12,1 0.22,1.99 0.36,2.99c7.29,54.04 40.62,101.33 87.44,126.83c110.61,60.25 247.27,-18.59 250.13,-145.2l40.5,151.14c5.74,21.44 33.76,25.38 45,6.92C511.9,435.33 512.9,428.32 511.17,421.84zM34,430.71c-2.24,8.34 -13.43,9.72 -17.69,2.33c-1.29,-2.23 -1.63,-4.84 -0.96,-7.33l49.6,-185.12c5.97,-22.29 4.44,-45.45 -4.32,-65.23c-12.37,-27.94 18.04,-91.1 49.83,-91.1c40.19,0 37.19,86.79 9.51,106.99c-16.83,12.28 -30.2,31.35 -36.35,54.33L34,430.71zM253.48,433.6c-106.03,0 -183.11,-106.51 -144.65,-208.69c9.21,-14.51 18.99,-20.61 22.05,-23.15c0.05,-0.04 0.1,-0.09 0.15,-0.13c11.25,-9.41 17.97,-24.91 21.41,-39.24c63.32,-54.94 158.1,-49.14 214.34,11.84l0,0l9.34,34.84c4.81,17.96 19.25,20.7 24.83,24.03c4.65,14.87 7.01,30.35 7.01,46.04C407.95,364.31 338.65,433.6 253.48,433.6z"/>
</vector>
+37 -3
View File
@@ -9,8 +9,10 @@
>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/search_layout"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:layout_height="match_parent"
>
<androidx.cardview.widget.CardView
android:id="@+id/card_view"
@@ -46,7 +48,7 @@
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view_search"
tools:listitem="@layout/item_food"
tools:listitem="@layout/item_food_search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/list_category"
@@ -54,6 +56,37 @@
app:layout_constraintEnd_toEndOf="parent"
/>
<LinearLayout
android:id="@+id/search_not_found"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintTop_toBottomOf="@id/list_category"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent"
android:orientation="vertical"
android:visibility="gone"
>
<ImageView
android:layout_width="150dp"
android:layout_height="150dp"
android:src="@drawable/dish"
android:layout_marginTop="100dp"
android:layout_gravity="center_horizontal"
/>
<TextView
android:text="Không có kết quả cần tìm. Vui lòng tìm thử với từ khoá khác."
android:fontFamily="@font/opensans"
android:textColor="@color/gray"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:textAlignment="center"
/>
</LinearLayout>
<ProgressBar
android:id="@+id/progress_bar"
android:indeterminateTint="@color/primaryColor"
@@ -75,7 +108,8 @@
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
android:layout_height="wrap_content"
/>
</androidx.constraintlayout.widget.ConstraintLayout>
+5 -5
View File
@@ -1,14 +1,14 @@
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_width="110dp"
android:layout_height="191dp"
android:layout_marginBottom="10dp"
android:layout_marginEnd="10dp"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="200dp"
android:layout_height="190dp"
app:cardCornerRadius="10dp"
>
@@ -18,8 +18,8 @@
<com.makeramen.roundedimageview.RoundedImageView
android:id="@+id/image_view"
android:layout_width="120dp"
android:layout_height="120dp"
android:layout_width="110dp"
android:layout_height="110dp"
android:src="@drawable/food"
android:scaleType="centerCrop"
app:riv_corner_radius="10dip"
+2 -1
View File
@@ -47,7 +47,7 @@
<TextView
android:id="@+id/shop_name_text_view"
android:text="Shop Name"
android:textSize="16sp"
android:textSize="18sp"
android:textColor="@color/secondary"
android:fontFamily="@font/opensans"
android:layout_width="wrap_content"
@@ -76,6 +76,7 @@
/>
<TextView
android:id="@+id/discount"
android:text="-59%"
android:textSize="8sp"
android:textColor="@color/red"