Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.lagradost.cloudstream3.ui.library

import android.content.Context
import android.view.LayoutInflater
import androidx.preference.PreferenceManager
import android.view.ViewGroup
import android.widget.FrameLayout
import androidx.core.view.isVisible
import com.lagradost.cloudstream3.R
import com.lagradost.cloudstream3.databinding.SearchResultGridExpandedBinding
import com.lagradost.cloudstream3.syncproviders.SyncAPI
import com.lagradost.cloudstream3.ui.AutofitRecyclerView
Expand All @@ -12,6 +15,7 @@ import com.lagradost.cloudstream3.ui.NoStateAdapter
import com.lagradost.cloudstream3.ui.ViewHolderState
import com.lagradost.cloudstream3.ui.search.SearchClickCallback
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import com.lagradost.cloudstream3.utils.UIHelper.getSpanCount
import kotlin.math.roundToInt

class PageAdapter(
Expand All @@ -27,6 +31,14 @@ class PageAdapter(
})) {
private val coverHeight: Int get() = (resView.itemWidth / 0.68).roundToInt()

companion object {
fun updatePosterSize(resView: AutofitRecyclerView?, context: Context, value: Int? = null) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense as a companion object function since you are affecting the PageAdapter's AutofitRecyclerView.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am SO sorry for my behavior and thank you so much for being patient with me, the next time i request a review, i wont disappoint, and im very new to open source and i dont wanna force my code into cloudstream, i will fix all of these in the next review.

val spanCount = value ?: PreferenceManager.getDefaultSharedPreferences(context)
.getInt(context.getString(R.string.library_poster_size_key), 3)
resView?.spanCount = spanCount
}
}

override fun onCreateContent(parent: ViewGroup): ViewHolderState<Any> {
return ViewHolderState(
SearchResultGridExpandedBinding.inflate(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,13 @@ class ViewpagerAdapter(
// Which is only determined after the recyclerview is attached.
// If this fails then item height becomes 0 when there is only one item
doOnAttach {
adapter = PageAdapter(
val pageAdapter = PageAdapter(
this,
clickCallback
).apply {
)
// Initialize poster size for this page
PageAdapter.updatePosterSize(this, this.context)
adapter = pageAdapter.apply {
submitList(item.items)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import com.lagradost.cloudstream3.ui.BasePreferenceFragmentCompat
import com.lagradost.cloudstream3.ui.clear
import com.lagradost.cloudstream3.ui.home.HomeChildItemAdapter
import com.lagradost.cloudstream3.ui.home.ParentItemAdapter
import com.lagradost.cloudstream3.ui.library.PageAdapter
import com.lagradost.cloudstream3.ui.search.SearchAdapter
import com.lagradost.cloudstream3.ui.search.SearchResultBuilder
import com.lagradost.cloudstream3.ui.settings.Globals.EMULATOR
Expand Down Expand Up @@ -65,6 +66,11 @@ class SettingsUI : BasePreferenceFragmentCompat() {
true
}

getPref(R.string.library_poster_size_key)?.setOnPreferenceChangeListener { _, newValue ->
context?.let { PageAdapter.updatePosterSize(null, it, newValue as? Int) }
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This makes no sense as a piece of code, it will only waste CPU cycles.

This will do null?.spanCount = newValue which is a no-op.

true
}

getPref(R.string.poster_ui_key)?.setOnPreferenceClickListener {
val prefNames = resources.getStringArray(R.array.poster_ui_options)
val keys = resources.getStringArray(R.array.poster_ui_options_values)
Expand Down
1 change: 1 addition & 0 deletions app/src/main/res/values/donottranslate-strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
<string name="poster_ui_key">poster_ui_key</string>
<string name="overscan_key">overscan_key</string>
<string name="poster_size_key">poster_size_key</string>
<string name="library_poster_size_key">library_poster_size</string>
<string name="subtitles_encoding_key">subtitles_encoding_key</string>
<string name="override_site_key">override_site_key</string>
<string name="redo_setup_key">redo_setup_key</string>
Expand Down
6 changes: 4 additions & 2 deletions app/src/main/res/values/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -743,8 +743,10 @@
</string>
<string name="overscan_settings_des">Changes the bounds of the screen</string>
<string name="overscan_settings">Overscan</string>
<string name="poster_size_settings_des">Changes size of posters</string>
<string name="poster_size_settings">Poster size</string>
<string name="poster_size_settings_des">Changes the number of poster columns</string>
<string name="poster_size_settings">Poster columns</string>
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is just false, poster size does not change the poster columns.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am sorry but that actually IS what i had the setting do, i swapped from size to column count which automatically resizes the posters, should i revert back to slider up > poster size increase?

Copy link
Copy Markdown
Collaborator

@fire-light42 fire-light42 Apr 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are confusing poster_size_settings and library_poster_size_settings.

You did swap the library poster setting, but you did not swap the normal poster setting. The normal poster setting does not change columns, it changes the size. You should therefore revert the changes to poster_size_settings and poster_size_settings_des.

<string name="library_poster_size_settings_des">Changes the number of library poster columns</string>
<string name="library_poster_size_settings">Library poster columns</string>
<string name="speedup_title">LongPress Speed Toggle</string>
<string name="speedup_summary">Hold to get 2x speed</string>
<string name="edit_profile_image_title">Edit Profile Image</string>
Expand Down
14 changes: 13 additions & 1 deletion app/src/main/res/xml/settings_ui.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
app:showSeekBarValue="true" />

<SeekBarPreference
android:defaultValue="0"
android:defaultValue="5"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why change the default value here?

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The duplicate defaultValue was already removed in a previous commit the current file only has one defaultValue per SeekBarPreference. Though im also confused as to why its not flagging this as outdated. Or maybe the change is too small to be flagged as outdated

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is not removed? You still have android:defaultValue="5", please change it back to 0. 😕

android:icon="@drawable/baseline_grid_view_24"
android:key="@string/poster_size_key"
android:max="15"
Expand All @@ -45,6 +45,18 @@
app:min="0"
app:seekBarIncrement="1"
app:showSeekBarValue="true" />

<SeekBarPreference
android:defaultValue="3"
android:icon="@drawable/baseline_grid_view_24"
android:key="@string/library_poster_size_key"
android:max="10"
android:summary="@string/library_poster_size_settings_des"
android:title="@string/library_poster_size_settings"
app:adjustable="true"
app:min="1"
app:seekBarIncrement="1"
app:showSeekBarValue="true" />
</PreferenceCategory>

<PreferenceCategory android:title="@string/pref_category_ui_features">
Expand Down