Added text for FeedView which allows users to be informed what to do when sub feed is empty.

This commit is contained in:
Koen 2023-10-20 14:14:02 +02:00
parent 12b73bb248
commit bd48aba8d3
3 changed files with 40 additions and 13 deletions

View file

@ -39,6 +39,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
private val _spinnerSortBy: Spinner;
private val _containerSortBy: LinearLayout;
private val _tagsView: TagsView;
private val _textCentered: TextView;
protected val _toolbarContentView: LinearLayout;
@ -68,6 +69,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
this.fragment = fragment;
inflater.inflate(R.layout.fragment_feed, this);
_textCentered = findViewById(R.id.text_centered);
_progress_bar = findViewById(R.id.progress_bar);
_progress_bar.inactiveColor = Color.TRANSPARENT;
@ -169,6 +171,10 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
_recyclerResults.addOnScrollListener(_scrollListener);
}
protected fun setTextCentered(text: String?) {
_textCentered.text = text;
}
fun onResume() {
//Reload the pager if the plugin was killed
val pager = recyclerData.pager;

View file

@ -13,6 +13,7 @@ import com.futo.platformplayer.api.media.models.contents.ContentType
import com.futo.platformplayer.api.media.models.contents.IPlatformContent
import com.futo.platformplayer.api.media.models.video.IPlatformVideo
import com.futo.platformplayer.api.media.platforms.js.JSClient
import com.futo.platformplayer.api.media.structures.EmptyPager
import com.futo.platformplayer.api.media.structures.IPager
import com.futo.platformplayer.cache.ChannelContentCache
import com.futo.platformplayer.constructs.TaskHandler
@ -280,8 +281,12 @@ class SubscriptionsFeedFragment : MainFragment() {
Logger.i(TAG, "Subscriptions load");
if(recyclerData.results.size == 0) {
val cachePager = ChannelContentCache.instance.getSubscriptionCachePager();
Logger.i(TAG, "Subscription show cache (${cachePager.getResults().size})");
val results = cachePager.getResults();
Logger.i(TAG, "Subscription show cache (${results.size})");
setTextCentered(if (results.isEmpty()) "No results found\nSwipe down to refresh" else null);
setPager(cachePager);
} else {
setTextCentered(null);
}
_taskGetPager.run(withRefetch);
}
@ -294,6 +299,7 @@ class SubscriptionsFeedFragment : MainFragment() {
finishRefreshLayoutLoader();
setLoading(false);
setPager(pager);
setTextCentered(if (pager.getResults().isEmpty()) "No results found\nSwipe down to refresh" else null);
} catch (e: Throwable) {
Logger.e(TAG, "Failed to finish loading", e)
}

View file

@ -76,22 +76,37 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior">
<LinearLayout
android:orientation="vertical"
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<com.futo.platformplayer.views.others.ProgressBar
android:id="@+id/progress_bar"
android:layout_height="match_parent">
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="0dp" />
android:layout_height="wrap_content">
<com.futo.platformplayer.views.others.ProgressBar
android:id="@+id/progress_bar"
android:layout_width="match_parent"
android:layout_height="0dp" />
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</LinearLayout>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/list_results"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" />
</LinearLayout>
<TextView
android:id="@+id/text_centered"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="20dp"
android:layout_marginEnd="20dp"
android:fontFamily="@font/inter_regular"
android:gravity="center"
android:textColor="@color/gray_ac"
android:textSize="12dp" />
</FrameLayout>
</androidx.swiperefreshlayout.widget.SwipeRefreshLayout>
</androidx.coordinatorlayout.widget.CoordinatorLayout>