Browse Source

Dont store loaders and adapters in class variables if we dont need to

pull/526/head
Twig N 5 years ago
parent
commit
e30dfc13b3
  1. 8
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java
  2. 5
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java

8
app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java

@ -62,7 +62,7 @@ public class RemoteRssFragment extends Fragment {
@ViewById @ViewById
protected TextView remoterssStatusMessage; protected TextView remoterssStatusMessage;
protected RemoteRssItemsAdapter adapter; // protected RemoteRssItemsAdapter adapter;
@AfterViews @AfterViews
protected void init() { protected void init() {
@ -70,7 +70,7 @@ public class RemoteRssFragment extends Fragment {
setHasOptionsMenu(true); setHasOptionsMenu(true);
// Set up details adapter // Set up details adapter
adapter = new RemoteRssItemsAdapter(getActivity()); RemoteRssItemsAdapter adapter = new RemoteRssItemsAdapter(getActivity());
torrentsList.setAdapter(adapter); torrentsList.setAdapter(adapter);
torrentsList.setFastScrollEnabled(true); torrentsList.setFastScrollEnabled(true);
} }
@ -85,8 +85,11 @@ public class RemoteRssFragment extends Fragment {
* Updates the UI with a new list of RSS items. * Updates the UI with a new list of RSS items.
*/ */
public void updateRemoteItems(List<RemoteRssItem> remoteItems, boolean scrollToTop) { public void updateRemoteItems(List<RemoteRssItem> remoteItems, boolean scrollToTop) {
RemoteRssItemsAdapter adapter = (RemoteRssItemsAdapter) torrentsList.getAdapter();
remoteRssItems = new ArrayList<>(remoteItems); remoteRssItems = new ArrayList<>(remoteItems);
adapter.updateItems(remoteRssItems); adapter.updateItems(remoteRssItems);
if (scrollToTop) { if (scrollToTop) {
torrentsList.smoothScrollToPosition(0); torrentsList.smoothScrollToPosition(0);
} }
@ -109,6 +112,7 @@ public class RemoteRssFragment extends Fragment {
*/ */
@ItemClick(resName = "torrents_list") @ItemClick(resName = "torrents_list")
protected void detailsListClicked(int position) { protected void detailsListClicked(int position) {
RemoteRssItemsAdapter adapter = (RemoteRssItemsAdapter) torrentsList.getAdapter();
RemoteRssItem item = (RemoteRssItem) adapter.getItem(position); RemoteRssItem item = (RemoteRssItem) adapter.getItem(position);
((RssfeedsActivity) getActivity()).downloadRemoteRssItem(item); ((RssfeedsActivity) getActivity()).downloadRemoteRssItem(item);

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

@ -83,11 +83,10 @@ public class RssfeedsActivity extends AppCompatActivity {
@Bean @Bean
protected ApplicationSettings applicationSettings; protected ApplicationSettings applicationSettings;
protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments // Contained feeds and items fragments
protected RssfeedsFragment fragmentFeeds; protected RssfeedsFragment fragmentFeeds;
protected RemoteRssFragment fragmentRemoteFeeds; protected RemoteRssFragment fragmentRemoteFeeds;
@FragmentById(R.id.rssitems_fragment) @FragmentById(R.id.rssitems_fragment)
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@ViewById @ViewById
@ -183,7 +182,7 @@ public class RssfeedsActivity extends AppCompatActivity {
* Reload the RSS feed settings and start loading all the feeds. To be called from contained fragments. * Reload the RSS feed settings and start loading all the feeds. To be called from contained fragments.
*/ */
public void refreshFeeds() { public void refreshFeeds() {
loaders = new ArrayList<>(); List<RssfeedLoader> loaders = new ArrayList<>();
// For each RSS feed setting the user created, start a loader that retrieved the RSS feed (via a background // For each RSS feed setting the user created, start a loader that retrieved the RSS feed (via a background
// thread) and, on success, determines the new items in the feed // thread) and, on success, determines the new items in the feed
for (RssfeedSetting setting : applicationSettings.getRssfeedSettings()) { for (RssfeedSetting setting : applicationSettings.getRssfeedSettings()) {

Loading…
Cancel
Save