I am having two Bottom Sheet Dialog Fragment layouts which I have included in a CoordinatorLayout
. The CoordinatorLayout
has a RecyclerView
whose items show one Bottom Sheet dialog fragment upon being clicked. The first bottom sheet dialog fragment is used to update the items of the recycler view. The second Bottom Sheet Dialog Fragment is used to perform a payment of the items. The issue am having is that when i show the second Bottom Sheet for payment and mistakenly click on the items the 1st bottom sheet comes below the second. Is there a way i can set the first bottom sheet dialog to be disabled or visibility set to gone like in buttons when the second bottom sheet is shown
Here is my XML
<androidx.coordinatorlayout.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Activities.CartActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay">
<androidx.appcompat.widget.Toolbar
android:id="@+id/cart_tool_bar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="?attr/colorPrimary"
app:popupTheme="@style/AppTheme.PopupOverlay"/>
</com.google.android.material.appbar.AppBarLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/colorWhiteShade">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/cart_recycler_view"
android:layout_width="match_parent"
android:layout_height="match_parent"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/colorWhiteDarker"
android:padding="5dp"
android:orientation="vertical">
<androidx.cardview.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardCornerRadius="5dp"
android:layout_margin="2dp"
android:padding="5dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="5dp">
<TextView
android:id="@+id/tv_sub_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_total"
android:textSize="20sp"
style="@style/TextAppearance.AppCompat.Large"/>
<TextView
android:id="@+id/sub_total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/sub_total"
style="@style/TextAppearance.AppCompat.Body1"
android:textStyle="bold"
android:layout_alignParentEnd="true"
android:textSize="17sp"
/>
<View
android:id="@+id/view"
android:layout_centerHorizontal="true"
android:layout_width="350dp"
android:layout_height="1dp"
android:background="@color/colorBlack20"
android:layout_margin="2dp"
android:layout_below="@id/sub_total"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/view"
android:layout_margin="2dp"
android:padding="2dp"
android:gravity="center"
android:orientation="horizontal">
<Button
android:id="@+id/btn_post_payment"
android:layout_width="wrap_content"
android:layout_height="35dp"
android:drawableStart="@drawable/pay_icon"
android:text="@string/pay"
android:background="@drawable/ripple"
android:layout_marginStart="2dp"
android:layout_marginEnd="2dp"
android:textColor="@android:color/white"
android:padding="5dp"
style="?attr/borderlessButtonStyle"
android:textAllCaps="false"/>
</LinearLayout>
</RelativeLayout>
</androidx.cardview.widget.CardView>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<!-- Always include layout below all the other layouts -->
<include layout="@layout/layout_cart_bottom_sheet"/>
<!-- Always include layout below all the other layouts -->
<include layout="@layout/layout_post_payment"/>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
Another implementation that i may like is if the 1st dialog can check if the second dialog is already showing and prevent it from showing again