From 4dc718cd5ba372ed5a40e3cf6b98f2a39d197cc4 Mon Sep 17 00:00:00 2001 From: Twig N Date: Fri, 19 Jun 2020 20:49:47 +1000 Subject: [PATCH] - automatically switch to remote rss feeds if they are set up AND you dont use local rss feeds --- .../core/gui/rss/RssFeedsActivity.java | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java b/app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java index 8fc448ce..06035b47 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java @@ -185,7 +185,25 @@ public class RssFeedsActivity extends AppCompatActivity { PagerAdapter pagerAdapter = new LayoutPagerAdapter(hasRemoteRss, currentConnection.getSettings().getName()); viewPager.setAdapter(pagerAdapter); tabLayout.setupWithViewPager(viewPager); - viewPager.setCurrentItem(0); + + // if local feeds dont have any entries but remote does, show it instead + int defaultTab = RSS_FEEDS_LOCAL; + + if (hasRemoteRss && applicationSettings.getRssfeedSettings().size() == 0) { + if (currentConnection instanceof RemoteRssSupplier) { + RemoteRssSupplier remoteConnection = ((RemoteRssSupplier) (currentConnection)); + boolean hasRemoteFeeds = false; + + try { + hasRemoteFeeds = remoteConnection.getRemoteRssChannels(log).size() > 0; + } catch (DaemonException e) {} + + if (hasRemoteFeeds) { + defaultTab = RSS_FEEDS_REMOTE; + } + } + } + viewPager.setCurrentItem(defaultTab); if (!hasRemoteRss) { tabLayout.setVisibility(View.GONE);