Hide 'Not subscribed' message the first time we show preview (#7296)

This commit is contained in:
ByteHamster 2024-07-20 16:19:25 +02:00 committed by GitHub
parent 9d6d37548f
commit 7d1509f816
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 15 additions and 5 deletions

View File

@ -87,6 +87,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
MaterialToolbar.OnMenuItemClickListener, EpisodeItemListAdapter.OnSelectModeListener {
public static final String TAG = "ItemlistFragment";
private static final String ARGUMENT_FEED_ID = "argument.de.danoeh.antennapod.feed_id";
private static final String ARGUMENT_IS_FIRST_TIME = "argument.de.danoeh.antennapod.first_time";
private static final String KEY_UP_ARROW = "up_arrow";
protected static final int EPISODES_PER_PAGE = 150;
protected int page = 1;
@ -98,6 +99,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
private MoreContentListFooterUtil nextPageLoader;
private boolean displayUpArrow;
private long feedID;
private boolean isFirstTime = false;
private Feed feed;
private Disposable disposable;
private FeedItemListFragmentBinding viewBinding;
@ -110,9 +112,14 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
* @return the newly created instance of an ItemlistFragment
*/
public static FeedItemlistFragment newInstance(long feedId) {
return newInstance(feedId, false);
}
public static FeedItemlistFragment newInstance(long feedId, boolean isFirstTime) {
FeedItemlistFragment i = new FeedItemlistFragment();
Bundle b = new Bundle();
b.putLong(ARGUMENT_FEED_ID, feedId);
b.putBoolean(ARGUMENT_IS_FIRST_TIME, isFirstTime);
i.setArguments(b);
return i;
}
@ -124,6 +131,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
Bundle args = getArguments();
Validate.notNull(args);
feedID = args.getLong(ARGUMENT_FEED_ID);
isFirstTime = args.getBoolean(ARGUMENT_IS_FIRST_TIME, false);
}
@Nullable
@ -478,6 +486,7 @@ public class FeedItemlistFragment extends Fragment implements AdapterView.OnItem
if (feed.getState() != Feed.STATE_SUBSCRIBED) {
viewBinding.header.descriptionContainer.setVisibility(View.VISIBLE);
viewBinding.header.headerDescriptionLabel.setText(HtmlToPlainText.getPlainText(feed.getDescription()));
viewBinding.header.subscribeNagLabel.setVisibility(isFirstTime ? View.GONE : View.VISIBLE);
} else if (feed.getItemFilter() != null) {
FeedItemFilter filter = feed.getItemFilter();
if (filter.getValues().length > 0) {

View File

@ -234,7 +234,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
if (subscribedFeed.getState() == Feed.STATE_SUBSCRIBED) {
openFeed(subscribedFeed.getId());
} else {
showFeedFragment(subscribedFeed.getId());
showFeedFragment(subscribedFeed.getId(), false);
}
}, error -> Log.e(TAG, Log.getStackTraceString(error)), () -> startFeedDownload(url));
return null;
@ -292,7 +292,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
})
.subscribeOn(Schedulers.computation())
.observeOn(AndroidSchedulers.mainThread())
.subscribe(this::showFeedFragment, error -> {
.subscribe(id -> showFeedFragment(id, true), error -> {
error.printStackTrace();
showErrorDialog(error.getMessage(), "");
});
@ -333,13 +333,13 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
}
}
private void showFeedFragment(long id) {
private void showFeedFragment(long id, boolean isFirstTime) {
if (isFeedFoundBySearch) {
Toast.makeText(this, R.string.no_feed_url_podcast_found_by_search, Toast.LENGTH_LONG).show();
}
viewBinding.progressBar.setVisibility(View.GONE);
FeedItemlistFragment fragment = FeedItemlistFragment.newInstance(id);
FeedItemlistFragment fragment = FeedItemlistFragment.newInstance(id, isFirstTime);
getSupportFragmentManager()
.beginTransaction()
.replace(R.id.fragmentContainer, fragment, FeedItemlistFragment.TAG)

View File

@ -200,15 +200,16 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingHorizontal="16dp"
android:paddingTop="16dp"
android:background="?android:attr/colorBackground"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:id="@+id/subscribeNagLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="8dp"
android:layout_marginTop="16dp"
android:paddingHorizontal="16dp"
android:paddingVertical="8dp"
android:background="@drawable/bg_message_info"