Load channels only once

This commit is contained in:
Bnyro 2022-05-16 17:33:22 +02:00
parent 6a69fef2b6
commit a3cec2027c
2 changed files with 8 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import androidx.recyclerview.widget.RecyclerView
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout import androidx.swiperefreshlayout.widget.SwipeRefreshLayout
import com.github.libretube.adapters.SubscriptionAdapter import com.github.libretube.adapters.SubscriptionAdapter
import com.github.libretube.adapters.SubscriptionChannelAdapter import com.github.libretube.adapters.SubscriptionChannelAdapter
import org.chromium.base.ThreadUtils.runOnUiThread
import retrofit2.HttpException import retrofit2.HttpException
import java.io.IOException import java.io.IOException
@ -67,10 +68,14 @@ class Subscriptions : Fragment() {
var toggleSubs = view.findViewById<RelativeLayout>(R.id.toggle_subs) var toggleSubs = view.findViewById<RelativeLayout>(R.id.toggle_subs)
toggleSubs.visibility = View.VISIBLE toggleSubs.visibility = View.VISIBLE
var loadedSubbedChannels = false
toggleSubs.setOnClickListener { toggleSubs.setOnClickListener {
if (!channelRecView.isVisible) { if (!channelRecView.isVisible) {
channelRecView?.layoutManager = GridLayoutManager(context, 4) if (!loadedSubbedChannels) {
fetchChannels(channelRecView) channelRecView?.layoutManager = GridLayoutManager(context, 4)
fetchChannels(channelRecView)
loadedSubbedChannels = true
}
channelRecView.visibility = View.VISIBLE channelRecView.visibility = View.VISIBLE
feedRecView.visibility = View.GONE feedRecView.visibility = View.GONE
} }

View File

@ -58,7 +58,7 @@
android:id="@+id/toggle_subs" android:id="@+id/toggle_subs"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:layout_margin="10dp" android:layout_margin="12dp"
android:visibility="gone"> android:visibility="gone">
<TextView <TextView