Fix crash on Emulator and TV

This commit is contained in:
Luna712 2024-07-11 17:26:07 -06:00 committed by GitHub
parent c9567c9694
commit 145482a32f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 221 additions and 236 deletions

View file

@ -112,6 +112,7 @@ class DownloadChildFragment : Fragment() {
if (!isMultiDeleteState) { if (!isMultiDeleteState) {
detachBackPressedCallback() detachBackPressedCallback()
downloadsViewModel.clearSelectedItems() downloadsViewModel.clearSelectedItems()
binding?.downloadChildToolbar?.isVisible = true
} }
} }
observe(downloadsViewModel.selectedBytes) { observe(downloadsViewModel.selectedBytes) {
@ -161,6 +162,7 @@ class DownloadChildFragment : Fragment() {
private fun handleSelectedChange(selected: MutableList<VisualDownloadCached>) { private fun handleSelectedChange(selected: MutableList<VisualDownloadCached>) {
if (selected.isNotEmpty()) { if (selected.isNotEmpty()) {
binding?.downloadDeleteAppbar?.isVisible = true binding?.downloadDeleteAppbar?.isVisible = true
binding?.downloadChildToolbar?.isVisible = false
activity?.attachBackPressedCallback { activity?.attachBackPressedCallback {
downloadsViewModel.setIsMultiDeleteState(false) downloadsViewModel.setIsMultiDeleteState(false)
} }

View file

@ -7,98 +7,87 @@
android:layout_height="match_parent" android:layout_height="match_parent"
android:background="?attr/primaryGrayBackground" android:background="?attr/primaryGrayBackground"
android:orientation="vertical" android:orientation="vertical"
tools:context=".ui.download.DownloadFragment"> tools:context=".ui.download.DownloadChildFragment">
<com.google.android.material.appbar.AppBarLayout <com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@android:color/transparent"> android:background="@android:color/transparent">
<FrameLayout <LinearLayout
android:id="@+id/download_delete_appbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?attr/colorPrimary"
android:padding="8dp"
android:visibility="gone">
<LinearLayout <ImageView
android:id="@+id/download_delete_appbar" android:id="@+id/btnCancel"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:background="?attr/selectableItemBackground"
android:background="?attr/colorPrimary" android:src="@drawable/ic_baseline_close_24"
android:contentDescription="@string/cancel"
android:padding="8dp" android:padding="8dp"
android:visibility="gone" android:layout_gravity="center_vertical"
android:elevation="100dp"> app:tint="@android:color/white" />
<ImageView <Button
android:id="@+id/btnCancel" android:id="@+id/btnDelete"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_baseline_close_24" android:text="@string/delete"
android:contentDescription="@string/cancel" android:textColor="@android:color/white"
android:padding="8dp" android:layout_gravity="center_vertical" />
android:layout_gravity="center_vertical"
app:tint="@android:color/white" />
<Button <TextView
android:id="@+id/btnDelete" android:id="@+id/selectItemsText"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:text="@string/delete" android:text="@string/downloads_delete_select"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:layout_gravity="center_vertical" /> android:layout_gravity="center_vertical"
android:visibility="gone" />
<TextView <View
android:id="@+id/selectItemsText" android:layout_width="0dp"
android:layout_width="wrap_content" android:layout_height="0dp"
android:layout_height="wrap_content" android:layout_weight="1" />
android:background="?attr/selectableItemBackground"
android:text="@string/downloads_delete_select"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<View <Button
android:layout_width="0dp" android:id="@+id/btnSelectAll"
android:layout_height="0dp" android:layout_width="wrap_content"
android:layout_weight="1" /> android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/select_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp" />
<Button <Button
android:id="@+id/btnSelectAll" android:id="@+id/btnDeselectAll"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/selectableItemBackground"
android:text="@string/select_all" android:text="@string/deselect_all"
android:textColor="@android:color/white" android:textColor="@android:color/white"
android:layout_marginEnd="8dp" /> android:layout_marginEnd="8dp"
android:visibility="gone" />
</LinearLayout>
<Button <com.google.android.material.appbar.MaterialToolbar
android:id="@+id/btnDeselectAll" android:id="@+id/download_child_toolbar"
android:layout_width="wrap_content" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground" android:background="?attr/primaryGrayBackground"
android:text="@string/deselect_all" android:paddingTop="@dimen/navbar_height"
android:textColor="@android:color/white" app:layout_scrollFlags="scroll|enterAlways"
android:layout_marginEnd="8dp" app:navigationIconTint="?attr/iconColor"
android:visibility="gone" /> app:titleTextColor="?attr/textColor"
</LinearLayout> tools:title="Overlord" />
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.google.android.material.appbar.MaterialToolbar
android:id="@+id/download_child_toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/primaryGrayBackground"
android:paddingTop="@dimen/navbar_height"
app:layout_scrollFlags="scroll|enterAlways"
app:navigationIconTint="?attr/iconColor"
app:titleTextColor="?attr/textColor"
tools:title="Overlord" />
</LinearLayout>
</FrameLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView

View file

@ -17,185 +17,179 @@
For Scroll add to LinearLayout For Scroll add to LinearLayout
app:layout_scrollFlags="scroll|enterAlways" app:layout_scrollFlags="scroll|enterAlways"
--> -->
<LinearLayout
<FrameLayout android:id="@+id/download_delete_appbar"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content"> android:layout_height="wrap_content"
android:orientation="horizontal"
android:background="?attr/colorPrimary"
android:padding="8dp"
android:visibility="gone">
<LinearLayout <ImageView
android:id="@+id/download_delete_appbar" android:id="@+id/btnCancel"
android:layout_width="match_parent" android:layout_width="wrap_content"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:orientation="horizontal" android:background="?attr/selectableItemBackground"
android:background="?attr/colorPrimary" android:src="@drawable/ic_baseline_close_24"
android:contentDescription="@string/cancel"
android:padding="8dp" android:padding="8dp"
android:visibility="gone"> android:layout_gravity="center_vertical"
app:tint="@android:color/white" />
<ImageView <Button
android:id="@+id/btnCancel" android:id="@+id/btnDelete"
android:layout_width="wrap_content" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:src="@drawable/ic_baseline_close_24"
android:contentDescription="@string/cancel"
android:padding="8dp"
android:layout_gravity="center_vertical"
app:tint="@android:color/white" />
<Button
android:id="@+id/btnDelete"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/delete"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical" />
<TextView
android:id="@+id/selectItemsText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/downloads_delete_select"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<View
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_weight="1" />
<Button
android:id="@+id/btnSelectAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/select_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp" />
<Button
android:id="@+id/btnDeselectAll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/deselect_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp"
android:visibility="gone" />
</LinearLayout>
<LinearLayout
android:id="@+id/download_storage_appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:background="?attr/selectableItemBackground"
android:orientation="vertical" android:text="@string/delete"
android:visibility="gone" android:textColor="@android:color/white"
tools:visibility="visible"> android:layout_gravity="center_vertical" />
<TextView <TextView
android:layout_width="wrap_content" android:id="@+id/selectItemsText"
android:layout_height="wrap_content" android:layout_width="wrap_content"
android:layout_marginBottom="5dp" android:layout_height="wrap_content"
android:text="@string/download_storage_text" android:background="?attr/selectableItemBackground"
android:textColor="?attr/textColor" /> android:text="@string/downloads_delete_select"
android:textColor="@android:color/white"
android:layout_gravity="center_vertical"
android:visibility="gone" />
<androidx.cardview.widget.CardView <View
android:layout_width="fill_parent" android:layout_width="0dp"
android:layout_height="12dp" android:layout_height="0dp"
android:layout_marginBottom="5dp" android:layout_weight="1" />
android:elevation="0dp"
app:cardCornerRadius="@dimen/storage_radius"
app:cardElevation="0dp"
app:cardMaxElevation="0dp">
<LinearLayout <Button
android:layout_width="match_parent" android:id="@+id/btnSelectAll"
android:layout_height="match_parent" android:layout_width="wrap_content"
android:orientation="horizontal"> android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:text="@string/select_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp" />
<View <Button
android:id="@+id/download_used" android:id="@+id/btnDeselectAll"
android:layout_width="0dp" android:layout_width="wrap_content"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="0.5" android:background="?attr/selectableItemBackground"
android:background="@drawable/storage_bar_left" /> android:text="@string/deselect_all"
android:textColor="@android:color/white"
android:layout_marginEnd="8dp"
android:visibility="gone" />
</LinearLayout>
<View <LinearLayout
android:id="@+id/download_app" android:id="@+id/download_storage_appbar"
android:layout_width="0dp" android:layout_width="match_parent"
android:layout_height="match_parent" android:layout_height="wrap_content"
android:layout_weight="0.10" android:layout_margin="10dp"
android:background="@drawable/storage_bar_mid" /> android:orientation="vertical"
android:visibility="gone"
tools:visibility="visible">
<View <TextView
android:id="@+id/download_free" android:layout_width="wrap_content"
android:layout_width="0dp" android:layout_height="wrap_content"
android:layout_height="match_parent" android:layout_marginBottom="5dp"
android:layout_weight="0.10" android:text="@string/download_storage_text"
android:background="@drawable/storage_bar_right" /> android:textColor="?attr/textColor" />
</LinearLayout>
</androidx.cardview.widget.CardView> <androidx.cardview.widget.CardView
android:layout_width="fill_parent"
android:layout_height="12dp"
android:layout_marginBottom="5dp"
android:elevation="0dp"
app:cardCornerRadius="@dimen/storage_radius"
app:cardElevation="0dp"
app:cardMaxElevation="0dp">
<LinearLayout <LinearLayout
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="match_parent"
android:orientation="horizontal"> android:orientation="horizontal">
<View <View
android:layout_width="10dp" android:id="@+id/download_used"
android:layout_height="10dp" android:layout_width="0dp"
android:layout_gravity="center_vertical" android:layout_height="match_parent"
android:layout_marginTop="5dp" android:layout_weight="0.5"
android:layout_marginEnd="5dp" android:background="@drawable/storage_bar_left" />
android:layout_marginBottom="5dp"
android:background="@drawable/storage_bar_left_box" />
<TextView
android:id="@+id/download_used_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Used • 30.58GB" />
<View <View
android:layout_width="10dp" android:id="@+id/download_app"
android:layout_height="10dp" android:layout_width="0dp"
android:layout_gravity="center_vertical" android:layout_height="match_parent"
android:layout_margin="5dp" android:layout_weight="0.10"
android:background="@drawable/storage_bar_mid_box" /> android:background="@drawable/storage_bar_mid" />
<TextView
android:id="@+id/download_app_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="App • 30.58GB" />
<View <View
android:layout_width="10dp" android:id="@+id/download_free"
android:layout_height="10dp" android:layout_width="0dp"
android:layout_gravity="center_vertical" android:layout_height="match_parent"
android:layout_margin="5dp" android:layout_weight="0.10"
android:background="@drawable/storage_bar_right_box" /> android:background="@drawable/storage_bar_right" />
<TextView
android:id="@+id/download_free_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Free • 30.58GB" />
</LinearLayout> </LinearLayout>
</androidx.cardview.widget.CardView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_marginTop="5dp"
android:layout_marginEnd="5dp"
android:layout_marginBottom="5dp"
android:background="@drawable/storage_bar_left_box" />
<TextView
android:id="@+id/download_used_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Used • 30.58GB" />
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="@drawable/storage_bar_mid_box" />
<TextView
android:id="@+id/download_app_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="App • 30.58GB" />
<View
android:layout_width="10dp"
android:layout_height="10dp"
android:layout_gravity="center_vertical"
android:layout_margin="5dp"
android:background="@drawable/storage_bar_right_box" />
<TextView
android:id="@+id/download_free_txt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:textColor="?attr/textColor"
android:textSize="12sp"
tools:text="Free • 30.58GB" />
</LinearLayout> </LinearLayout>
</FrameLayout> </LinearLayout>
</com.google.android.material.appbar.AppBarLayout> </com.google.android.material.appbar.AppBarLayout>
<androidx.recyclerview.widget.RecyclerView <androidx.recyclerview.widget.RecyclerView
@ -224,11 +218,11 @@
<!-- <!--
<ProgressBar <ProgressBar
android:visibility="visible" android:visibility="visible"
tools:visibility="gone" tools:visibility="gone"
android:id="@+id/download_loading" android:id="@+id/download_loading"
android:layout_gravity="center" android:layout_gravity="center"
android:layout_width="50dp" android:layout_height="50dp"> android:layout_width="50dp" android:layout_height="50dp">
</ProgressBar>--> </ProgressBar>-->
<com.facebook.shimmer.ShimmerFrameLayout <com.facebook.shimmer.ShimmerFrameLayout