diff --git a/app/src/main/java/com/capstone/foodify/Fragment/SearchFragment.java b/app/src/main/java/com/capstone/foodify/Fragment/SearchFragment.java index 3805261..4b6a38c 100644 --- a/app/src/main/java/com/capstone/foodify/Fragment/SearchFragment.java +++ b/app/src/main/java/com/capstone/foodify/Fragment/SearchFragment.java @@ -90,7 +90,6 @@ public class SearchFragment extends Fragment { ACTION_CODE = SEARCH_FOOD; CURRENT_PAGE = 1; showProgressBarAndHideEndOfListText(); - listFoodSearch.clear(); if (!query.isEmpty()) { searchQuery = query; getListFoodBySearch(searchQuery, CURRENT_PAGE); @@ -106,6 +105,7 @@ public class SearchFragment extends Fragment { showProgressBarAndHideEndOfListText(); foodAdapter.setData(listFood); foodAdapter.notifyDataSetChanged(); + hideProgressBarAndShowEndOfListText(); } return true; } @@ -141,11 +141,14 @@ public class SearchFragment extends Fragment { private void loadFoodAdapter(Response> response) { List foodData = response.body(); - if(foodData != null) { - listFoodSearch.addAll(foodData); - foodAdapter.setData(listFoodSearch); - foodAdapter.notifyDataSetChanged(); - } + listFoodSearch.clear(); + + listFoodSearch.addAll(foodData); + foodAdapter.setData(listFoodSearch); + foodAdapter.notifyDataSetChanged(); + hideProgressBarAndShowEndOfListText(); + + Toast.makeText(getContext(), "List food search: " + foodData.size(), Toast.LENGTH_SHORT).show(); } private void getListCategory() { @@ -192,7 +195,6 @@ public class SearchFragment extends Fragment { FoodApi.apiService.listFoodByCategory(id).enqueue(new Callback>() { @Override public void onResponse(Call> call, Response> response) { - listFoodSearch.clear(); loadFoodAdapter(response); }