Prevent scroll to another fragment

This commit is contained in:
Nezumi
2023-02-17 08:52:03 +07:00
parent 9225723bb2
commit c6935fe52e
2 changed files with 14 additions and 7 deletions
@@ -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);