mirror of
https://gitlab.futo.org/videostreaming/grayjay.git
synced 2025-08-04 07:09:53 +00:00
Merge branch 'master' of gitlab.futo.org:videostreaming/grayjay
This commit is contained in:
commit
f344dbf35c
5 changed files with 69 additions and 15 deletions
|
@ -39,6 +39,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
||||||
private val _spinnerSortBy: Spinner;
|
private val _spinnerSortBy: Spinner;
|
||||||
private val _containerSortBy: LinearLayout;
|
private val _containerSortBy: LinearLayout;
|
||||||
private val _tagsView: TagsView;
|
private val _tagsView: TagsView;
|
||||||
|
private val _textCentered: TextView;
|
||||||
|
|
||||||
protected val _toolbarContentView: LinearLayout;
|
protected val _toolbarContentView: LinearLayout;
|
||||||
|
|
||||||
|
@ -68,6 +69,7 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
||||||
this.fragment = fragment;
|
this.fragment = fragment;
|
||||||
inflater.inflate(R.layout.fragment_feed, this);
|
inflater.inflate(R.layout.fragment_feed, this);
|
||||||
|
|
||||||
|
_textCentered = findViewById(R.id.text_centered);
|
||||||
_progress_bar = findViewById(R.id.progress_bar);
|
_progress_bar = findViewById(R.id.progress_bar);
|
||||||
_progress_bar.inactiveColor = Color.TRANSPARENT;
|
_progress_bar.inactiveColor = Color.TRANSPARENT;
|
||||||
|
|
||||||
|
@ -169,6 +171,10 @@ abstract class FeedView<TFragment, TResult, TConverted, TPager, TViewHolder> : L
|
||||||
_recyclerResults.addOnScrollListener(_scrollListener);
|
_recyclerResults.addOnScrollListener(_scrollListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected fun setTextCentered(text: String?) {
|
||||||
|
_textCentered.text = text;
|
||||||
|
}
|
||||||
|
|
||||||
fun onResume() {
|
fun onResume() {
|
||||||
//Reload the pager if the plugin was killed
|
//Reload the pager if the plugin was killed
|
||||||
val pager = recyclerData.pager;
|
val pager = recyclerData.pager;
|
||||||
|
|
|
@ -69,6 +69,8 @@ class ImportSubscriptionsFragment : MainFragment() {
|
||||||
private var _currentLoadIndex = 0;
|
private var _currentLoadIndex = 0;
|
||||||
|
|
||||||
private var _taskLoadChannel: TaskHandler<String, IPlatformChannel>;
|
private var _taskLoadChannel: TaskHandler<String, IPlatformChannel>;
|
||||||
|
private var _counter: Int = 0;
|
||||||
|
private var _limitToastShown = false;
|
||||||
|
|
||||||
constructor(fragment: ImportSubscriptionsFragment, inflater: LayoutInflater) : super(inflater.context) {
|
constructor(fragment: ImportSubscriptionsFragment, inflater: LayoutInflater) : super(inflater.context) {
|
||||||
_fragment = fragment;
|
_fragment = fragment;
|
||||||
|
@ -104,6 +106,7 @@ class ImportSubscriptionsFragment : MainFragment() {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|
||||||
_taskLoadChannel = TaskHandler<String, IPlatformChannel>({_fragment.lifecycleScope}, { link ->
|
_taskLoadChannel = TaskHandler<String, IPlatformChannel>({_fragment.lifecycleScope}, { link ->
|
||||||
|
_counter++;
|
||||||
val channel: IPlatformChannel = StatePlatform.instance.getChannelLive(link, false);
|
val channel: IPlatformChannel = StatePlatform.instance.getChannelLive(link, false);
|
||||||
return@TaskHandler channel;
|
return@TaskHandler channel;
|
||||||
}).success {
|
}).success {
|
||||||
|
@ -124,6 +127,8 @@ class ImportSubscriptionsFragment : MainFragment() {
|
||||||
}
|
}
|
||||||
|
|
||||||
fun onShown(parameter: Any ?, isBack: Boolean) {
|
fun onShown(parameter: Any ?, isBack: Boolean) {
|
||||||
|
_counter = 0;
|
||||||
|
_limitToastShown = false;
|
||||||
updateSelected();
|
updateSelected();
|
||||||
|
|
||||||
val itemsRemoved = _items.size;
|
val itemsRemoved = _items.size;
|
||||||
|
@ -157,6 +162,15 @@ class ImportSubscriptionsFragment : MainFragment() {
|
||||||
|
|
||||||
private fun load() {
|
private fun load() {
|
||||||
setLoading(true);
|
setLoading(true);
|
||||||
|
if (_counter >= MAXIMUM_BATCH_SIZE) {
|
||||||
|
if (!_limitToastShown) {
|
||||||
|
_limitToastShown = true;
|
||||||
|
UIDialogs.toast(context, "Stopped after $MAXIMUM_BATCH_SIZE to avoid rate limit, re-enter to import rest");
|
||||||
|
}
|
||||||
|
|
||||||
|
setLoading(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
_taskLoadChannel.run(_links[_currentLoadIndex]);
|
_taskLoadChannel.run(_links[_currentLoadIndex]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -196,6 +210,7 @@ class ImportSubscriptionsFragment : MainFragment() {
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
val TAG = "ImportSubscriptionsFragment";
|
val TAG = "ImportSubscriptionsFragment";
|
||||||
|
private const val MAXIMUM_BATCH_SIZE = 75;
|
||||||
fun newInstance() = ImportSubscriptionsFragment().apply {}
|
fun newInstance() = ImportSubscriptionsFragment().apply {}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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.contents.IPlatformContent
|
||||||
import com.futo.platformplayer.api.media.models.video.IPlatformVideo
|
import com.futo.platformplayer.api.media.models.video.IPlatformVideo
|
||||||
import com.futo.platformplayer.api.media.platforms.js.JSClient
|
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.api.media.structures.IPager
|
||||||
import com.futo.platformplayer.cache.ChannelContentCache
|
import com.futo.platformplayer.cache.ChannelContentCache
|
||||||
import com.futo.platformplayer.constructs.TaskHandler
|
import com.futo.platformplayer.constructs.TaskHandler
|
||||||
|
@ -280,8 +281,12 @@ class SubscriptionsFeedFragment : MainFragment() {
|
||||||
Logger.i(TAG, "Subscriptions load");
|
Logger.i(TAG, "Subscriptions load");
|
||||||
if(recyclerData.results.size == 0) {
|
if(recyclerData.results.size == 0) {
|
||||||
val cachePager = ChannelContentCache.instance.getSubscriptionCachePager();
|
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);
|
setPager(cachePager);
|
||||||
|
} else {
|
||||||
|
setTextCentered(null);
|
||||||
}
|
}
|
||||||
_taskGetPager.run(withRefetch);
|
_taskGetPager.run(withRefetch);
|
||||||
}
|
}
|
||||||
|
@ -294,6 +299,7 @@ class SubscriptionsFeedFragment : MainFragment() {
|
||||||
finishRefreshLayoutLoader();
|
finishRefreshLayoutLoader();
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
setPager(pager);
|
setPager(pager);
|
||||||
|
setTextCentered(if (pager.getResults().isEmpty()) "No results found\nSwipe down to refresh" else null);
|
||||||
} catch (e: Throwable) {
|
} catch (e: Throwable) {
|
||||||
Logger.e(TAG, "Failed to finish loading", e)
|
Logger.e(TAG, "Failed to finish loading", e)
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,9 +61,21 @@ public class PolycentricModelLoader implements ModelLoader<String, ByteBuffer> {
|
||||||
_deferred.invokeOnCompletion(throwable -> {
|
_deferred.invokeOnCompletion(throwable -> {
|
||||||
if (throwable != null) {
|
if (throwable != null) {
|
||||||
callback.onLoadFailed(new Exception(throwable));
|
callback.onLoadFailed(new Exception(throwable));
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
Deferred<ByteBuffer> deferred = _deferred;
|
||||||
|
if (deferred == null) {
|
||||||
|
callback.onLoadFailed(new Exception("Deferred is null"));
|
||||||
|
return Unit.INSTANCE;
|
||||||
|
}
|
||||||
|
|
||||||
|
ByteBuffer completed = deferred.getCompleted();
|
||||||
|
if (completed != null) {
|
||||||
|
callback.onDataReady(completed);
|
||||||
|
} else {
|
||||||
|
callback.onLoadFailed(new Exception("Completed is null"));
|
||||||
}
|
}
|
||||||
final ByteBuffer completed = _deferred.getCompleted();
|
|
||||||
callback.onDataReady(completed);
|
|
||||||
return Unit.INSTANCE;
|
return Unit.INSTANCE;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,22 +76,37 @@
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
app:layout_behavior="@string/appbar_scrolling_view_behavior">
|
||||||
<LinearLayout
|
<FrameLayout
|
||||||
android:orientation="vertical"
|
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="wrap_content">
|
android:layout_height="match_parent">
|
||||||
<com.futo.platformplayer.views.others.ProgressBar
|
<LinearLayout
|
||||||
android:id="@+id/progress_bar"
|
android:orientation="vertical"
|
||||||
android:layout_width="match_parent"
|
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
|
<androidx.recyclerview.widget.RecyclerView
|
||||||
android:id="@+id/list_results"
|
android:id="@+id/list_results"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:orientation="vertical" />
|
android:orientation="vertical" />
|
||||||
</LinearLayout>
|
</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.swiperefreshlayout.widget.SwipeRefreshLayout>
|
||||||
|
|
||||||
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
</androidx.coordinatorlayout.widget.CoordinatorLayout>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue