Browse Source

- removed OptionsMenu from RemoteRssFragment since it duplicate them

- restored use of @FragmentById
- removed onFragmentReady()
- removed onFragmentDestroy()
pull/526/head
Twig N 4 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; @@ -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; @@ -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 { @@ -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 { @@ -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.
*/

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

@ -25,7 +25,6 @@ import android.os.Parcel; @@ -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 { @@ -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 { @@ -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<RemoteRssChannel> feeds;
@ -195,24 +195,6 @@ public class RssfeedsActivity extends AppCompatActivity { @@ -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 { @@ -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 { @@ -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 { @@ -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 { @@ -446,8 +422,6 @@ public class RssfeedsActivity extends AppCompatActivity {
});
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 { @@ -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();

Loading…
Cancel
Save