Delay loading when using online view multiple times to nudge people into subscribing

This commit is contained in:
ByteHamster 2024-04-21 00:17:46 +02:00
parent f0b0c68374
commit 0ecdac5fed
3 changed files with 22 additions and 0 deletions

View File

@ -207,9 +207,19 @@ public class OnlineFeedViewFragment extends Fragment {
.build();
download = Observable.fromCallable(() -> {
long start = System.currentTimeMillis();
feeds = DBReader.getFeedList();
boolean isInDatabase = findFeedInSubscriptions() != null;
if (isInDatabase) {
viewBinding.stateDeleteNotSubscribedLabel.post(() ->
viewBinding.stateDeleteNotSubscribedLabel.setVisibility(View.VISIBLE));
}
downloader = new HttpDownloader(request);
downloader.call();
long end = System.currentTimeMillis();
if (isInDatabase && end < start + 4000) {
Thread.sleep(4000 - (end - start)); // To nudge people into subscribing
}
return downloader.getResult();
})
.subscribeOn(Schedulers.io())
@ -299,6 +309,7 @@ public class OnlineFeedViewFragment extends Fragment {
*/
private void showFeedInformation(final Feed feed, Map<String, String> alternateFeedUrls) {
viewBinding.progressBar.setVisibility(View.GONE);
viewBinding.stateDeleteNotSubscribedLabel.setVisibility(View.GONE);
viewBinding.feedDisplayContainer.setVisibility(View.VISIBLE);
if (isFeedFoundBySearch) {
int resId = R.string.no_feed_url_podcast_found_by_search;

View File

@ -13,6 +13,16 @@
android:layout_gravity="center"
style="?android:attr/progressBarStyle" />
<TextView
android:id="@+id/stateDeleteNotSubscribedLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom|center_horizontal"
android:padding="32dp"
android:textAlignment="center"
android:visibility="gone"
android:text="@string/state_deleted_not_subscribed" />
<LinearLayout
android:id="@+id/feed_display_container"
android:layout_width="match_parent"

View File

@ -683,6 +683,7 @@
<string name="subscribe_label">Subscribe</string>
<string name="preview_episodes">Preview episodes</string>
<string name="subscribe_for_settings">Subscribe to change settings</string>
<string name="state_deleted_not_subscribed">Playback state of non-subscribed podcasts is deleted after a while. Subscribe to the podcast to enjoy all features.</string>
<!-- Content descriptions for image buttons -->
<string name="toolbar_back_button_content_description">Back</string>