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. 23
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  2. 4
      app/src/main/res/values/strings.xml

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

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

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

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

Loading…
Cancel
Save