minor bug fix

This commit is contained in:
LagradOst 2021-12-11 01:26:54 +01:00
parent 49a91328d8
commit 6291933533
4 changed files with 7 additions and 7 deletions

View file

@ -47,7 +47,7 @@ class APIRepository(val api: MainAPI) {
}
}
suspend fun getMainPage(): Resource<HomePageResponse> {
suspend fun getMainPage(): Resource<HomePageResponse?> {
return safeApiCall {
api.getMainPage() ?: throw ErrorLoadingException()
}

View file

@ -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()

View file

@ -37,8 +37,8 @@ class HomeViewModel : ViewModel() {
private val _apiName = MutableLiveData<String>()
val apiName: LiveData<String> = _apiName
private val _page = MutableLiveData<Resource<HomePageResponse>>()
val page: LiveData<Resource<HomePageResponse>> = _page
private val _page = MutableLiveData<Resource<HomePageResponse?>>()
val page: LiveData<Resource<HomePageResponse?>> = _page
private val _randomItems = MutableLiveData<List<SearchResponse>?>(null)
val randomItems: LiveData<List<SearchResponse>?> = _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 }

View file

@ -357,7 +357,7 @@ class ResultFragment : Fragment() {
var currentSubs: HashMap<String, SubtitleFile>? = 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
)