Browse Source

- moved most of remoterss/RemoteRssActivity code into RssfeedsActivity

- RemoteRssFragment now extends android.support.v4.app.Fragment
- removed swipeRefreshLayout
pull/526/head
Twig N 5 years ago
parent
commit
f92dd04a31
  1. 230
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java
  2. 85
      app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssFragment.java
  3. 140
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedsActivity.java
  4. 17
      app/src/main/res/layout/fragment_remoterss.xml

230
app/src/main/java/org/transdroid/core/gui/remoterss/RemoteRssActivity.java

@ -72,24 +72,24 @@ import java.util.List;
* @author Twig Nguyen * @author Twig Nguyen
*/ */
@EActivity(R.layout.activity_remoterss) @EActivity(R.layout.activity_remoterss)
public class RemoteRssActivity extends AppCompatActivity implements RefreshableActivity { public class RemoteRssActivity extends AppCompatActivity {
@NonConfigurationInstance // @NonConfigurationInstance
protected ArrayList<RemoteRssChannel> feeds; // protected ArrayList<RemoteRssChannel> feeds;
@InstanceState // @InstanceState
protected int selectedFilter; // protected int selectedFilter;
@NonConfigurationInstance // @NonConfigurationInstance
protected ArrayList<RemoteRssItem> recentItems; // protected ArrayList<RemoteRssItem> recentItems;
// Server connection // Server connection
@Bean @Bean
protected ApplicationSettings applicationSettings; protected ApplicationSettings applicationSettings;
@Bean @Bean
protected Log log; protected Log log;
@Bean // @Bean
protected ConnectivityHelper connectivityHelper; // protected ConnectivityHelper connectivityHelper;
private IDaemonAdapter currentConnection; // private IDaemonAdapter currentConnection;
// Details view components // Details view components
@ViewById @ViewById
@ -122,71 +122,71 @@ public class RemoteRssActivity extends AppCompatActivity implements RefreshableA
setSupportActionBar(torrentsToolbar); setSupportActionBar(torrentsToolbar);
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
// Connect to the last used server // // Connect to the last used server
ServerSetting lastUsed = applicationSettings.getLastUsedServer(); // ServerSetting lastUsed = applicationSettings.getLastUsedServer();
currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this); // currentConnection = lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
//
if (feeds != null) { // if (feeds != null) {
// Called from a configuration change. No need to load anything from server // // Called from a configuration change. No need to load anything from server
showChannelFilters(); // showChannelFilters();
fragmentRemoteRss.updateRemoteItems( // fragmentRemoteRss.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 */ );
} else { // } else {
loadFeeds(); // loadFeeds();
} // }
}
@Background
protected void loadFeeds() {
try {
fragmentRemoteRss.setRefreshing(true);
feeds = ((RemoteRssSupplier) (currentConnection)).getRemoteRssChannels(log);
fragmentRemoteRss.setRefreshing(false);
} catch (DaemonException e) {
onCommunicationError(e);
}
recentItems = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
Date oneMonthAgo = calendar.getTime();
for (RemoteRssChannel feed : feeds) {
for (RemoteRssItem item : feed.getItems()) {
if (item.getTimestamp().after(oneMonthAgo)) {
recentItems.add(item);
}
}
}
// Sort by -newest
Collections.sort(recentItems, new Comparator<RemoteRssItem>() {
@Override
public int compare(RemoteRssItem lhs, RemoteRssItem rhs) {
return rhs.getTimestamp().compareTo(lhs.getTimestamp());
}
});
afterLoadFeeds();
} }
@UiThread // @Background
protected void afterLoadFeeds() { // protected void loadFeeds() {
// We need to wrap these calls in a @UiThread rather than make them each a @UiThread themselves // try {
// because they need to run sequentially in a configuration change scenario in order for Android // fragmentRemoteRss.setRefreshing(true);
// to maintain scroll position on the fragment adapter. // feeds = ((RemoteRssSupplier) (currentConnection)).getRemoteRssChannels(log);
showChannelFilters(); // fragmentRemoteRss.setRefreshing(false);
onFeedSelected(selectedFilter); // } catch (DaemonException e) {
} // onCommunicationError(e);
// }
@UiThread //
protected void onCommunicationError(DaemonException daemonException) { // recentItems = new ArrayList<>();
//noinspection ThrowableResultOfMethodCallIgnored // Calendar calendar = Calendar.getInstance();
log.i(this, daemonException.toString()); // calendar.add(Calendar.MONTH, -1);
String error = getString(LocalTorrent.getResourceForDaemonException(daemonException)); // Date oneMonthAgo = calendar.getTime();
SnackbarManager.show(Snackbar.with(this).text(error).colorResource(R.color.red).type(SnackbarType.MULTI_LINE)); //
} // for (RemoteRssChannel feed : feeds) {
// for (RemoteRssItem item : feed.getItems()) {
// if (item.getTimestamp().after(oneMonthAgo)) {
// recentItems.add(item);
// }
// }
// }
// // Sort by -newest
// Collections.sort(recentItems, new Comparator<RemoteRssItem>() {
// @Override
// public int compare(RemoteRssItem lhs, RemoteRssItem rhs) {
// return rhs.getTimestamp().compareTo(lhs.getTimestamp());
// }
// });
//
// afterLoadFeeds();
// }
// @UiThread
// protected void afterLoadFeeds() {
// // We need to wrap these calls in a @UiThread rather than make them each a @UiThread themselves
// // because they need to run sequentially in a configuration change scenario in order for Android
// // to maintain scroll position on the fragment adapter.
// showChannelFilters();
// onFeedSelected(selectedFilter);
// }
// @UiThread
// protected void onCommunicationError(DaemonException daemonException) {
// //noinspection ThrowableResultOfMethodCallIgnored
// log.i(this, daemonException.toString());
// String error = getString(LocalTorrent.getResourceForDaemonException(daemonException));
// SnackbarManager.show(Snackbar.with(this).text(error).colorResource(R.color.red).type(SnackbarType.MULTI_LINE));
// }
@TargetApi(Build.VERSION_CODES.HONEYCOMB) @TargetApi(Build.VERSION_CODES.HONEYCOMB)
@ -208,49 +208,49 @@ public class RemoteRssActivity extends AppCompatActivity implements RefreshableA
} }
} }
private void showChannelFilters() { private void showChannelFilters() {
List<RemoteRssChannel> feedLabels = new ArrayList<>(feeds.size() +1); // List<RemoteRssChannel> feedLabels = new ArrayList<>(feeds.size() +1);
feedLabels.add(new RemoteRssChannel() { // feedLabels.add(new RemoteRssChannel() {
@Override // @Override
public String getName() { // public String getName() {
return getString(R.string.remoterss_filter_allrecent); // return getString(R.string.remoterss_filter_allrecent);
} // }
//
@Override // @Override
public void writeToParcel(Parcel dest, int flags) { // public void writeToParcel(Parcel dest, int flags) {
} // }
}); // });
feedLabels.addAll(feeds); // feedLabels.addAll(feeds);
//
drawerList.setAdapter(new SimpleListItemAdapter(this, feedLabels)); // drawerList.setAdapter(new SimpleListItemAdapter(this, feedLabels));
} }
@ItemClick(R.id.drawer_list) // @ItemClick(R.id.drawer_list)
protected void onFeedSelected(int position) { // protected void onFeedSelected(int position) {
selectedFilter = position; // selectedFilter = position;
fragmentRemoteRss.updateRemoteItems(position == 0 ? recentItems : feeds.get(position - 1).getItems(), true); // fragmentRemoteRss.updateRemoteItems(position == 0 ? recentItems : feeds.get(position - 1).getItems(), true);
//
RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position); // RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position);
getSupportActionBar().setSubtitle(channel.getName()); // getSupportActionBar().setSubtitle(channel.getName());
//
drawerLayout.closeDrawers(); // drawerLayout.closeDrawers();
} // }
public IDaemonAdapter getCurrentConnection() { // public IDaemonAdapter getCurrentConnection() {
return currentConnection; // return currentConnection;
} // }
public RemoteRssChannel getChannel(String name) { // public RemoteRssChannel getChannel(String name) {
for (RemoteRssChannel feed : feeds) { // for (RemoteRssChannel feed : feeds) {
if (feed.getName().equals(name)) { // if (feed.getName().equals(name)) {
return feed; // return feed;
} // }
} // }
return null; // return null;
} // }
@Override // @Override
public void refreshScreen() { // public void refreshScreen() {
loadFeeds(); // loadFeeds();
} // }
} }

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

