Browse Source

Click on empty/error messages refreshes the torrents and details screens. Fixes #20.

pull/82/head
Eric Kok 11 years ago
parent
commit
cd44899f83
  1. 13
      core/res/layout/fragment_details.xml
  2. 38
      core/src/org/transdroid/core/gui/DetailsActivity.java
  3. 39
      core/src/org/transdroid/core/gui/DetailsFragment.java
  4. 5
      core/src/org/transdroid/core/gui/TorrentTasksExecutor.java
  5. 12
      core/src/org/transdroid/core/gui/TorrentsActivity.java
  6. 18
      core/src/org/transdroid/core/gui/TorrentsFragment.java
  7. 28
      core/src/org/transdroid/core/gui/navigation/RefreshableActivity.java
  8. 4
      core/src/org/transdroid/core/service/ConnectivityHelper.java

13
core/res/layout/fragment_details.xml

@ -52,4 +52,17 @@
android:textIsSelectable="false" android:textIsSelectable="false"
android:visibility="visible" /> android:visibility="visible" />
<TextView
android:id="@+id/error_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:drawablePadding="8dip"
android:drawableTop="?attr/loading_progress"
android:gravity="center"
android:maxWidth="400dip"
android:padding="@dimen/margin_default"
android:textIsSelectable="false"
android:visibility="gone" />
</FrameLayout> </FrameLayout>

38
core/src/org/transdroid/core/gui/DetailsActivity.java

@ -35,6 +35,7 @@ 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.Label; import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.service.ConnectivityHelper; import org.transdroid.core.service.ConnectivityHelper;
import org.transdroid.daemon.Daemon; import org.transdroid.daemon.Daemon;
import org.transdroid.daemon.IDaemonAdapter; import org.transdroid.daemon.IDaemonAdapter;
@ -79,7 +80,7 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/ */
@EActivity(resName = "activity_details") @EActivity(resName = "activity_details")
@OptionsMenu(resName = "activity_details") @OptionsMenu(resName = "activity_details")
public class DetailsActivity extends SherlockFragmentActivity implements TorrentTasksExecutor { public class DetailsActivity extends SherlockFragmentActivity implements TorrentTasksExecutor, RefreshableActivity {
@Extra @Extra
@InstanceState @InstanceState
@ -148,8 +149,8 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
} }
@OptionsItem(resName = "action_refresh") @OptionsItem(resName = "action_refresh")
protected void refreshScreen() { public void refreshScreen() {
fragmentDetails.updateIsLoading(true); fragmentDetails.updateIsLoading(true, null);
refreshTorrent(); refreshTorrent();
refreshTorrentDetails(torrent); refreshTorrentDetails(torrent);
refreshTorrentFiles(torrent); refreshTorrentFiles(torrent);
@ -162,7 +163,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(), onTorrentsRetrieved(((RetrieveTaskSuccessResult) result).getTorrents(),
((RetrieveTaskSuccessResult) result).getLabels()); ((RetrieveTaskSuccessResult) result).getLabels());
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, true);
} }
} }
@ -174,7 +175,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof GetTorrentDetailsTaskSuccessResult) { if (result instanceof GetTorrentDetailsTaskSuccessResult) {
onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails()); onTorrentDetailsRetrieved(torrent, ((GetTorrentDetailsTaskSuccessResult) result).getTorrentDetails());
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -186,7 +187,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof GetFileListTaskSuccessResult) { if (result instanceof GetFileListTaskSuccessResult) {
onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles()); onTorrentFilesRetrieved(torrent, ((GetFileListTaskSuccessResult) result).getFiles());
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -198,7 +199,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_resumed, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -210,7 +211,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_paused, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -222,7 +223,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_started, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -234,7 +235,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName())); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_stopped, torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -247,7 +248,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed, closeActivity(getString(withData ? R.string.result_removed_with_data : R.string.result_removed,
torrent.getName())); torrent.getName()));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -267,7 +268,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_labelset, newLabel));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -278,7 +279,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_trackersupdated));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -289,7 +290,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_locationset, newLocation));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -301,7 +302,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
if (result instanceof DaemonTaskResult) { if (result instanceof DaemonTaskResult) {
onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset)); onTaskSucceeded((DaemonTaskSuccessResult) result, getString(R.string.result_priotitiesset));
} else { } else {
onCommunicationError((DaemonTaskFailureResult) result); onCommunicationError((DaemonTaskFailureResult) result, false);
} }
} }
@ -326,9 +327,10 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
} }
@UiThread @UiThread
protected void onCommunicationError(DaemonTaskFailureResult result) { protected void onCommunicationError(DaemonTaskFailureResult result, boolean isCritical) {
Log.i(this, result.getException().toString()); Log.i(this, result.getException().toString());
fragmentDetails.updateIsLoading(false); String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
fragmentDetails.updateIsLoading(false, isCritical? error: null);
Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())), Crouton.showText(this, getString(LocalTorrent.getResourceForDaemonException(result.getException())),
NavigationHelper.CROUTON_ERROR_STYLE); NavigationHelper.CROUTON_ERROR_STYLE);
} }
@ -336,7 +338,7 @@ public class DetailsActivity extends SherlockFragmentActivity implements Torrent
@UiThread @UiThread
protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) { protected void onTorrentsRetrieved(List<Torrent> torrents, List<org.transdroid.daemon.Label> labels) {
// Update the details fragment accordingly // Update the details fragment accordingly
fragmentDetails.updateIsLoading(false); fragmentDetails.updateIsLoading(false, null);
fragmentDetails.perhapsUpdateTorrent(torrents); fragmentDetails.perhapsUpdateTorrent(torrents);
fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels, fragmentDetails.updateLabels(Label.convertToNavigationLabels(labels,
getResources().getString(R.string.labels_unlabeled))); getResources().getString(R.string.labels_unlabeled)));

