Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/shutdown after download closing after one download #145

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ public void fragmentFinished(Intent intent, ResultCode code)
/* If add torrent dialog has been called by an implicit intent */
if (getIntent().getData() != null && intent.hasExtra(TAG_RESULT_TORRENT)) {
Intent i = new Intent(getApplicationContext(), MainActivity.class);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
i.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP);
i.putExtra(TAG_RESULT_TORRENT, intent.getParcelableExtra(TAG_RESULT_TORRENT));
startActivity(i);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,20 +530,30 @@ public void onTorrentFinished(String id)
moveTorrent(torrent);
}

if (pref.getBoolean(getString(R.string.pref_key_shutdown_downloads_complete),
SettingsManager.Default.shutdownDownloadsComplete)) {
if (torrentsFinished()
&& pref.getBoolean(
getString(R.string.pref_key_shutdown_downloads_complete),
SettingsManager.Default.shutdownDownloadsComplete)) {
if (torrentsMoveTotal != null) {
shutdownAfterMove = true;
} else {
Intent shutdownIntent =
new Intent(getApplicationContext(), NotificationReceiver.class);
Intent shutdownIntent = new Intent(getApplicationContext(), NotificationReceiver.class);
shutdownIntent.setAction(NotificationReceiver.NOTIFY_ACTION_SHUTDOWN_APP);
sendBroadcast(shutdownIntent);
}
}
}
}

private boolean torrentsFinished() {
for (TorrentDownload torrentDownload : TorrentEngine.getInstance().getTasks()) {
if (torrentDownload.getStateCode().equals(TorrentStateCode.DOWNLOADING)) {
return false;
}
}
return true;
}

@Override
public void onTorrentMoved(String id, boolean success)
{
Expand Down