mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 20:00:50 +00:00
Fix UI search layout
This commit is contained in:
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="CompilerConfiguration">
|
<component name="CompilerConfiguration">
|
||||||
<bytecodeTargetLevel target="11" />
|
<bytecodeTargetLevel target="17" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Generated
+1
@@ -7,6 +7,7 @@
|
|||||||
<option name="testRunner" value="GRADLE" />
|
<option name="testRunner" value="GRADLE" />
|
||||||
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
<option name="distributionType" value="DEFAULT_WRAPPED" />
|
||||||
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
<option name="externalProjectPath" value="$PROJECT_DIR$" />
|
||||||
|
<option name="gradleJvm" value="jbr-17" />
|
||||||
<option name="modules">
|
<option name="modules">
|
||||||
<set>
|
<set>
|
||||||
<option value="$PROJECT_DIR$" />
|
<option value="$PROJECT_DIR$" />
|
||||||
|
|||||||
Generated
+1
-2
@@ -1,7 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="Android Studio default JDK" project-jdk-type="JavaSDK">
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_17" project-jdk-name="jbr-17" project-jdk-type="JavaSDK">
|
||||||
<output url="file://$PROJECT_DIR$/build/classes" />
|
<output url="file://$PROJECT_DIR$/build/classes" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ProjectType">
|
<component name="ProjectType">
|
||||||
|
|||||||
+1
-1
@@ -14,7 +14,7 @@ android {
|
|||||||
defaultConfig {
|
defaultConfig {
|
||||||
applicationId "com.capstone.foodify"
|
applicationId "com.capstone.foodify"
|
||||||
minSdk 26
|
minSdk 26
|
||||||
targetSdk 33
|
targetSdk 32
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
|
||||||
|
|||||||
@@ -120,12 +120,14 @@ public class HomeFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<List<Food>> call, Throwable t) {
|
public void onFailure(Call<List<Food>> call, Throwable t) {
|
||||||
//Check internet connection
|
//Check internet connection
|
||||||
if(Common.checkInternetConnection(getContext())){
|
if(getContext() != null){
|
||||||
//Has internet connection
|
if(Common.checkInternetConnection(getContext())){
|
||||||
Toast.makeText(getContext(), "Error: " + t, Toast.LENGTH_SHORT).show();
|
//Has internet connection
|
||||||
} else {
|
Toast.makeText(getContext(), "Error: " + t, Toast.LENGTH_SHORT).show();
|
||||||
//No internet, show notification
|
} else {
|
||||||
Common.showErrorInternetConnectionNotification(getActivity());
|
//No internet, show notification
|
||||||
|
Common.showErrorInternetConnectionNotification(getActivity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -15,7 +15,9 @@ import androidx.annotation.NonNull;
|
|||||||
import androidx.appcompat.widget.SearchView;
|
import androidx.appcompat.widget.SearchView;
|
||||||
import androidx.core.widget.NestedScrollView;
|
import androidx.core.widget.NestedScrollView;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
|
import androidx.recyclerview.widget.DividerItemDecoration;
|
||||||
import androidx.recyclerview.widget.GridLayoutManager;
|
import androidx.recyclerview.widget.GridLayoutManager;
|
||||||
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
|
|
||||||
import com.capstone.foodify.API.FoodApi;
|
import com.capstone.foodify.API.FoodApi;
|
||||||
@@ -68,8 +70,12 @@ public class SearchFragment extends Fragment {
|
|||||||
|
|
||||||
getListCategory();
|
getListCategory();
|
||||||
|
|
||||||
GridLayoutManager gridLayoutManager = new GridLayoutManager(getContext(), 3);
|
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext());
|
||||||
recycler_view_search.setLayoutManager(gridLayoutManager);
|
recycler_view_search.setLayoutManager(linearLayoutManager);
|
||||||
|
|
||||||
|
RecyclerView.ItemDecoration itemDecoration = new DividerItemDecoration(requireContext(), DividerItemDecoration.VERTICAL);
|
||||||
|
recycler_view_search.addItemDecoration(itemDecoration);
|
||||||
|
|
||||||
recycler_view_search.setNestedScrollingEnabled(false);
|
recycler_view_search.setNestedScrollingEnabled(false);
|
||||||
recycler_view_search.setAdapter(foodAdapter);
|
recycler_view_search.setAdapter(foodAdapter);
|
||||||
|
|
||||||
@@ -90,6 +96,7 @@ public class SearchFragment extends Fragment {
|
|||||||
public boolean onQueryTextSubmit(String query) {
|
public boolean onQueryTextSubmit(String query) {
|
||||||
ACTION_CODE = SEARCH_FOOD;
|
ACTION_CODE = SEARCH_FOOD;
|
||||||
CURRENT_PAGE = 1;
|
CURRENT_PAGE = 1;
|
||||||
|
listFoodSearch.clear();
|
||||||
showProgressBarAndHideEndOfListText();
|
showProgressBarAndHideEndOfListText();
|
||||||
if (!query.isEmpty()) {
|
if (!query.isEmpty()) {
|
||||||
searchQuery = query;
|
searchQuery = query;
|
||||||
@@ -101,6 +108,8 @@ public class SearchFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onQueryTextChange(String newText) {
|
public boolean onQueryTextChange(String newText) {
|
||||||
if (searchView.getQuery().length() == 0) {
|
if (searchView.getQuery().length() == 0) {
|
||||||
|
listFoodSearch.clear();
|
||||||
|
|
||||||
CURRENT_PAGE = 1;
|
CURRENT_PAGE = 1;
|
||||||
ACTION_CODE = LIST_FOOD;
|
ACTION_CODE = LIST_FOOD;
|
||||||
showProgressBarAndHideEndOfListText();
|
showProgressBarAndHideEndOfListText();
|
||||||
@@ -142,8 +151,6 @@ public class SearchFragment extends Fragment {
|
|||||||
private void loadFoodAdapter(Response<List<Food>> response) {
|
private void loadFoodAdapter(Response<List<Food>> response) {
|
||||||
List<Food> foodData = response.body();
|
List<Food> foodData = response.body();
|
||||||
|
|
||||||
listFoodSearch.clear();
|
|
||||||
|
|
||||||
listFoodSearch.addAll(foodData);
|
listFoodSearch.addAll(foodData);
|
||||||
foodAdapter.setData(listFoodSearch);
|
foodAdapter.setData(listFoodSearch);
|
||||||
foodAdapter.notifyDataSetChanged();
|
foodAdapter.notifyDataSetChanged();
|
||||||
|
|||||||
@@ -76,8 +76,8 @@ public class FoodSearchAdapter extends RecyclerView.Adapter<FoodSearchAdapter.Fo
|
|||||||
super(itemView);
|
super(itemView);
|
||||||
|
|
||||||
image = itemView.findViewById(R.id.image_view);
|
image = itemView.findViewById(R.id.image_view);
|
||||||
name = itemView.findViewById(R.id.title);
|
name = itemView.findViewById(R.id.food_name_text_view);
|
||||||
price = itemView.findViewById(R.id.price);
|
price = itemView.findViewById(R.id.price_text_view);
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -49,7 +49,6 @@
|
|||||||
tools:listitem="@layout/item_food"
|
tools:listitem="@layout/item_food"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/list_category"
|
app:layout_constraintTop_toBottomOf="@id/list_category"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
|||||||
@@ -1,67 +1,79 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
android:layout_width="120dp"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="221dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginBottom="10dp"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto">
|
xmlns:app="http://schemas.android.com/apk/res-auto">
|
||||||
|
|
||||||
<androidx.cardview.widget.CardView
|
<LinearLayout
|
||||||
|
android:id="@+id/layout_foreground"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="200dp"
|
android:layout_height="match_parent"
|
||||||
app:cardCornerRadius="10dp"
|
android:orientation="horizontal"
|
||||||
|
android:background="@color/white"
|
||||||
|
android:layout_margin="5dp"
|
||||||
>
|
>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<ImageView
|
||||||
android:layout_width="match_parent"
|
android:id="@+id/image_view"
|
||||||
android:layout_height="match_parent">
|
android:layout_width="110dp"
|
||||||
|
android:layout_height="110dp"
|
||||||
|
android:src="@drawable/food"
|
||||||
|
android:scaleType="centerCrop"
|
||||||
|
app:riv_corner_radius="10dip"
|
||||||
|
tools:ignore="ContentDescription" />
|
||||||
|
|
||||||
<com.makeramen.roundedimageview.RoundedImageView
|
<LinearLayout
|
||||||
android:id="@+id/image_view"
|
android:layout_width="0dp"
|
||||||
android:layout_width="120dp"
|
android:layout_height="wrap_content"
|
||||||
android:layout_height="120dp"
|
android:orientation="vertical"
|
||||||
android:src="@drawable/food"
|
android:layout_weight="1"
|
||||||
android:scaleType="centerCrop"
|
>
|
||||||
app:riv_corner_radius="10dip"
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/food_name_text_view"
|
||||||
|
android:text="Food Name"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="47dp"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/image_view"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/title"
|
android:id="@+id/shop_name_text_view"
|
||||||
android:layout_width="match_parent"
|
android:text="Shop Name"
|
||||||
android:layout_height="40dp"
|
android:textSize="16sp"
|
||||||
android:text="@string/food_title"
|
android:textColor="@color/secondary"
|
||||||
android:layout_marginStart="3dp"
|
|
||||||
android:layout_marginEnd="3dp"
|
|
||||||
android:textSize="12sp"
|
|
||||||
android:fontFamily="@font/opensans"
|
android:fontFamily="@font/opensans"
|
||||||
android:textColor="@color/black"
|
android:layout_width="wrap_content"
|
||||||
android:layout_marginTop="3dp"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/image_view"
|
android:layout_marginStart="12dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
android:layout_marginTop="2dp"
|
||||||
|
app:layout_constraintStart_toEndOf="@id/image_view"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/text_view_1"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
android:id="@+id/linearLayout"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:orientation="horizontal"
|
android:layout_marginTop="2dp"
|
||||||
android:layout_marginTop="5dp"
|
|
||||||
android:layout_marginStart="2dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/title"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/price"
|
android:id="@+id/price_text_view"
|
||||||
android:textSize="18sp"
|
android:text="$5.00"
|
||||||
android:text="1000000000"
|
android:textSize="25sp"
|
||||||
android:textColor="@color/primaryColor"
|
android:textColor="@color/primaryColor"
|
||||||
android:fontFamily="@font/bebas"
|
android:fontFamily="@font/bebas"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent" />
|
android:layout_height="wrap_content"
|
||||||
|
android:layout_marginStart="12dp"
|
||||||
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:text="-59%"
|
android:text="-59%"
|
||||||
@@ -70,31 +82,27 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
|
||||||
android:layout_marginTop="2dp"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
|
|
||||||
>
|
|
||||||
|
|
||||||
<ImageView
|
|
||||||
android:id="@+id/basket_icon"
|
|
||||||
android:layout_width="20dp"
|
|
||||||
android:layout_height="match_parent"
|
|
||||||
android:layout_marginEnd="4dp"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
android:contentDescription="@string/basket_icon"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
android:src="@drawable/basket_icon"
|
|
||||||
/>
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
|
||||||
|
|
||||||
</LinearLayout>
|
</LinearLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
<LinearLayout
|
||||||
</androidx.cardview.widget.CardView>
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:layout_weight="0.1"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ImageView
|
||||||
|
android:id="@+id/basket_icon"
|
||||||
|
android:layout_width="20dp"
|
||||||
|
android:layout_height="match_parent"
|
||||||
|
android:contentDescription="@string/basket_icon"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:src="@drawable/basket_icon"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
</FrameLayout>
|
</FrameLayout>
|
||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||||
plugins {
|
plugins {
|
||||||
id 'com.android.application' version '7.4.1' apply false
|
id 'com.android.application' version '7.4.2' apply false
|
||||||
id 'com.android.library' version '7.4.1' apply false
|
id 'com.android.library' version '7.4.2' apply false
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user