39
core/src/org/transdroid/core/gui/DetailsFragment.java

@ -21,6 +21,7 @@ import java.util.Collections;
import java.util.List; import java.util.List;
import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment; import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.InstanceState; import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.OptionsItem; import org.androidannotations.annotations.OptionsItem;
@ -34,6 +35,7 @@ import org.transdroid.core.gui.lists.SimpleListItemAdapter;
import org.transdroid.core.gui.navigation.Label; import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationHelper; import org.transdroid.core.gui.navigation.NavigationHelper;
import org.transdroid.core.gui.navigation.NavigationHelper_; import org.transdroid.core.gui.navigation.NavigationHelper_;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.navigation.SetLabelDialog; import org.transdroid.core.gui.navigation.SetLabelDialog;
import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener; import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener;
@ -85,13 +87,15 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
protected ArrayList<Label> currentLabels = null; protected ArrayList<Label> currentLabels = null;
@InstanceState @InstanceState
protected boolean isLoadingTorrent = false; protected boolean isLoadingTorrent = false;
@InstanceState
protected boolean hasCriticalError = false;
private ServerSetting currentServerSettings = null; private ServerSetting currentServerSettings = null;
// Views // Views
@ViewById(resName = "details_list") @ViewById(resName = "details_list")
protected SherlockListView detailsList; protected SherlockListView detailsList;
@ViewById @ViewById
protected TextView emptyText; protected TextView emptyText, errorText;
@ViewById @ViewById
protected ProgressBar loadingProgress; protected ProgressBar loadingProgress;
@ -128,19 +132,22 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
/** /**
* Updates the details adapter header to show the new torrent data. * Updates the details adapter header to show the new torrent data.
* @param newTorrent The new torrent object * @param newTorrent The new, non-null torrent object
*/ */
public void updateTorrent(Torrent newTorrent) { public void updateTorrent(Torrent newTorrent) {
clear();
this.torrent = newTorrent; this.torrent = newTorrent;
this.hasCriticalError = false;
((DetailsAdapter) detailsList.getAdapter()).updateTorrent(newTorrent); ((DetailsAdapter) detailsList.getAdapter()).updateTorrent(newTorrent);
// Make the list (with details header) visible // Make the list (with details header) visible
detailsList.setVisibility(View.VISIBLE); detailsList.setVisibility(View.VISIBLE);
emptyText.setVisibility(View.GONE); emptyText.setVisibility(View.GONE);
errorText.setVisibility(View.GONE);
loadingProgress.setVisibility(View.GONE); loadingProgress.setVisibility(View.GONE);
// Also update the available actions in the action bar // Also update the available actions in the action bar
getActivity().supportInvalidateOptionsMenu(); getActivity().supportInvalidateOptionsMenu();
// Refresh the detailed statistics (errors) and list of files // Refresh the detailed statistics (errors) and list of files
torrentDetails = null;
torrentFiles = null;
getTasksExecutor().refreshTorrentDetails(torrent); getTasksExecutor().refreshTorrentDetails(torrent);
getTasksExecutor().refreshTorrentFiles(torrent); getTasksExecutor().refreshTorrentFiles(torrent);
} }
@ -208,7 +215,8 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
public void clear() { public void clear() {
detailsList.setAdapter(new DetailsAdapter(getActivity())); detailsList.setAdapter(new DetailsAdapter(getActivity()));
detailsList.setVisibility(View.GONE); detailsList.setVisibility(View.GONE);
emptyText.setVisibility(!isLoadingTorrent ? View.VISIBLE : View.GONE); emptyText.setVisibility(!isLoadingTorrent && !hasCriticalError ? View.VISIBLE : View.GONE);
errorText.setVisibility(!isLoadingTorrent && hasCriticalError ? View.VISIBLE : View.GONE);
loadingProgress.setVisibility(isLoadingTorrent ? View.VISIBLE : View.GONE); loadingProgress.setVisibility(isLoadingTorrent ? View.VISIBLE : View.GONE);
// Note: this.torrent is not cleared as we need to know later what the fragment was originally bound to // Note: this.torrent is not cleared as we need to know later what the fragment was originally bound to
torrentDetails = null; torrentDetails = null;
@ -218,10 +226,13 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
/** /**
* Updates the shown screen depending on whether the torrent is loading * Updates the shown screen depending on whether the torrent is loading
* @param isLoading True if the torrent is (re)loading, false otherwise * @param isLoading True if the torrent is (re)loading, false otherwise
* @param connectionErrorMessage The error message text to show to the user, or null if there was no error
*/ */
public void updateIsLoading(boolean isLoading) { public void updateIsLoading(boolean isLoading, String connectionErrorMessage) {
this.isLoadingTorrent = isLoading; this.isLoadingTorrent = isLoading;
if (isLoadingTorrent) this.hasCriticalError = connectionErrorMessage != null;
errorText.setText(connectionErrorMessage);
if (isLoading || hasCriticalError)
clear(); clear();
} }
@ -330,6 +341,22 @@ public class DetailsFragment extends SherlockFragment implements OnTrackersUpdat
getTasksExecutor().updateLocation(torrent, newLocation); getTasksExecutor().updateLocation(torrent, newLocation);
} }
@Click
protected void emptyTextClicked() {
// Refresh the activity (that contains this fragment) when the empty view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
@Click
protected void errorTextClicked() {
// Refresh the activity (that contains this fragment) when the error view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
private MultiChoiceModeListenerCompat onDetailsSelected = new MultiChoiceModeListenerCompat() { private MultiChoiceModeListenerCompat onDetailsSelected = new MultiChoiceModeListenerCompat() {
SelectionManagerMode selectionManagerMode; SelectionManagerMode selectionManagerMode;

5
core/src/org/transdroid/core/gui/TorrentTasksExecutor.java

@ -22,6 +22,11 @@ import org.transdroid.daemon.Priority;
import org.transdroid.daemon.Torrent; import org.transdroid.daemon.Torrent;
import org.transdroid.daemon.TorrentFile; import org.transdroid.daemon.TorrentFile;
/**
* Interface to be implemented by any activity that wants containing fragments to be able to load data and execute
* commands against a torrent server.
* @author Eric Kok
*/
public interface TorrentTasksExecutor { public interface TorrentTasksExecutor {
void resumeTorrent(Torrent torrent); void resumeTorrent(Torrent torrent);
void pauseTorrent(Torrent torrent); void pauseTorrent(Torrent torrent);

12
core/src/org/transdroid/core/gui/TorrentsActivity.java

@ -122,7 +122,8 @@ import de.keyboardsurfer.android.widget.crouton.Crouton;
*/ */
@EActivity(resName = "activity_torrents") @EActivity(resName = "activity_torrents")
@OptionsMenu(resName = "activity_torrents") @OptionsMenu(resName = "activity_torrents")
public class TorrentsActivity extends SherlockFragmentActivity implements OnNavigationListener, TorrentTasksExecutor { public class TorrentsActivity extends SherlockFragmentActivity implements OnNavigationListener, TorrentTasksExecutor,
RefreshableActivity {
// Navigation components // Navigation components
@Bean @Bean
@ -385,6 +386,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
// Clear the currently shown list of torrents and perhaps the details // Clear the currently shown list of torrents and perhaps the details
fragmentTorrents.clear(true, true); fragmentTorrents.clear(true, true);
if (fragmentDetails != null && fragmentDetails.getActivity() != null) { if (fragmentDetails != null && fragmentDetails.getActivity() != null) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear(); fragmentDetails.clear();
fragmentDetails.setCurrentServerSettings(server); fragmentDetails.setCurrentServerSettings(server);
} }
@ -401,6 +403,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
navigationSpinnerAdapter.updateCurrentFilter(currentFilter); navigationSpinnerAdapter.updateCurrentFilter(currentFilter);
// Clear the details view // Clear the details view
if (fragmentDetails != null) { if (fragmentDetails != null) {
fragmentDetails.updateIsLoading(false, null);
fragmentDetails.clear(); fragmentDetails.clear();
} }
} }
@ -547,7 +550,7 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
} }
@OptionsItem(resName = "action_refresh") @OptionsItem(resName = "action_refresh")
protected void refreshScreen() { public void refreshScreen() {
fragmentTorrents.updateIsLoading(true); fragmentTorrents.updateIsLoading(true);
refreshTorrents(); refreshTorrents();
if (Daemon.supportsStats(currentConnection.getType())) if (Daemon.supportsStats(currentConnection.getType()))
@ -942,8 +945,11 @@ public class TorrentsActivity extends SherlockFragmentActivity implements OnNavi
String error = getString(LocalTorrent.getResourceForDaemonException(result.getException())); String error = getString(LocalTorrent.getResourceForDaemonException(result.getException()));
Crouton.showText(this, error, NavigationHelper.CROUTON_ERROR_STYLE); Crouton.showText(this, error, NavigationHelper.CROUTON_ERROR_STYLE);
fragmentTorrents.updateIsLoading(false); fragmentTorrents.updateIsLoading(false);
if (isCritical) if (isCritical) {
fragmentTorrents.updateError(error); fragmentTorrents.updateError(error);
if (fragmentDetails != null)
fragmentDetails.updateIsLoading(false, error);
}
} }
@UiThread @UiThread

18
core/src/org/transdroid/core/gui/TorrentsFragment.java

@ -23,6 +23,7 @@ import java.util.Locale;
import org.androidannotations.annotations.AfterViews; import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean; import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.Click;
import org.androidannotations.annotations.EFragment; import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.InstanceState; import org.androidannotations.annotations.InstanceState;
import org.androidannotations.annotations.ItemClick; import org.androidannotations.annotations.ItemClick;
@ -33,6 +34,7 @@ import org.transdroid.core.gui.lists.TorrentsAdapter;
import org.transdroid.core.gui.lists.TorrentsAdapter_; import org.transdroid.core.gui.lists.TorrentsAdapter_;
import org.transdroid.core.gui.navigation.Label; import org.transdroid.core.gui.navigation.Label;
import org.transdroid.core.gui.navigation.NavigationFilter; import org.transdroid.core.gui.navigation.NavigationFilter;
import org.transdroid.core.gui.navigation.RefreshableActivity;
import org.transdroid.core.gui.navigation.SelectionManagerMode; import org.transdroid.core.gui.navigation.SelectionManagerMode;
import org.transdroid.core.gui.navigation.SetLabelDialog; import org.transdroid.core.gui.navigation.SetLabelDialog;
import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener; import org.transdroid.core.gui.navigation.SetLabelDialog.OnLabelPickedListener;
@ -304,6 +306,22 @@ public class TorrentsFragment extends SherlockFragment implements OnLabelPickedL
}; };
@Click
protected void emptyTextClicked() {
// Refresh the activity (that contains this fragment) when the empty view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
@Click
protected void errorTextClicked() {
// Refresh the activity (that contains this fragment) when the error view gear is clicked
if (getActivity() != null && getActivity() instanceof RefreshableActivity) {
((RefreshableActivity) getActivity()).refreshScreen();
}
}
@ItemClick(resName = "torrent_list") @ItemClick(resName = "torrent_list")
protected void torrentsListClicked(Torrent torrent) { protected void torrentsListClicked(Torrent torrent) {
((TorrentsActivity) getActivity()).openDetails(torrent); ((TorrentsActivity) getActivity()).openDetails(torrent);

28
core/src/org/transdroid/core/gui/navigation/RefreshableActivity.java

@ -0,0 +1,28 @@
/*
* Copyright 2010-2013 Eric Kok et al.
*
* Transdroid is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Transdroid is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Transdroid. If not, see <http://www.gnu.org/licenses/>.
*/
package org.transdroid.core.gui.navigation;
/**
* Interface to be implemented by any activity that allows its content to be refreshed; fragments can ask for
* user-initiated refreshes.
* @author Eric Kok
*/
public interface RefreshableActivity {
public void refreshScreen();
}

4
core/src/org/transdroid/core/service/ConnectivityHelper.java

@ -42,7 +42,8 @@ public class ConnectivityHelper {
return false; return false;
// Still good? Check the current active network instead // Still good? Check the current active network instead
return connectivityManager.getActiveNetworkInfo().isConnected(); return connectivityManager.getActiveNetworkInfo() != null
&& connectivityManager.getActiveNetworkInfo().isConnected();
} }
public String getConnectedNetworkName() { public String getConnectedNetworkName() {
@ -51,4 +52,5 @@ public class ConnectivityHelper {
} }
return null; return null;
} }
} }

Loading…
Cancel
Save