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