@ -17,7 +17,7 @@
package org.transdroid.core.gui.remoterss; package org.transdroid.core.gui.remoterss;
import android.app.Fragment; import android.support.v4.app.Fragment;
import android.support.v4.widget.SwipeRefreshLayout; import android.support.v4.widget.SwipeRefreshLayout;
import android.support.v7.widget.ActionMenuView; import android.support.v7.widget.ActionMenuView;
import android.view.View; import android.view.View;
@ -41,6 +41,7 @@ import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.RefreshableActivity; import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.remoterss.data.RemoteRssItem; import org.transdroid.core.gui.remoterss.data.RemoteRssItem;
import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier; import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier;
import org.transdroid.core.gui.rss.RssfeedsActivity;
import org.transdroid.daemon.DaemonException; import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.task.DaemonTaskSuccessResult; import org.transdroid.daemon.task.DaemonTaskSuccessResult;
@ -66,8 +67,6 @@ public class RemoteRssFragment extends Fragment {
@ViewById(R.id.contextual_menu) @ViewById(R.id.contextual_menu)
protected ActionMenuView contextualMenu; protected ActionMenuView contextualMenu;
@ViewById @ViewById
protected SwipeRefreshLayout swipeRefreshLayout;
@ViewById
protected ListView torrentsList; protected ListView torrentsList;
@ViewById @ViewById
protected TextView remoterssStatusMessage; protected TextView remoterssStatusMessage;
@ -94,16 +93,12 @@ public class RemoteRssFragment extends Fragment {
adapter = new RemoteRssItemsAdapter(getActivity()); adapter = new RemoteRssItemsAdapter(getActivity());
torrentsList.setAdapter(adapter); torrentsList.setAdapter(adapter);
torrentsList.setFastScrollEnabled(true); torrentsList.setFastScrollEnabled(true);
}
// Allow pulls on the list view to refresh the torrents @Override
if (getActivity() != null && getActivity() instanceof RefreshableActivity) { public void onResume() {
swipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { super.onResume();
@Override ((RssfeedsActivity) getActivity()).refreshRemoteFeeds();
public void onRefresh() {
((RefreshableActivity) getActivity()).refreshScreen();
}
});
}
} }
/** /**
@ -123,12 +118,6 @@ public class RemoteRssFragment extends Fragment {
remoterssStatusMessage.setVisibility(View.VISIBLE); remoterssStatusMessage.setVisibility(View.VISIBLE);
remoterssStatusMessage.setText(R.string.remoterss_no_files); remoterssStatusMessage.setText(R.string.remoterss_no_files);
} }
swipeRefreshLayout.setRefreshing(false);
}
@UiThread
public void setRefreshing(boolean refreshing) {
swipeRefreshLayout.setRefreshing(refreshing);
} }
/** /**
@ -137,36 +126,38 @@ public class RemoteRssFragment extends Fragment {
@ItemClick(resName = "torrents_list") @ItemClick(resName = "torrents_list")
protected void detailsListClicked(int position) { protected void detailsListClicked(int position) {
RemoteRssItem item = (RemoteRssItem) adapter.getItem(position); RemoteRssItem item = (RemoteRssItem) adapter.getItem(position);
downloadRemoteRssItem(item); // downloadRemoteRssItem(item);
}
/** ((RssfeedsActivity) getActivity()).downloadRemoteRssItem(item);
* Download the item in a background thread and display success/fail accordingly.
*/
@Background
protected void downloadRemoteRssItem(RemoteRssItem item) {
final RemoteRssActivity activity = (RemoteRssActivity) getActivity();
final RemoteRssSupplier supplier = (RemoteRssSupplier) activity.getCurrentConnection();
try {
supplier.downloadRemoteRssItem(log, item, activity.getChannel(item.getSourceName()));
onTaskSucceeded(null, getString(R.string.result_added, item.getTitle()));
} catch (DaemonException e) {
onTaskFailed(getString(LocalTorrent.getResourceForDaemonException(e)));
}
}
@UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
SnackbarManager.show(Snackbar.with(getActivity()).text(successMessage));
} }
@UiThread // /**
protected void onTaskFailed(String message) { // * Download the item in a background thread and display success/fail accordingly.
SnackbarManager.show(Snackbar.with(getActivity()) // */
.text(message) // @Background
.colorResource(R.color.red) // protected void downloadRemoteRssItem(RemoteRssItem item) {
.type(SnackbarType.MULTI_LINE) // final RemoteRssActivity activity = (RemoteRssActivity) getActivity();
); // final RemoteRssSupplier supplier = (RemoteRssSupplier) activity.getCurrentConnection();
} //
// try {
// supplier.downloadRemoteRssItem(log, item, activity.getChannel(item.getSourceName()));
// onTaskSucceeded(null, getString(R.string.result_added, item.getTitle()));
// } catch (DaemonException e) {
// onTaskFailed(getString(LocalTorrent.getResourceForDaemonException(e)));
// }
// }
//
// @UiThread
// protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
// SnackbarManager.show(Snackbar.with(getActivity()).text(successMessage));
// }
//
// @UiThread
// protected void onTaskFailed(String message) {
// SnackbarManager.show(Snackbar.with(getActivity())
// .text(message)
// .colorResource(R.color.red)
// .type(SnackbarType.MULTI_LINE)
// );
// }
} }

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

