mirror of
https://github.com/Nezumi-2711/Foodify.git
synced 2026-09-22 13:38:41 +00:00
Prevent scroll to another fragment
This commit is contained in:
@@ -7,6 +7,8 @@ import androidx.viewpager2.widget.ViewPager2;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.os.Bundle;
|
||||
import android.view.MenuItem;
|
||||
import android.view.MotionEvent;
|
||||
import android.view.View;
|
||||
|
||||
import com.capstone.foodify.R;
|
||||
import com.capstone.foodify.ViewPagerAdapter;
|
||||
@@ -37,6 +39,8 @@ public class MainActivity extends AppCompatActivity {
|
||||
private void bottomNavigation() {
|
||||
viewPagerAdapter = new ViewPagerAdapter(this);
|
||||
viewPager2.setAdapter(viewPagerAdapter);
|
||||
|
||||
viewPager2.setUserInputEnabled(false);
|
||||
bottomNavigationView.setOnItemSelectedListener(new NavigationBarView.OnItemSelectedListener() {
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Override
|
||||
|
||||
@@ -53,8 +53,13 @@ public class HomeFragment extends Fragment {
|
||||
recyclerView_restaurant = view.findViewById(R.id.recycler_view_restaurant);
|
||||
shopAdapter = new ShopAdapter(getContext());
|
||||
|
||||
if(listFood.isEmpty() || drinkFood.isEmpty()){
|
||||
getListFood();
|
||||
} else {
|
||||
menuAdapter.setData(getListMenu());
|
||||
rcvMenu.setAdapter(menuAdapter);
|
||||
}
|
||||
|
||||
getListFood();
|
||||
|
||||
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(getContext(), RecyclerView.VERTICAL, false);
|
||||
rcvMenu.setLayoutManager(linearLayoutManager);
|
||||
@@ -98,9 +103,8 @@ public class HomeFragment extends Fragment {
|
||||
public void onResponse(Call<List<Food>> call, Response<List<Food>> response) {
|
||||
List<Food> foodData = response.body();
|
||||
|
||||
for(Food tempFood: foodData){
|
||||
listFood.add(tempFood);
|
||||
}
|
||||
if(foodData != null)
|
||||
listFood.addAll(foodData);
|
||||
|
||||
drinkListFood();
|
||||
}
|
||||
@@ -118,9 +122,8 @@ public class HomeFragment extends Fragment {
|
||||
public void onResponse(Call<List<Food>> call, Response<List<Food>> response) {
|
||||
List<Food> foodData = response.body();
|
||||
|
||||
for(Food tempFood: foodData){
|
||||
drinkFood.add(tempFood);
|
||||
}
|
||||
if(foodData != null)
|
||||
drinkFood.addAll(foodData);
|
||||
|
||||
menuAdapter.setData(getListMenu());
|
||||
rcvMenu.setAdapter(menuAdapter);
|
||||
|
||||
Reference in New Issue
Block a user