Browse Source

- updated tab labels

- updated comments in RssfeedsActivity.java
- show/hide remote rss feeds tab depending on server support
- show/hide tab depending on server support
pull/526/head
Twig N 5 years ago
parent
commit
46bcc679ef
  1. 25
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  2. 4
      app/src/main/res/values/strings.xml

25
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java

@ -31,6 +31,7 @@ import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity; import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.text.TextUtils; import android.text.TextUtils;
import android.view.View;
import com.nispok.snackbar.Snackbar; import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager; import com.nispok.snackbar.SnackbarManager;
@ -63,6 +64,7 @@ import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier;
import org.transdroid.core.rssparser.Channel; import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.RssParser; import org.transdroid.core.rssparser.RssParser;
import org.transdroid.core.service.ConnectivityHelper; import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.DaemonException; import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.IDaemonAdapter; import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.task.DaemonTaskSuccessResult; import org.transdroid.daemon.task.DaemonTaskSuccessResult;
@ -111,8 +113,12 @@ public class RssfeedsActivity extends AppCompatActivity {
class PagerAdapter extends FragmentPagerAdapter { class PagerAdapter extends FragmentPagerAdapter {
public PagerAdapter(FragmentManager fm) { boolean hasRemoteRss = false;
public PagerAdapter(FragmentManager fm, boolean hasRemoteRss) {
super(fm); super(fm);
this.hasRemoteRss = hasRemoteRss;
} }
@Override @Override
@ -131,7 +137,11 @@ public class RssfeedsActivity extends AppCompatActivity {
@Override @Override
public int getCount() { public int getCount() {
return 2; if (this.hasRemoteRss) {
return 2;
}
return 1;
} }
@Nullable @Nullable
@ -163,10 +173,15 @@ public class RssfeedsActivity extends AppCompatActivity {
getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(getString(R.string.rss_feeds))); getSupportActionBar().setTitle(NavigationHelper.buildCondensedFontString(getString(R.string.rss_feeds)));
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager()); boolean hasRemoteRss = Daemon.supportsRemoteRssManagement(this.getCurrentConnection().getType());
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), hasRemoteRss);
viewPager.setAdapter(pagerAdapter); viewPager.setAdapter(pagerAdapter);
tabLayout.setupWithViewPager(viewPager); tabLayout.setupWithViewPager(viewPager);
viewPager.setCurrentItem(0); viewPager.setCurrentItem(0);
if (!hasRemoteRss) {
tabLayout.setVisibility(View.GONE);
}
} }
public void onFragmentReady(Fragment fragment) { public void onFragmentReady(Fragment fragment) {
@ -307,6 +322,7 @@ public class RssfeedsActivity extends AppCompatActivity {
return lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this); return lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
} }
// @Background
public void refreshRemoteFeeds() { public void refreshRemoteFeeds() {
// Connect to the last used server // Connect to the last used server
IDaemonAdapter currentConnection = this.getCurrentConnection(); IDaemonAdapter currentConnection = this.getCurrentConnection();
@ -319,7 +335,7 @@ public class RssfeedsActivity extends AppCompatActivity {
try { try {
feeds = ((RemoteRssSupplier) (currentConnection)).getRemoteRssChannels(log); feeds = ((RemoteRssSupplier) (currentConnection)).getRemoteRssChannels(log);
// loadFeeds() in background // By default it displays the latest items within the last month.
recentItems = new ArrayList<>(); recentItems = new ArrayList<>();
Calendar calendar = Calendar.getInstance(); Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1); calendar.add(Calendar.MONTH, -1);
@ -345,6 +361,7 @@ public class RssfeedsActivity extends AppCompatActivity {
return; return;
} }
// @UIThread
if (fragmentRemoteFeeds != null) { if (fragmentRemoteFeeds != null) {
fragmentRemoteFeeds.updateRemoteItems( fragmentRemoteFeeds.updateRemoteItems(
selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(), selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(),

4
app/src/main/res/values/strings.xml

@ -102,8 +102,8 @@
<string name="navigation_invertselection">Invert selection</string> <string name="navigation_invertselection">Invert selection</string>
<string name="navigation_pickserver">Add torrent to&#8230;</string> <string name="navigation_pickserver">Add torrent to&#8230;</string>
<string name="navigation_url_hint" translatable="false">http://…</string> <string name="navigation_url_hint" translatable="false">http://…</string>
<string name="navigation_rss_tabs_local">RSS feeds</string> <string name="navigation_rss_tabs_local">Transdroid</string>
<string name="navigation_rss_tabs_remote">Remote feeds</string> <string name="navigation_rss_tabs_remote">Server</string>
<string name="status_status">STATUS: %1$s</string> <string name="status_status">STATUS: %1$s</string>
<string name="status_waiting">Waiting to check&#8230;</string> <string name="status_waiting">Waiting to check&#8230;</string>

Loading…
Cancel
Save