Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
(cherry picked from commit ce93f23)
  • Loading branch information
crackededed committed Dec 21, 2024
1 parent 322388f commit 9b43210
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 7 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ android {
applicationId = "com.github.andreyasadchy.xtra"
minSdk = 21
targetSdk = 35
versionCode = 270
versionName = "2.40.3"
versionCode = 271
versionName = "2.40.4"
}

buildTypes {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import androidx.fragment.app.viewModels
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
import androidx.navigation.fragment.navArgs
import androidx.paging.PagingData
import androidx.paging.PagingDataAdapter
import androidx.recyclerview.widget.RecyclerView
Expand All @@ -21,7 +20,6 @@ import com.github.andreyasadchy.xtra.model.ui.Video
import com.github.andreyasadchy.xtra.ui.common.FragmentHost
import com.github.andreyasadchy.xtra.ui.common.Scrollable
import com.github.andreyasadchy.xtra.ui.common.Sortable
import com.github.andreyasadchy.xtra.ui.games.GamePagerFragmentArgs
import com.github.andreyasadchy.xtra.ui.videos.BaseVideosAdapter
import com.github.andreyasadchy.xtra.ui.videos.BaseVideosFragment
import com.github.andreyasadchy.xtra.ui.videos.VideosAdapter
Expand All @@ -41,7 +39,6 @@ class FollowedVideosFragment : BaseVideosFragment(), Scrollable, Sortable, Video

private var _binding: CommonRecyclerViewLayoutBinding? = null
private val binding get() = _binding!!
private val args: GamePagerFragmentArgs by navArgs()
private val viewModel: FollowedVideosViewModel by viewModels()
private lateinit var pagingAdapter: PagingDataAdapter<Video, out RecyclerView.ViewHolder>

Expand All @@ -65,7 +62,7 @@ class FollowedVideosFragment : BaseVideosFragment(), Scrollable, Sortable, Video
override fun initialize() {
viewLifecycleOwner.lifecycleScope.launch {
if (viewModel.filter.value == null) {
val sortValues = args.channelId?.let { viewModel.getSortChannel(it)?.takeIf { it.saveSort == true } } ?: viewModel.getSortChannel("followed_videos")
val sortValues = viewModel.getSortChannel("followed_videos")
viewModel.setFilter(
sort = sortValues?.videoSort,
type = sortValues?.videoType,
Expand Down Expand Up @@ -96,6 +93,7 @@ class FollowedVideosFragment : BaseVideosFragment(), Scrollable, Sortable, Video
sortBar.root.setOnClickListener {
VideosSortDialog.newInstance(
sort = viewModel.sort,
period = viewModel.period,
type = viewModel.type,
saveDefault = requireContext().prefs().getBoolean(C.SORT_DEFAULT_FOLLOWED_VIDEOS, false)
).show(childFragmentManager, null)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ class FollowedVideosViewModel @Inject constructor(

val sort: String
get() = filter.value?.sort ?: VideosSortDialog.SORT_TIME
val period: String
get() = filter.value?.period ?: VideosSortDialog.PERIOD_ALL
val type: String
get() = filter.value?.type ?: VideosSortDialog.VIDEO_TYPE_ALL

Expand Down Expand Up @@ -83,11 +85,12 @@ class FollowedVideosViewModel @Inject constructor(
}

fun setFilter(sort: String?, type: String?) {
filter.value = Filter(sort, type)
filter.value = Filter(sort, null, type)
}

class Filter(
val sort: String?,
val period: String?,
val type: String?,
)
}

0 comments on commit 9b43210

Please sign in to comment.