|
|
@ -22,16 +22,17 @@ import android.net.Uri; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Build; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Bundle; |
|
|
|
import android.os.Parcel; |
|
|
|
import android.os.Parcel; |
|
|
|
|
|
|
|
import android.support.annotation.NonNull; |
|
|
|
import android.support.annotation.Nullable; |
|
|
|
import android.support.annotation.Nullable; |
|
|
|
import android.support.design.widget.TabLayout; |
|
|
|
import android.support.design.widget.TabLayout; |
|
|
|
import android.support.v4.app.Fragment; |
|
|
|
import android.support.v4.app.Fragment; |
|
|
|
import android.support.v4.app.FragmentManager; |
|
|
|
import android.support.v4.view.PagerAdapter; |
|
|
|
import android.support.v4.app.FragmentPagerAdapter; |
|
|
|
|
|
|
|
import android.support.v4.view.ViewPager; |
|
|
|
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 android.view.View; |
|
|
|
|
|
|
|
import android.view.ViewGroup; |
|
|
|
|
|
|
|
|
|
|
|
import com.nispok.snackbar.Snackbar; |
|
|
|
import com.nispok.snackbar.Snackbar; |
|
|
|
import com.nispok.snackbar.SnackbarManager; |
|
|
|
import com.nispok.snackbar.SnackbarManager; |
|
|
@ -57,7 +58,6 @@ import org.transdroid.core.gui.lists.LocalTorrent; |
|
|
|
import org.transdroid.core.gui.log.Log; |
|
|
|
import org.transdroid.core.gui.log.Log; |
|
|
|
import org.transdroid.core.gui.navigation.NavigationHelper; |
|
|
|
import org.transdroid.core.gui.navigation.NavigationHelper; |
|
|
|
import org.transdroid.core.gui.remoterss.RemoteRssFragment; |
|
|
|
import org.transdroid.core.gui.remoterss.RemoteRssFragment; |
|
|
|
import org.transdroid.core.gui.remoterss.RemoteRssFragment_; |
|
|
|
|
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssChannel; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssChannel; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier; |
|
|
|
import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier; |
|
|
@ -112,38 +112,45 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
protected ConnectivityHelper connectivityHelper; |
|
|
|
protected ConnectivityHelper connectivityHelper; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PagerAdapter extends FragmentPagerAdapter { |
|
|
|
protected class LayoutPagerAdapter extends PagerAdapter { |
|
|
|
boolean hasRemoteRss = false; |
|
|
|
boolean hasRemoteRss; |
|
|
|
String serverName = ""; |
|
|
|
String serverName; |
|
|
|
|
|
|
|
|
|
|
|
public PagerAdapter(FragmentManager fm, boolean hasRemoteRss, String name) { |
|
|
|
public LayoutPagerAdapter(boolean hasRemoteRss, String name) { |
|
|
|
super(fm); |
|
|
|
super(); |
|
|
|
|
|
|
|
|
|
|
|
this.hasRemoteRss = hasRemoteRss; |
|
|
|
this.hasRemoteRss = hasRemoteRss; |
|
|
|
this.serverName = (name.length() > 0 ? name : getString(R.string.navigation_rss_tabs_remote)); |
|
|
|
this.serverName = (name.length() > 0 ? name : getString(R.string.navigation_rss_tabs_remote)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@NonNull |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Fragment getItem(int position) { |
|
|
|
public Object instantiateItem(@NonNull ViewGroup container, int position) { |
|
|
|
Fragment fragment = null; |
|
|
|
int resId = 0; |
|
|
|
|
|
|
|
|
|
|
|
if (position == RSS_FEEDS_LOCAL) { |
|
|
|
if (position == RSS_FEEDS_LOCAL) { |
|
|
|
fragment = RssfeedsFragment_.builder().build(); |
|
|
|
resId = R.id.layout_rssfeeds_local; |
|
|
|
} |
|
|
|
} |
|
|
|
else if (position == RSS_FEEDS_REMOTE) { |
|
|
|
else if (position == RSS_FEEDS_REMOTE) { |
|
|
|
fragment = RemoteRssFragment_.builder().build(); |
|
|
|
resId = R.id.layout_rss_feeds_remote; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return fragment; |
|
|
|
return findViewById(resId); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public int getCount() { |
|
|
|
public int getCount() { |
|
|
|
if (this.hasRemoteRss) { |
|
|
|
return (this.hasRemoteRss ? 2 : 1); |
|
|
|
return 2; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
|
|
public boolean isViewFromObject(@NonNull View view, @NonNull Object o) { |
|
|
|
|
|
|
|
return (view == o); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return 1; |
|
|
|
@Override |
|
|
|
|
|
|
|
public void destroyItem(@NonNull ViewGroup container, int position, @NonNull Object object) { |
|
|
|
|
|
|
|
container.removeView((View) object); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Nullable |
|
|
|
@Nullable |
|
|
@ -178,7 +185,7 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
IDaemonAdapter currentConnection = this.getCurrentConnection(); |
|
|
|
IDaemonAdapter currentConnection = this.getCurrentConnection(); |
|
|
|
boolean hasRemoteRss = Daemon.supportsRemoteRssManagement(currentConnection.getType()); |
|
|
|
boolean hasRemoteRss = Daemon.supportsRemoteRssManagement(currentConnection.getType()); |
|
|
|
|
|
|
|
|
|
|
|
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager(), hasRemoteRss, currentConnection.getSettings().getName()); |
|
|
|
PagerAdapter pagerAdapter = new LayoutPagerAdapter(hasRemoteRss, currentConnection.getSettings().getName()); |
|
|
|
viewPager.setAdapter(pagerAdapter); |
|
|
|
viewPager.setAdapter(pagerAdapter); |
|
|
|
tabLayout.setupWithViewPager(viewPager); |
|
|
|
tabLayout.setupWithViewPager(viewPager); |
|
|
|
viewPager.setCurrentItem(0); |
|
|
|
viewPager.setCurrentItem(0); |
|
|
|