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 { @@ -62,7 +62,7 @@ public class RemoteRssFragment extends Fragment {
@ViewById
protected TextView remoterssStatusMessage;
protected RemoteRssItemsAdapter adapter;
// protected RemoteRssItemsAdapter adapter;
@AfterViews
protected void init() {
@ -70,7 +70,7 @@ public class RemoteRssFragment extends Fragment { @@ -70,7 +70,7 @@ public class RemoteRssFragment extends Fragment {
setHasOptionsMenu(true);
// Set up details adapter
adapter = new RemoteRssItemsAdapter(getActivity());
RemoteRssItemsAdapter adapter = new RemoteRssItemsAdapter(getActivity());
torrentsList.setAdapter(adapter);
torrentsList.setFastScrollEnabled(true);
}
@ -85,8 +85,11 @@ public class RemoteRssFragment extends Fragment { @@ -85,8 +85,11 @@ public class RemoteRssFragment extends Fragment {
* Updates the UI with a new list of RSS items.
*/
public void updateRemoteItems(List<RemoteRssItem> remoteItems, boolean scrollToTop) {
RemoteRssItemsAdapter adapter = (RemoteRssItemsAdapter) torrentsList.getAdapter();
remoteRssItems = new ArrayList<>(remoteItems);
adapter.updateItems(remoteRssItems);
if (scrollToTop) {
torrentsList.smoothScrollToPosition(0);
}
@ -109,6 +112,7 @@ public class RemoteRssFragment extends Fragment { @@ -109,6 +112,7 @@ public class RemoteRssFragment extends Fragment {
*/
@ItemClick(resName = "torrents_list")
protected void detailsListClicked(int position) {
RemoteRssItemsAdapter adapter = (RemoteRssItemsAdapter) torrentsList.getAdapter();
RemoteRssItem item = (RemoteRssItem) adapter.getItem(position);
((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 { @@ -83,11 +83,10 @@ public class RssfeedsActivity extends AppCompatActivity {
@Bean
protected ApplicationSettings applicationSettings;
protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments
protected RssfeedsFragment fragmentFeeds;
protected RemoteRssFragment fragmentRemoteFeeds;
@FragmentById(R.id.rssitems_fragment)
protected RssitemsFragment fragmentItems;
@ViewById
@ -183,7 +182,7 @@ public class RssfeedsActivity extends AppCompatActivity { @@ -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.
*/
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
// thread) and, on success, determines the new items in the feed
for (RssfeedSetting setting : applicationSettings.getRssfeedSettings()) {

Loading…
Cancel
Save