mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Fix progress bar on home fragment crash the app
This commit is contained in:
@@ -5,6 +5,7 @@ import android.view.LayoutInflater;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
|
import androidx.constraintlayout.widget.ConstraintLayout;
|
||||||
import androidx.fragment.app.Fragment;
|
import androidx.fragment.app.Fragment;
|
||||||
import androidx.recyclerview.widget.LinearLayoutManager;
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
||||||
import androidx.recyclerview.widget.RecyclerView;
|
import androidx.recyclerview.widget.RecyclerView;
|
||||||
@@ -45,7 +46,7 @@ public class HomeFragment extends Fragment {
|
|||||||
private RecyclerView rcvMenu, recyclerView_restaurant;
|
private RecyclerView rcvMenu, recyclerView_restaurant;
|
||||||
private MenuAdapter menuAdapter;
|
private MenuAdapter menuAdapter;
|
||||||
private ShopAdapter shopAdapter;
|
private ShopAdapter shopAdapter;
|
||||||
private PopupDialog popupDialog;
|
private ConstraintLayout progressLayout;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -59,8 +60,7 @@ public class HomeFragment extends Fragment {
|
|||||||
menuAdapter = new MenuAdapter(getContext());
|
menuAdapter = new MenuAdapter(getContext());
|
||||||
recyclerView_restaurant = view.findViewById(R.id.recycler_view_restaurant);
|
recyclerView_restaurant = view.findViewById(R.id.recycler_view_restaurant);
|
||||||
shopAdapter = new ShopAdapter(getContext());
|
shopAdapter = new ShopAdapter(getContext());
|
||||||
|
progressLayout = view.findViewById(R.id.progress_layout);
|
||||||
popupDialog = PopupDialog.getInstance(getContext());
|
|
||||||
|
|
||||||
|
|
||||||
if(listFood.isEmpty() || recentFood.isEmpty()){
|
if(listFood.isEmpty() || recentFood.isEmpty()){
|
||||||
@@ -91,10 +91,6 @@ public class HomeFragment extends Fragment {
|
|||||||
|
|
||||||
private void showSlider(){
|
private void showSlider(){
|
||||||
|
|
||||||
//Show progress bar
|
|
||||||
popupDialog.setStyle(Styles.PROGRESS).setProgressDialogTint(getResources().getColor(R.color.primaryColor, null))
|
|
||||||
.setCancelable(false).showDialog();
|
|
||||||
|
|
||||||
FoodApi.apiService.listSlider().enqueue(new Callback<List<Slider>>() {
|
FoodApi.apiService.listSlider().enqueue(new Callback<List<Slider>>() {
|
||||||
@Override
|
@Override
|
||||||
public void onResponse(Call<List<Slider>> call, Response<List<Slider>> response) {
|
public void onResponse(Call<List<Slider>> call, Response<List<Slider>> response) {
|
||||||
@@ -107,13 +103,17 @@ public class HomeFragment extends Fragment {
|
|||||||
|
|
||||||
imageSlider.setImageList(slideModels, ScaleTypes.FIT);
|
imageSlider.setImageList(slideModels, ScaleTypes.FIT);
|
||||||
|
|
||||||
popupDialog.dismissDialog();
|
//Dismiss progress bar
|
||||||
|
progressLayout.setVisibility(View.GONE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<List<Slider>> call, Throwable t) {
|
public void onFailure(Call<List<Slider>> call, Throwable t) {
|
||||||
popupDialog.dismissDialog();
|
//Dismiss progress bar
|
||||||
Common.showNotificationError(getContext(), getActivity());
|
progressLayout.setVisibility(View.GONE);
|
||||||
|
|
||||||
|
if(getActivity() != null)
|
||||||
|
Common.showNotificationError(getContext(), getActivity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -144,7 +144,8 @@ public class HomeFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<Foods> call, Throwable t) {
|
public void onFailure(Call<Foods> call, Throwable t) {
|
||||||
//Check internet connection
|
//Check internet connection
|
||||||
Common.showNotificationError(getContext(), getActivity());
|
if(getActivity() != null)
|
||||||
|
Common.showNotificationError(getContext(), getActivity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -191,7 +192,8 @@ public class HomeFragment extends Fragment {
|
|||||||
@Override
|
@Override
|
||||||
public void onFailure(Call<Shops> call, Throwable t) {
|
public void onFailure(Call<Shops> call, Throwable t) {
|
||||||
//Check internet connection
|
//Check internet connection
|
||||||
Common.showNotificationError(getContext(), getActivity());
|
if(getActivity() != null)
|
||||||
|
Common.showNotificationError(getContext(), getActivity());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,16 +31,19 @@
|
|||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/forgot_Password_description"
|
android:id="@+id/forgot_Password_description"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_marginTop="20dp"
|
android:layout_marginTop="20dp"
|
||||||
android:text="@string/confirm_code_description"
|
android:text="@string/confirm_code_description"
|
||||||
android:fontFamily="@font/opensans"
|
android:fontFamily="@font/opensans"
|
||||||
android:textColor="@color/gray"
|
android:textColor="@color/gray"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
|
android:layout_marginEnd="20dp"
|
||||||
android:layout_marginStart="20dp"
|
android:layout_marginStart="20dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintTop_toBottomOf="@+id/textView" />
|
app:layout_constraintTop_toBottomOf="@+id/textView"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
<LinearLayout
|
<LinearLayout
|
||||||
|
|||||||
@@ -1,118 +1,151 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<androidx.core.widget.NestedScrollView xmlns:android="http://schemas.android.com/apk/res/android"
|
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
xmlns:app="http://schemas.android.com/apk/res-auto"
|
xmlns:app="http://schemas.android.com/apk/res-auto"
|
||||||
xmlns:tools="http://schemas.android.com/tools"
|
xmlns:tools="http://schemas.android.com/tools"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
tools:context=".Fragment.HomeFragment">
|
tools:context=".Fragment.HomeFragment">
|
||||||
|
|
||||||
<androidx.constraintlayout.widget.ConstraintLayout
|
<androidx.core.widget.NestedScrollView
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="match_parent"
|
||||||
android:layout_marginStart="10dp"
|
|
||||||
android:layout_marginEnd="10dp"
|
|
||||||
>
|
>
|
||||||
|
|
||||||
<LinearLayout
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:id="@+id/header_title"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_marginTop="40dp"
|
android:layout_height="match_parent"
|
||||||
android:layout_height="wrap_content"
|
android:layout_marginStart="10dp"
|
||||||
app:layout_constraintTop_toTopOf="parent"
|
android:layout_marginEnd="10dp"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
android:orientation="horizontal"
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
>
|
>
|
||||||
|
|
||||||
<TextView
|
<LinearLayout
|
||||||
android:id="@+id/welcome_text"
|
android:id="@+id/header_title"
|
||||||
android:text="@string/hello_guest"
|
android:layout_width="match_parent"
|
||||||
android:textSize="22sp"
|
android:layout_marginTop="40dp"
|
||||||
android:fontFamily="@font/opensans"
|
|
||||||
android:textStyle="bold"
|
|
||||||
android:textColor="@color/black"
|
|
||||||
android:layout_weight="0.7"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/welcome_text"
|
||||||
|
android:text="@string/hello_guest"
|
||||||
|
android:textSize="22sp"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/black"
|
||||||
|
android:layout_weight="0.7"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
|
||||||
|
<TextView
|
||||||
|
android:id="@+id/text_address"
|
||||||
|
android:text="@string/home"
|
||||||
|
android:textSize="18sp"
|
||||||
|
android:textStyle="bold"
|
||||||
|
android:textColor="@color/secondary"
|
||||||
|
android:textAlignment="center"
|
||||||
|
android:layout_width="wrap_content"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
/>
|
||||||
|
<ImageView
|
||||||
|
android:src="@drawable/location"
|
||||||
|
android:layout_weight="0.1"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="30dp"
|
||||||
|
android:contentDescription="@string/location_icon"
|
||||||
|
app:tint="@color/secondary"
|
||||||
|
/>
|
||||||
|
|
||||||
|
</LinearLayout>
|
||||||
|
|
||||||
|
<com.denzcoskun.imageslider.ImageSlider
|
||||||
|
android:id="@+id/slider"
|
||||||
|
app:iss_auto_cycle="true"
|
||||||
|
app:iss_delay="0"
|
||||||
|
app:iss_period="3000"
|
||||||
|
android:layout_marginTop="20dp"
|
||||||
|
app:iss_corner_radius="40"
|
||||||
|
android:layout_width="match_parent"
|
||||||
|
android:layout_height="180dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/header_title"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/text_address"
|
android:id="@+id/restaurant_text"
|
||||||
android:text="@string/home"
|
android:text="Shop"
|
||||||
|
android:layout_marginTop="5dp"
|
||||||
android:textSize="18sp"
|
android:textSize="18sp"
|
||||||
|
android:fontFamily="@font/opensans"
|
||||||
|
android:textColor="@color/black"
|
||||||
android:textStyle="bold"
|
android:textStyle="bold"
|
||||||
android:textColor="@color/secondary"
|
|
||||||
android:textAlignment="center"
|
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/slider"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
/>
|
/>
|
||||||
<ImageView
|
|
||||||
android:src="@drawable/location"
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:layout_weight="0.1"
|
android:id="@+id/recycler_view_restaurant"
|
||||||
android:layout_width="0dp"
|
android:layout_width="0dp"
|
||||||
android:layout_height="30dp"
|
android:layout_height="wrap_content"
|
||||||
android:contentDescription="@string/location_icon"
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
app:tint="@color/secondary"
|
android:orientation="horizontal"
|
||||||
|
android:contentDescription="@string/description"
|
||||||
|
tools:listitem="@layout/item_shop"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/restaurant_text"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</LinearLayout>
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
|
android:id="@+id/recycler_view_menu"
|
||||||
|
android:layout_width="0dp"
|
||||||
|
android:layout_height="wrap_content"
|
||||||
|
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
||||||
|
android:orientation="horizontal"
|
||||||
|
tools:listitem="@layout/item_food"
|
||||||
|
android:layout_marginTop="10dp"
|
||||||
|
app:layout_constraintTop_toBottomOf="@id/recycler_view_restaurant"
|
||||||
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
/>
|
||||||
|
|
||||||
<com.denzcoskun.imageslider.ImageSlider
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
android:id="@+id/slider"
|
|
||||||
app:iss_auto_cycle="true"
|
|
||||||
app:iss_delay="0"
|
|
||||||
app:iss_period="3000"
|
|
||||||
android:layout_marginTop="20dp"
|
|
||||||
app:iss_corner_radius="40"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="180dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/header_title"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<TextView
|
</androidx.core.widget.NestedScrollView>
|
||||||
android:id="@+id/restaurant_text"
|
|
||||||
android:text="Shop"
|
<androidx.constraintlayout.widget.ConstraintLayout
|
||||||
android:layout_marginTop="5dp"
|
android:layout_width="match_parent"
|
||||||
android:textSize="18sp"
|
android:layout_height="0dp"
|
||||||
android:fontFamily="@font/opensans"
|
android:background="#80000000"
|
||||||
android:textColor="@color/black"
|
android:id="@+id/progress_layout"
|
||||||
android:textStyle="bold"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
|
>
|
||||||
|
|
||||||
|
<ProgressBar
|
||||||
|
android:id="@+id/progressBarLoadData"
|
||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
app:layout_constraintTop_toBottomOf="@id/slider"
|
android:indeterminateTint="@color/primaryColor"
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_restaurant"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
android:contentDescription="@string/description"
|
|
||||||
tools:listitem="@layout/item_shop"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/restaurant_text"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<androidx.recyclerview.widget.RecyclerView
|
|
||||||
android:id="@+id/recycler_view_menu"
|
|
||||||
android:layout_width="0dp"
|
|
||||||
android:layout_height="wrap_content"
|
|
||||||
app:layoutManager="androidx.recyclerview.widget.LinearLayoutManager"
|
|
||||||
android:orientation="horizontal"
|
|
||||||
tools:listitem="@layout/item_food"
|
|
||||||
android:layout_marginTop="10dp"
|
|
||||||
app:layout_constraintTop_toBottomOf="@id/recycler_view_restaurant"
|
|
||||||
app:layout_constraintStart_toStartOf="parent"
|
app:layout_constraintStart_toStartOf="parent"
|
||||||
app:layout_constraintEnd_toEndOf="parent"
|
app:layout_constraintEnd_toEndOf="parent"
|
||||||
|
app:layout_constraintTop_toTopOf="parent"
|
||||||
|
app:layout_constraintBottom_toBottomOf="parent"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
</androidx.constraintlayout.widget.ConstraintLayout>
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
|
|
||||||
|
|
||||||
|
</androidx.constraintlayout.widget.ConstraintLayout>
|
||||||
</androidx.core.widget.NestedScrollView>
|
|
||||||
Reference in New Issue
Block a user