diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt index 7680abe2..99884f36 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/APIRepository.kt @@ -47,7 +47,7 @@ class APIRepository(val api: MainAPI) { } } - suspend fun getMainPage(): Resource { + suspend fun getMainPage(): Resource { return safeApiCall { api.getMainPage() ?: throw ErrorLoadingException() } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt index d8382be1..b7521193 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeFragment.kt @@ -254,14 +254,14 @@ class HomeFragment : Fragment() { currentHomePage = d (home_master_recycler?.adapter as ParentItemAdapter?)?.items = - d.items.mapNotNull { + d?.items?.mapNotNull { try { HomePageList(it.name, it.list.filterSearchResponse()) } catch (e: Exception) { logError(e) null } - } + } ?: listOf() home_master_recycler?.adapter?.notifyDataSetChanged() diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt index 10435b59..ff8a63db 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/home/HomeViewModel.kt @@ -37,8 +37,8 @@ class HomeViewModel : ViewModel() { private val _apiName = MutableLiveData() val apiName: LiveData = _apiName - private val _page = MutableLiveData>() - val page: LiveData> = _page + private val _page = MutableLiveData>() + val page: LiveData> = _page private val _randomItems = MutableLiveData?>(null) val randomItems: LiveData?> = _randomItems @@ -154,7 +154,7 @@ class HomeViewModel : ViewModel() { when (data) { is Resource.Success -> { val home = data.value - if (home.items.isNotEmpty()) { + if (home?.items?.isNullOrEmpty() == false) { val currentList = home.items.shuffled().filter { !it.list.isNullOrEmpty() }.flatMap { it.list } .distinctBy { it.url } diff --git a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt index bc239928..f6f9b876 100644 --- a/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt +++ b/app/src/main/java/com/lagradost/cloudstream3/ui/result/ResultFragment.kt @@ -357,7 +357,7 @@ class ResultFragment : Fragment() { var currentSubs: HashMap? = null val showTitle = - episodeClick.data.name ?: getString(R.string.episode_name_format).format( + episodeClick.data.name ?: context?.getString(R.string.episode_name_format)?.format( getString(R.string.episode), episodeClick.data.episode )