@ -33,26 +33,43 @@ import android.text.TextUtils;
import com.nispok.snackbar.Snackbar; import com.nispok.snackbar.Snackbar;
import com.nispok.snackbar.SnackbarManager; import com.nispok.snackbar.SnackbarManager;
import com.nispok.snackbar.enums.SnackbarType;
import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Background; import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity; import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.FragmentById; import org.androidannotations.annotations.FragmentById;
import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.NonConfigurationInstance;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
import org.androidannotations.annotations.UiThread; import org.androidannotations.annotations.UiThread;
import org.androidannotations.annotations.ViewById; import org.androidannotations.annotations.ViewById;
import org.transdroid.R; import org.transdroid.R;
import org.transdroid.core.app.settings.ApplicationSettings; import org.transdroid.core.app.settings.ApplicationSettings;
import org.transdroid.core.app.settings.RssfeedSetting; import org.transdroid.core.app.settings.RssfeedSetting;
import org.transdroid.core.app.settings.ServerSetting;
import org.transdroid.core.app.settings.SystemSettings_; import org.transdroid.core.app.settings.SystemSettings_;
import org.transdroid.core.gui.TorrentsActivity_; import org.transdroid.core.gui.TorrentsActivity_;
import org.transdroid.core.gui.lists.LocalTorrent;
import org.transdroid.core.gui.log.Log; import org.transdroid.core.gui.log.Log;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.remoterss.RemoteRssFragment;
import org.transdroid.core.gui.remoterss.RemoteRssFragment_;
import org.transdroid.core.gui.remoterss.data.RemoteRssChannel;
import org.transdroid.core.gui.remoterss.data.RemoteRssItem;
import org.transdroid.core.gui.remoterss.data.RemoteRssSupplier;
import org.transdroid.core.rssparser.Channel; import org.transdroid.core.rssparser.Channel;
import org.transdroid.core.rssparser.RssParser; import org.transdroid.core.rssparser.RssParser;
import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.daemon.DaemonException;
import org.transdroid.daemon.IDaemonAdapter;
import org.transdroid.daemon.task.DaemonTaskSuccessResult;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Calendar;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -64,10 +81,12 @@ public class RssfeedsActivity extends AppCompatActivity {
protected Log log; protected Log log;
@Bean @Bean
protected ApplicationSettings applicationSettings; protected ApplicationSettings applicationSettings;
protected List<RssfeedLoader> loaders; protected List<RssfeedLoader> loaders;
// Contained feeds and items fragments // Contained feeds and items fragments
protected RssfeedsFragment fragmentFeeds; protected RssfeedsFragment fragmentFeeds;
protected RemoteRssFragment fragmentRemoteFeeds;
@FragmentById(R.id.rssitems_fragment) @FragmentById(R.id.rssitems_fragment)
protected RssitemsFragment fragmentItems; protected RssitemsFragment fragmentItems;
@ViewById @ViewById
@ -80,6 +99,17 @@ public class RssfeedsActivity extends AppCompatActivity {
protected static final int RSS_FEEDS_LOCAL = 0; protected static final int RSS_FEEDS_LOCAL = 0;
protected static final int RSS_FEEDS_REMOTE = 1; protected static final int RSS_FEEDS_REMOTE = 1;
// remote RSS stuff
@NonConfigurationInstance
protected ArrayList<RemoteRssChannel> feeds;
@InstanceState
protected int selectedFilter;
@NonConfigurationInstance
protected ArrayList<RemoteRssItem> recentItems;
@Bean
protected ConnectivityHelper connectivityHelper;
class PagerAdapter extends FragmentPagerAdapter { class PagerAdapter extends FragmentPagerAdapter {
public PagerAdapter(FragmentManager fm) { public PagerAdapter(FragmentManager fm) {
super(fm); super(fm);
@ -93,7 +123,7 @@ public class RssfeedsActivity extends AppCompatActivity {
fragment = fragmentFeeds; fragment = fragmentFeeds;
} }
else if (position == RSS_FEEDS_REMOTE) { else if (position == RSS_FEEDS_REMOTE) {
fragment = null; fragment = fragmentRemoteFeeds;
} }
return fragment; return fragment;
@ -134,7 +164,7 @@ public class RssfeedsActivity extends AppCompatActivity {
getSupportActionBar().setDisplayHomeAsUpEnabled(true); getSupportActionBar().setDisplayHomeAsUpEnabled(true);
fragmentFeeds = RssfeedsFragment_.builder().build(); fragmentFeeds = RssfeedsFragment_.builder().build();
fragmentItems = RssitemsFragment_.builder().build(); fragmentRemoteFeeds = RemoteRssFragment_.builder().build();
PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager()); PagerAdapter pagerAdapter = new PagerAdapter(getSupportFragmentManager());
viewPager.setAdapter(pagerAdapter); viewPager.setAdapter(pagerAdapter);
@ -180,7 +210,6 @@ public class RssfeedsActivity extends AppCompatActivity {
handleRssfeedResult(loader, null, true); handleRssfeedResult(loader, null, true);
log.i(this, "RSS feed " + loader.getSetting().getUrl() + " error: " + e.toString()); log.i(this, "RSS feed " + loader.getSetting().getUrl() + " error: " + e.toString());
} }
} }
/** /**
@ -250,7 +279,112 @@ public class RssfeedsActivity extends AppCompatActivity {
.requiresExternalAuthentication(loader.getSetting().requiresExternalAuthentication()).start(); .requiresExternalAuthentication(loader.getSetting().requiresExternalAuthentication()).start();
} }
}
protected IDaemonAdapter getCurrentConnection() {
ServerSetting lastUsed = applicationSettings.getLastUsedServer();
return lastUsed.createServerAdapter(connectivityHelper.getConnectedNetworkName(), this);
}
public void refreshRemoteFeeds() {
// Connect to the last used server
IDaemonAdapter currentConnection = this.getCurrentConnection();
// remote rss not supported for this connection type
if (currentConnection instanceof RemoteRssSupplier == false) {
return;
}
try {
feeds = ((RemoteRssSupplier) (currentConnection)).getRemoteRssChannels(log);
// loadFeeds() in background
recentItems = new ArrayList<>();
Calendar calendar = Calendar.getInstance();
calendar.add(Calendar.MONTH, -1);
Date oneMonthAgo = calendar.getTime();
for (RemoteRssChannel feed : feeds) {
for (RemoteRssItem item : feed.getItems()) {
if (item.getTimestamp().after(oneMonthAgo)) {
recentItems.add(item);
}
}
}
// Sort by -newest
Collections.sort(recentItems, new Comparator<RemoteRssItem>() {
@Override
public int compare(RemoteRssItem lhs, RemoteRssItem rhs) {
return rhs.getTimestamp().compareTo(lhs.getTimestamp());
}
});
} catch (DaemonException e) {
onCommunicationError(e);
return;
}
// if (feeds != null) {
// Called from a configuration change. No need to load anything from server
// showChannelFilters();
fragmentRemoteFeeds.updateRemoteItems(
// selectedFilter == 0 ? recentItems : feeds.get(selectedFilter).getItems(),
recentItems,
false /* allow android to restore scroll position */ );
// } else {
// loadFeeds();
// }
}
@UiThread
protected void onCommunicationError(DaemonException daemonException) {
//noinspection ThrowableResultOfMethodCallIgnored
log.i(this, daemonException.toString());
String error = getString(LocalTorrent.getResourceForDaemonException(daemonException));
SnackbarManager.show(Snackbar.with(this).text(error).colorResource(R.color.red).type(SnackbarType.MULTI_LINE));
}
// @ItemClick(R.id.drawer_list)
protected void onFeedSelected(int position) {
selectedFilter = position;
RemoteRssChannel channel = feeds.get(position);
fragmentRemoteFeeds.updateRemoteItems(position == 0 ? recentItems : channel.getItems(), true);
// RemoteRssChannel channel = (RemoteRssChannel) drawerList.getAdapter().getItem(position);
// getSupportActionBar().setSubtitle(channel.getName());
// drawerLayout.closeDrawers();
}
/**
* Download the item in a background thread and display success/fail accordingly.
*/
@Background
public void downloadRemoteRssItem(RemoteRssItem item) {
final RemoteRssSupplier supplier = (RemoteRssSupplier) this.getCurrentConnection();
try {
RemoteRssChannel channel = feeds.get(selectedFilter);
supplier.downloadRemoteRssItem(log, item, channel);
onTaskSucceeded(null, getString(R.string.result_added, item.getTitle()));
} catch (DaemonException e) {
onTaskFailed(getString(LocalTorrent.getResourceForDaemonException(e)));
}
}
@UiThread
protected void onTaskSucceeded(DaemonTaskSuccessResult result, String successMessage) {
SnackbarManager.show(Snackbar.with(this).text(successMessage));
} }
@UiThread
protected void onTaskFailed(String message) {
SnackbarManager.show(Snackbar.with(this)
.text(message)
.colorResource(R.color.red)
.type(SnackbarType.MULTI_LINE)
);
}
} }

17
app/src/main/res/layout/fragment_remoterss.xml

@ -27,16 +27,11 @@
android:gravity="center" android:gravity="center"
android:id="@+id/remoterss_status_message"/> android:id="@+id/remoterss_status_message"/>
<android.support.v4.widget.SwipeRefreshLayout <ListView
android:id="@+id/swipe_refresh_layout" android:id="@+id/torrents_list"
android:layout_width="match_parent" android:layout_width="match_parent"
android:layout_height="match_parent"> android:layout_height="match_parent"
<ListView android:clipToPadding="false"
android:id="@+id/torrents_list" tools:listitem="@layout/list_item_remoterssitem"
android:layout_width="match_parent" tools:visibility="visible"/>
android:layout_height="match_parent"
android:clipToPadding="false"
tools:listitem="@layout/list_item_remoterssitem"
tools:visibility="visible"/>
</android.support.v4.widget.SwipeRefreshLayout>
</FrameLayout> </FrameLayout>

Loading…
Cancel
Save