fix the calculation that incorrectly sets the number of columns to display

This commit is contained in:
Kai 2024-12-08 16:47:13 -06:00
parent 7c9e9d5f52
commit 23afe7994c
No known key found for this signature in database
4 changed files with 7 additions and 4 deletions

View file

@ -33,6 +33,7 @@ import com.futo.platformplayer.views.overlays.slideup.SlideUpMenuItem
import com.futo.platformplayer.views.overlays.slideup.SlideUpMenuOverlay
import com.futo.platformplayer.withTimestamp
import kotlin.math.floor
import kotlin.math.max
abstract class ContentFeedView<TFragment> : FeedView<TFragment, IPlatformContent, IPlatformContent, IPager<IPlatformContent>, ContentPreviewViewHolder> where TFragment : MainFragment {
private var _exoPlayer: PlayerManager? = null;
@ -168,7 +169,7 @@ abstract class ContentFeedView<TFragment> : FeedView<TFragment, IPlatformContent
val glmResults =
GridLayoutManager(
context,
(resources.configuration.screenWidthDp / resources.getDimension(R.dimen.landscape_threshold)).toInt() + 1
max((resources.configuration.screenWidthDp.toDouble() / resources.getInteger(R.integer.landscape_threshold)).toInt(), 1)
);
return glmResults
}

View file

@ -30,6 +30,7 @@ import kotlinx.coroutines.CancellationException
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import java.time.OffsetDateTime
import kotlin.math.max
abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : LinearLayout where TPager : IPager<TResult>, TViewHolder : RecyclerView.ViewHolder, TFragment : MainFragment {
protected val _recyclerResults: RecyclerView;
@ -234,7 +235,8 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
}
open fun updateSpanCount() {
recyclerData.layoutManager.spanCount = (resources.configuration.screenWidthDp / resources.getDimension(R.dimen.landscape_threshold)).toInt() + 1
recyclerData.layoutManager.spanCount =
max((resources.configuration.screenWidthDp.toDouble() / resources.getInteger(R.integer.landscape_threshold)).toInt(), 1)
}
override fun onConfigurationChanged(newConfig: Configuration?) {

View file

@ -91,7 +91,7 @@ class VideoDetailFragment : MainFragment {
return min(
resources.configuration.screenWidthDp,
resources.configuration.screenHeightDp
) < resources.getDimension(R.dimen.landscape_threshold)
) < resources.getInteger(R.integer.landscape_threshold) * 2
}
override fun onConfigurationChanged(newConfig: Configuration) {

View file

@ -2,5 +2,5 @@
<resources>
<dimen name="minimized_player_max_width">500dp</dimen>
<dimen name="app_bar_height">200dp</dimen>
<dimen name="landscape_threshold">300dp</dimen>
<integer name="landscape_threshold">400</integer>
</resources>