mirror of
				https://github.com/recloudstream/cloudstream.git
				synced 2024-08-15 01:53:11 +00:00 
			
		
		
		
	Fix no downloads message display
This commit is contained in:
		
							parent
							
								
									96ed04f7cd
								
							
						
					
					
						commit
						aa332ab809
					
				
					 5 changed files with 13 additions and 29 deletions
				
			
		|  | @ -35,6 +35,7 @@ class DownloadChildFragment : Fragment() { | ||||||
| 
 | 
 | ||||||
|     override fun onDestroyView() { |     override fun onDestroyView() { | ||||||
|         downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent -= it } |         downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent -= it } | ||||||
|  |         downloadDeleteEventListener = null | ||||||
|         binding = null |         binding = null | ||||||
|         super.onDestroyView() |         super.onDestroyView() | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | @ -35,7 +35,6 @@ import com.lagradost.cloudstream3.ui.result.setLinearListLayout | ||||||
| import com.lagradost.cloudstream3.ui.settings.Globals.TV | import com.lagradost.cloudstream3.ui.settings.Globals.TV | ||||||
| import com.lagradost.cloudstream3.ui.settings.Globals.isLayout | import com.lagradost.cloudstream3.ui.settings.Globals.isLayout | ||||||
| import com.lagradost.cloudstream3.utils.AppUtils.loadResult | import com.lagradost.cloudstream3.utils.AppUtils.loadResult | ||||||
| import com.lagradost.cloudstream3.utils.Coroutines.main |  | ||||||
| import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE | import com.lagradost.cloudstream3.utils.DOWNLOAD_EPISODE_CACHE | ||||||
| import com.lagradost.cloudstream3.utils.DataStore | import com.lagradost.cloudstream3.utils.DataStore | ||||||
| import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe | import com.lagradost.cloudstream3.utils.UIHelper.dismissSafe | ||||||
|  | @ -60,16 +59,8 @@ class DownloadFragment : Fragment() { | ||||||
|         this.layoutParams = param |         this.layoutParams = param | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     private fun setList(list: List<VisualDownloadHeaderCached>) { |  | ||||||
|         main { |  | ||||||
|             (binding?.downloadList?.adapter as? DownloadAdapter)?.submitList(list) |  | ||||||
|         } |  | ||||||
|     } |  | ||||||
| 
 |  | ||||||
|     override fun onDestroyView() { |     override fun onDestroyView() { | ||||||
|         downloadDeleteEventListener?.let { |         downloadDeleteEventListener?.let { VideoDownloadManager.downloadDeleteEvent -= it } | ||||||
|             VideoDownloadManager.downloadDeleteEvent -= it |  | ||||||
|         } |  | ||||||
|         downloadDeleteEventListener = null |         downloadDeleteEventListener = null | ||||||
|         binding = null |         binding = null | ||||||
|         super.onDestroyView() |         super.onDestroyView() | ||||||
|  | @ -95,12 +86,10 @@ class DownloadFragment : Fragment() { | ||||||
|         hideKeyboard() |         hideKeyboard() | ||||||
|         binding?.downloadStorageAppbar?.setAppBarNoScrollFlagsOnTV() |         binding?.downloadStorageAppbar?.setAppBarNoScrollFlagsOnTV() | ||||||
| 
 | 
 | ||||||
|         observe(downloadsViewModel.noDownloadsText) { |  | ||||||
|             binding?.textNoDownloads?.text = it |  | ||||||
|         } |  | ||||||
|         observe(downloadsViewModel.headerCards) { |         observe(downloadsViewModel.headerCards) { | ||||||
|             setList(it) |             (binding?.downloadList?.adapter as? DownloadAdapter)?.submitList(it) | ||||||
|             binding?.downloadLoading?.isVisible = false |             binding?.downloadLoading?.isVisible = false | ||||||
|  |             binding?.textNoDownloads?.isVisible = it.isEmpty() | ||||||
|         } |         } | ||||||
|         observe(downloadsViewModel.availableBytes) { |         observe(downloadsViewModel.availableBytes) { | ||||||
|             updateStorageInfo(view.context, it, R.string.free_storage, binding?.downloadFreeTxt, binding?.downloadFree) |             updateStorageInfo(view.context, it, R.string.free_storage, binding?.downloadFreeTxt, binding?.downloadFree) | ||||||
|  |  | ||||||
|  | @ -21,11 +21,6 @@ import kotlinx.coroutines.Dispatchers | ||||||
| import kotlinx.coroutines.withContext | import kotlinx.coroutines.withContext | ||||||
| 
 | 
 | ||||||
| class DownloadViewModel : ViewModel() { | class DownloadViewModel : ViewModel() { | ||||||
|     private val _noDownloadsText = MutableLiveData<String>().apply { |  | ||||||
|         value = "" |  | ||||||
|     } |  | ||||||
|     val noDownloadsText: LiveData<String> = _noDownloadsText |  | ||||||
| 
 |  | ||||||
|     private val _headerCards = |     private val _headerCards = | ||||||
|         MutableLiveData<List<VisualDownloadHeaderCached>>().apply { listOf<VisualDownloadHeaderCached>() } |         MutableLiveData<List<VisualDownloadHeaderCached>>().apply { listOf<VisualDownloadHeaderCached>() } | ||||||
|     val headerCards: LiveData<List<VisualDownloadHeaderCached>> = _headerCards |     val headerCards: LiveData<List<VisualDownloadHeaderCached>> = _headerCards | ||||||
|  |  | ||||||
|  | @ -143,17 +143,15 @@ | ||||||
| 
 | 
 | ||||||
|     <TextView |     <TextView | ||||||
|         android:id="@+id/text_no_downloads" |         android:id="@+id/text_no_downloads" | ||||||
|         android:layout_width="match_parent" |         android:layout_width="wrap_content" | ||||||
|         android:layout_height="wrap_content" |         android:layout_height="wrap_content" | ||||||
|         android:layout_marginStart="8dp" |         android:layout_gravity="center" | ||||||
|         android:layout_marginTop="8dp" |         android:layout_margin="30dp" | ||||||
|         android:layout_marginEnd="8dp" |         android:text="@string/downloads_empty" | ||||||
|         android:textAlignment="center" |         android:textSize="15sp" | ||||||
|         android:textSize="20sp" |         android:gravity="center" | ||||||
|         app:layout_constraintBottom_toBottomOf="parent" |         android:visibility="gone" | ||||||
|         app:layout_constraintEnd_toEndOf="parent" |         tools:visibility="visible" /> | ||||||
|         app:layout_constraintStart_toStartOf="parent" |  | ||||||
|         app:layout_constraintTop_toTopOf="parent" /> |  | ||||||
| 
 | 
 | ||||||
|     <!-- |     <!-- | ||||||
|     <ProgressBar |     <ProgressBar | ||||||
|  |  | ||||||
|  | @ -149,6 +149,7 @@ | ||||||
|     <string name="download_canceled">Download Canceled</string> |     <string name="download_canceled">Download Canceled</string> | ||||||
|     <string name="download_done">Download Done</string> |     <string name="download_done">Download Done</string> | ||||||
|     <string name="download_format" translatable="false">%s - %s</string> |     <string name="download_format" translatable="false">%s - %s</string> | ||||||
|  |     <string name="downloads_empty">You currently don\'t have any downloads.</string> | ||||||
|     <string name="update_started">Update Started</string> |     <string name="update_started">Update Started</string> | ||||||
|     <string name="stream">Network stream</string> |     <string name="stream">Network stream</string> | ||||||
|     <string name="error_loading_links_toast">Error Loading Links</string> |     <string name="error_loading_links_toast">Error Loading Links</string> | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue