Fixed some small issues
This commit is contained in:
parent
bc29f40d69
commit
1dd0930b83
3 changed files with 11 additions and 19 deletions
|
@ -40,7 +40,6 @@ import androidx.appcompat.app.AlertDialog
|
||||||
import androidx.core.content.edit
|
import androidx.core.content.edit
|
||||||
import androidx.core.math.MathUtils
|
import androidx.core.math.MathUtils
|
||||||
import androidx.core.os.bundleOf
|
import androidx.core.os.bundleOf
|
||||||
import androidx.core.view.MenuItemCompat
|
|
||||||
import androidx.core.view.isVisible
|
import androidx.core.view.isVisible
|
||||||
import androidx.lifecycle.ViewModelProvider
|
import androidx.lifecycle.ViewModelProvider
|
||||||
import androidx.preference.PreferenceManager
|
import androidx.preference.PreferenceManager
|
||||||
|
@ -99,9 +98,6 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||||
private var oldestSubscriptionUpdate: OffsetDateTime? = null
|
private var oldestSubscriptionUpdate: OffsetDateTime? = null
|
||||||
|
|
||||||
private lateinit var groupAdapter: GroupieAdapter
|
private lateinit var groupAdapter: GroupieAdapter
|
||||||
@State @JvmField var showPlayedItems: Boolean = true
|
|
||||||
@State @JvmField var showPartiallyPlayedItems: Boolean = true
|
|
||||||
@State @JvmField var showFutureItems: Boolean = true
|
|
||||||
|
|
||||||
private var onSettingsChangeListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
private var onSettingsChangeListener: SharedPreferences.OnSharedPreferenceChangeListener? = null
|
||||||
private var updateListViewModeOnResume = false
|
private var updateListViewModeOnResume = false
|
||||||
|
@ -140,9 +136,6 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||||
|
|
||||||
val factory = FeedViewModel.getFactory(requireContext(), groupId)
|
val factory = FeedViewModel.getFactory(requireContext(), groupId)
|
||||||
viewModel = ViewModelProvider(this, factory)[FeedViewModel::class.java]
|
viewModel = ViewModelProvider(this, factory)[FeedViewModel::class.java]
|
||||||
showPlayedItems = viewModel.getShowPlayedItemsFromPreferences()
|
|
||||||
showPartiallyPlayedItems = viewModel.getShowPartiallyPlayedItemsFromPreferences()
|
|
||||||
showFutureItems = viewModel.getShowFutureItemsFromPreferences()
|
|
||||||
viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(::handleResult) }
|
viewModel.stateLiveData.observe(viewLifecycleOwner) { it?.let(::handleResult) }
|
||||||
|
|
||||||
groupAdapter = GroupieAdapter().apply {
|
groupAdapter = GroupieAdapter().apply {
|
||||||
|
@ -217,10 +210,6 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||||
activity.supportActionBar?.subtitle = groupName
|
activity.supportActionBar?.subtitle = groupName
|
||||||
|
|
||||||
inflater.inflate(R.menu.menu_feed_fragment, menu)
|
inflater.inflate(R.menu.menu_feed_fragment, menu)
|
||||||
MenuItemCompat.setTooltipText(
|
|
||||||
menu.findItem(R.id.menu_item_feed_toggle_played_items),
|
|
||||||
getString(R.string.feed_show_hide_streams)
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
|
@ -259,7 +248,11 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||||
getString(R.string.feed_show_upcoming)
|
getString(R.string.feed_show_upcoming)
|
||||||
)
|
)
|
||||||
|
|
||||||
val checkedDialogItems = booleanArrayOf(showPlayedItems, showPartiallyPlayedItems, showFutureItems)
|
val checkedDialogItems = booleanArrayOf(
|
||||||
|
viewModel.getShowPlayedItemsFromPreferences(),
|
||||||
|
viewModel.getShowPartiallyPlayedItemsFromPreferences(),
|
||||||
|
viewModel.getShowFutureItemsFromPreferences()
|
||||||
|
)
|
||||||
|
|
||||||
val builder = AlertDialog.Builder(context!!)
|
val builder = AlertDialog.Builder(context!!)
|
||||||
builder.setTitle(R.string.feed_hide_streams_title)
|
builder.setTitle(R.string.feed_hide_streams_title)
|
||||||
|
@ -268,14 +261,11 @@ class FeedFragment : BaseStateFragment<FeedState>() {
|
||||||
}
|
}
|
||||||
|
|
||||||
builder.setPositiveButton(R.string.ok) { _, _ ->
|
builder.setPositiveButton(R.string.ok) { _, _ ->
|
||||||
showPlayedItems = checkedDialogItems[0]
|
viewModel.setSaveShowPlayedItems(checkedDialogItems[0])
|
||||||
viewModel.setSaveShowPlayedItems(showPlayedItems)
|
|
||||||
|
|
||||||
showPartiallyPlayedItems = checkedDialogItems[1]
|
viewModel.setSaveShowPartiallyPlayedItems(checkedDialogItems[1])
|
||||||
viewModel.setSaveShowPartiallyPlayedItems(showPartiallyPlayedItems)
|
|
||||||
|
|
||||||
showFutureItems = checkedDialogItems[2]
|
viewModel.setSaveShowFutureItems(checkedDialogItems[2])
|
||||||
viewModel.setSaveShowFutureItems(showFutureItems)
|
|
||||||
}
|
}
|
||||||
builder.setNegativeButton(R.string.cancel, null)
|
builder.setNegativeButton(R.string.cancel, null)
|
||||||
|
|
||||||
|
|
|
@ -157,9 +157,11 @@ class FeedViewModel(
|
||||||
private fun getShowPartiallyPlayedItemsFromPreferences(context: Context) =
|
private fun getShowPartiallyPlayedItemsFromPreferences(context: Context) =
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
.getBoolean(context.getString(R.string.feed_show_partially_watched_items_key), true)
|
.getBoolean(context.getString(R.string.feed_show_partially_watched_items_key), true)
|
||||||
|
|
||||||
private fun getShowFutureItemsFromPreferences(context: Context) =
|
private fun getShowFutureItemsFromPreferences(context: Context) =
|
||||||
PreferenceManager.getDefaultSharedPreferences(context)
|
PreferenceManager.getDefaultSharedPreferences(context)
|
||||||
.getBoolean(context.getString(R.string.feed_show_future_items_key), true)
|
.getBoolean(context.getString(R.string.feed_show_future_items_key), true)
|
||||||
|
|
||||||
fun getFactory(context: Context, groupId: Long) = viewModelFactory {
|
fun getFactory(context: Context, groupId: Long) = viewModelFactory {
|
||||||
initializer {
|
initializer {
|
||||||
FeedViewModel(
|
FeedViewModel(
|
||||||
|
|
|
@ -283,7 +283,7 @@
|
||||||
|
|
||||||
<string name="feed_update_threshold_key">feed_update_threshold_key</string>
|
<string name="feed_update_threshold_key">feed_update_threshold_key</string>
|
||||||
<string name="feed_update_threshold_default_value">300</string>
|
<string name="feed_update_threshold_default_value">300</string>
|
||||||
<string name="feed_show_watched_items_key">feed_show_watched_items</string>
|
<string name="feed_show_watched_items_key">feed_show_played_items</string>
|
||||||
<string name="feed_show_partially_watched_items_key">feed_show_partially_watched_items</string>
|
<string name="feed_show_partially_watched_items_key">feed_show_partially_watched_items</string>
|
||||||
<string name="feed_show_future_items_key">feed_show_future_items</string>
|
<string name="feed_show_future_items_key">feed_show_future_items</string>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue