From 0fc366ecc6d8895f7e02475139f3710a652856dc Mon Sep 17 00:00:00 2001 From: Twig N Date: Thu, 23 Jan 2020 20:38:45 +1100 Subject: [PATCH] - removed OptionsMenu from RemoteRssFragment since it duplicate them - restored use of @FragmentById - removed onFragmentReady() - removed onFragmentDestroy() --- .../core/gui/remoterss/RemoteRssFragment.java | 11 ---- .../core/gui/rss/RssfeedsActivity.java | 52 +++++-------------- .../core/gui/rss/RssfeedsFragment.java | 8 --- 3 files changed, 13 insertions(+), 58 deletions(-) diff --git a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java index 36dbc5c9..d742aa24 100644 --- a/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java @@ -30,7 +30,6 @@ import org.androidannotations.annotations.EFragment; import org.androidannotations.annotations.ItemClick; import org.androidannotations.annotations.ItemSelect; import org.androidannotations.annotations.OptionsItem; -import org.androidannotations.annotations.OptionsMenu; import org.androidannotations.annotations.ViewById; import org.transdroid.R; import org.transdroid.core.gui.log.Log; @@ -48,7 +47,6 @@ import java.util.List; * @author Twig */ @EFragment(R.layout.fragment_remoterss) -@OptionsMenu(R.menu.fragment_rssfeeds) public class RemoteRssFragment extends Fragment { @Bean protected Log log; @@ -85,8 +83,6 @@ public class RemoteRssFragment extends Fragment { @Override public void onResume() { super.onResume(); - - getRssActivity().onFragmentReady(this); this.refreshScreen(); } @@ -100,13 +96,6 @@ public class RemoteRssFragment extends Fragment { MainSettingsActivity_.intent(getActivity()).start(); } - @Override - public void onDestroy() { - super.onDestroy(); - - getRssActivity().onFragmentDestroy(this); - } - /** * Updates the UI with a new list of RSS items. */ 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 6718e89f..9070f2e6 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 @@ -25,7 +25,6 @@ import android.os.Parcel; import android.support.annotation.NonNull; import android.support.annotation.Nullable; import android.support.design.widget.TabLayout; -import android.support.v4.app.Fragment; import android.support.v4.view.PagerAdapter; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; @@ -85,12 +84,16 @@ public class RssfeedsActivity extends AppCompatActivity { @Bean protected ApplicationSettings applicationSettings; - // Contained feeds and items fragments - protected RssfeedsFragment fragmentLocalFeeds; - protected RemoteRssFragment fragmentRemoteFeeds; + protected static final int RSS_FEEDS_LOCAL = 0; + protected static final int RSS_FEEDS_REMOTE = 1; + @FragmentById(R.id.remoterss_fragment) + protected RemoteRssFragment fragmentRemoteFeeds; @FragmentById(R.id.rssitems_fragment) protected RssitemsFragment fragmentItems; + @FragmentById(R.id.rssfeeds_fragment) + protected RssfeedsFragment fragmentLocalFeeds; + @ViewById protected Toolbar rssfeedsToolbar; @ViewById(R.id.rssfeeds_tabs) @@ -98,9 +101,6 @@ public class RssfeedsActivity extends AppCompatActivity { @ViewById(R.id.rssfeeds_pager) protected ViewPager viewPager; - protected static final int RSS_FEEDS_LOCAL = 0; - protected static final int RSS_FEEDS_REMOTE = 1; - // remote RSS stuff @NonConfigurationInstance protected ArrayList 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) @OptionsItem(android.R.id.home) protected void navigateUp() { @@ -232,9 +214,7 @@ public class RssfeedsActivity extends AppCompatActivity { 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) { loader.update(channel, hasError); - if (fragmentLocalFeeds != null) { - fragmentLocalFeeds.notifyDataSetChanged(); - } + fragmentLocalFeeds.notifyDataSetChanged(); } /** @@ -373,11 +351,9 @@ public class RssfeedsActivity extends AppCompatActivity { } // @UIThread - if (fragmentRemoteFeeds != null) { - fragmentRemoteFeeds.updateRemoteItems( - selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(), - false /* allow android to restore scroll position */ ); - } + fragmentRemoteFeeds.updateRemoteItems( + selectedFilter == 0 ? recentItems : feeds.get(selectedFilter -1).getItems(), + false /* allow android to restore scroll position */ ); showRemoteChannelFilters(); } @@ -446,8 +422,6 @@ public class RssfeedsActivity extends AppCompatActivity { }); feedLabels.addAll(feeds); - if (fragmentRemoteFeeds != null) { - fragmentRemoteFeeds.updateChannelFilters(feedLabels); - } + fragmentRemoteFeeds.updateChannelFilters(feedLabels); } } diff --git a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java index 2ad23339..670059e9 100644 --- a/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java +++ b/app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java @@ -84,17 +84,9 @@ public class RssfeedsFragment extends Fragment { @Override public void onResume() { super.onResume(); - getRssActivity().onFragmentReady(this); this.refreshScreen(); } - @Override - public void onDestroy() { - super.onDestroy(); - - getRssActivity().onFragmentDestroy(this); - } - @OptionsItem(R.id.action_refresh) protected void refreshScreen() { getRssActivity().refreshFeeds();