Browse Source

- removed OptionsMenu from RemoteRssFragment since it duplicate them

- restored use of @FragmentById
- removed onFragmentReady()
- removed onFragmentDestroy()
pull/526/head
Twig N 5 years ago
parent
commit
0fc366ecc6
  1. 11
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java
  2. 52
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  3. 8
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java

11
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.ItemClick;
import org.androidannotations.annotations.ItemSelect; import org.androidannotations.annotations.ItemSelect;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.OptionsMenu;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.gui.log.Log; import org.transdroid.core.gui.log.Log;
@ -48,7 +47,6 @@ import java.util.List;
* @author Twig * @author Twig
*/ */
@EFragment(R.layout.fragment_remoterss) @EFragment(R.layout.fragment_remoterss)
@OptionsMenu(R.menu.fragment_rssfeeds)
public class RemoteRssFragment extends Fragment { public class RemoteRssFragment extends Fragment {
@Bean @Bean
protected Log log; protected Log log;
@ -85,8 +83,6 @@ public class RemoteRssFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
getRssActivity().onFragmentReady(this);
this.refreshScreen(); this.refreshScreen();
} }
@ -100,13 +96,6 @@ public class RemoteRssFragment extends Fragment {
MainSettingsActivity_.intent(getActivity()).start(); MainSettingsActivity_.intent(getActivity()).start();
} }
@Override
public void onDestroy() {
super.onDestroy();
getRssActivity().onFragmentDestroy(this);
}
/** /**
* Updates the UI with a new list of RSS items. * Updates the UI with a new list of RSS items.
*/ */

52
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.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);
}
} }
} }

8
app/src/main/java/org/transdroid/core/gui/rss/RssfeedsFragment.java

@ -84,17 +84,9 @@ public class RssfeedsFragment extends Fragment {
@Override @Override
public void onResume() { public void onResume() {
super.onResume(); super.onResume();
getRssActivity().onFragmentReady(this);
this.refreshScreen(); this.refreshScreen();
} }
@Override
public void onDestroy() {
super.onDestroy();
getRssActivity().onFragmentDestroy(this);
}
@OptionsItem(R.id.action_refresh) @OptionsItem(R.id.action_refresh)
protected void refreshScreen() { protected void refreshScreen() {
getRssActivity().refreshFeeds(); getRssActivity().refreshFeeds();

Loading…
Cancel
Save