|
|
@ -25,7 +25,6 @@ import android.os.Parcel; |
|
|
|
import android.support.annotation.NonNull; |
|
|
|
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.view.PagerAdapter; |
|
|
|
import android.support.v4.view.PagerAdapter; |
|
|
|
import android.support.v4.view.ViewPager; |
|
|
|
import android.support.v4.view.ViewPager; |
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
|
import android.support.v7.app.AppCompatActivity; |
|
|
@ -85,12 +84,16 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
@Bean |
|
|
|
@Bean |
|
|
|
protected ApplicationSettings applicationSettings; |
|
|
|
protected ApplicationSettings applicationSettings; |
|
|
|
|
|
|
|
|
|
|
|
// Contained feeds and items fragments
|
|
|
|
protected static final int RSS_FEEDS_LOCAL = 0; |
|
|
|
protected RssfeedsFragment fragmentLocalFeeds; |
|
|
|
protected static final int RSS_FEEDS_REMOTE = 1; |
|
|
|
protected RemoteRssFragment fragmentRemoteFeeds; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@FragmentById(R.id.remoterss_fragment) |
|
|
|
|
|
|
|
protected RemoteRssFragment fragmentRemoteFeeds; |
|
|
|
@FragmentById(R.id.rssitems_fragment) |
|
|
|
@FragmentById(R.id.rssitems_fragment) |
|
|
|
protected RssitemsFragment fragmentItems; |
|
|
|
protected RssitemsFragment fragmentItems; |
|
|
|
|
|
|
|
@FragmentById(R.id.rssfeeds_fragment) |
|
|
|
|
|
|
|
protected RssfeedsFragment fragmentLocalFeeds; |
|
|
|
|
|
|
|
|
|
|
|
@ViewById |
|
|
|
@ViewById |
|
|
|
protected Toolbar rssfeedsToolbar; |
|
|
|
protected Toolbar rssfeedsToolbar; |
|
|
|
@ViewById(R.id.rssfeeds_tabs) |
|
|
|
@ViewById(R.id.rssfeeds_tabs) |
|
|
@ -98,9 +101,6 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
@ViewById(R.id.rssfeeds_pager) |
|
|
|
@ViewById(R.id.rssfeeds_pager) |
|
|
|
protected ViewPager viewPager; |
|
|
|
protected ViewPager viewPager; |
|
|
|
|
|
|
|
|
|
|
|
protected static final int RSS_FEEDS_LOCAL = 0; |
|
|
|
|
|
|
|
protected static final int RSS_FEEDS_REMOTE = 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// remote RSS stuff
|
|
|
|
// remote RSS stuff
|
|
|
|
@NonConfigurationInstance |
|
|
|
@NonConfigurationInstance |
|
|
|
protected ArrayList<RemoteRssChannel> feeds; |
|
|
|
protected ArrayList<RemoteRssChannel> feeds; |
|
|
@ -195,24 +195,6 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void onFragmentReady(Fragment fragment) { |
|
|
|
|
|
|
|
if (fragment instanceof RssfeedsFragment) { |
|
|
|
|
|
|
|
fragmentLocalFeeds = (RssfeedsFragment) fragment; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (fragment instanceof RemoteRssFragment) { |
|
|
|
|
|
|
|
fragmentRemoteFeeds = (RemoteRssFragment) fragment; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void onFragmentDestroy(Fragment fragment) { |
|
|
|
|
|
|
|
if (fragment instanceof RssfeedsFragment) { |
|
|
|
|
|
|
|
fragmentLocalFeeds = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
else if (fragment instanceof RemoteRssFragment) { |
|
|
|
|
|
|
|
fragmentRemoteFeeds = null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
|
|
|
@TargetApi(Build.VERSION_CODES.HONEYCOMB) |
|
|
|
@OptionsItem(android.R.id.home) |
|
|
|
@OptionsItem(android.R.id.home) |
|
|
|
protected void navigateUp() { |
|
|
|
protected void navigateUp() { |
|
|
@ -232,9 +214,7 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
loadRssfeed(loader); |
|
|
|
loadRssfeed(loader); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (fragmentLocalFeeds != null) { |
|
|
|
fragmentLocalFeeds.update(loaders); |
|
|
|
fragmentLocalFeeds.update(loaders); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -266,9 +246,7 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
protected void handleRssfeedResult(RssfeedLoader loader, Channel channel, boolean hasError) { |
|
|
|
protected void handleRssfeedResult(RssfeedLoader loader, Channel channel, boolean hasError) { |
|
|
|
loader.update(channel, hasError); |
|
|
|
loader.update(channel, hasError); |
|
|
|
|
|
|
|
|
|
|
|
if (fragmentLocalFeeds != null) { |
|
|
|
fragmentLocalFeeds.notifyDataSetChanged(); |
|
|
|
fragmentLocalFeeds.notifyDataSetChanged(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -373,11 +351,9 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// @UIThread
|
|
|
|
// @UIThread
|
|
|
|
if (fragmentRemoteFeeds != null) { |
|
|
|
fragmentRemoteFeeds.updateRemoteItems( |
|
|
|
fragmentRemoteFeeds.updateRemoteItems( |
|
|
|
selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(), |
|
|
|
selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(), |
|
|
|
false /* allow android to restore scroll position */ ); |
|
|
|
false /* allow android to restore scroll position */ ); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
showRemoteChannelFilters(); |
|
|
|
showRemoteChannelFilters(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -446,8 +422,6 @@ public class RssfeedsActivity extends AppCompatActivity { |
|
|
|
}); |
|
|
|
}); |
|
|
|
feedLabels.addAll(feeds); |
|
|
|
feedLabels.addAll(feeds); |
|
|
|
|
|
|
|
|
|
|
|
if (fragmentRemoteFeeds != null) { |
|
|
|
fragmentRemoteFeeds.updateChannelFilters(feedLabels); |
|
|
|
fragmentRemoteFeeds.updateChannelFilters(feedLabels); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|