Hello am having a Bottom Sheet Dialog Fragment that is show when an item in a recyclerview is clicked. The showing of the bottom sheet implementation is in an adapter for the recyclerview. The problem am having is that when you quickly double tap on the items to show the bottom sheet it shows twice, is there a way to limit the tap to only one tap or not to show the bottom sheet dialog fragment again when it is being shown by checking
Here is how am showing the bottom sheet on item click in the recyclerview
@Override
public void onBindViewHolder(@NonNull final MyViewHolder myViewHolder, final int position) {
myViewHolder.cardView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
BottomSheetFragment bottomSheetFragment = new BottomSheetFragment();
Bundle bundle = new Bundle();
bundle.putInt("id",productList.get(position).getId());
bundle.putString("name",productList.get(position).getName());
bundle.putDouble("price",productList.get(position).getPrice());
bundle.putInt("stock",productList.get(position).getStock());
bundle.putInt("quantity",productList.get(position).getQuantity());
bundle.putString("photo",productList.get(position).getPhoto());
bottomSheetFragment.setArguments(bundle);
bottomSheetFragment.show(fragmentManager, bottomSheetFragment.getTag());
}
});
}
I have tried using Muhannad Fakhouri answer by doing the following
Declaring a boolean to show if BottomSheet is showing or not
private boolean isBottomSheetShowing = false;
Implementation in the bottom sheet
if(!isBottomSheetShowing){
isBottomSheetShowing = true;
ItemBottomSheet itemBottomSheet = new ItemBottomSheet();
Bundle bundle = new Bundle();
bundle.putString("code",itemPosition.getCode());
bundle.putString("name",itemPosition.getName());
bundle.putString("description",itemPosition.getDescription());
bundle.putString("upcCode",itemPosition.getUpcCode());
bundle.putString("photoBlob",itemPosition.getPhotoBlob());
bundle.putDouble("discount",itemPosition.getDiscount());
bundle.putDouble("price",itemPosition.getPrice());
bundle.putInt("available",itemPosition.getAvailable());
itemBottomSheet.setArguments(bundle);
itemBottomSheet.show(fragmentManager, itemBottomSheet.getTag());
}else{
isBottomSheetShowing = false;
}
The issue arrising now is that there is a time when nothing happens totally when i click on the item and then after i click the item again it shows