Browse Source

Miscellaneous Java lint cleanup

pull/559/head
TacoTheDank 4 years ago
parent
commit
9d2e11a8df
  1. 3
      app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java
  2. 12
      app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java
  3. 5
      app/src/main/java/org/transdroid/core/gui/lists/MergeAdapter.java
  4. 4
      app/src/main/java/org/transdroid/core/gui/lists/PiecesMapView.java
  5. 2
      app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemAdapter.java
  6. 4
      app/src/main/java/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java
  7. 4
      app/src/main/java/org/transdroid/core/gui/lists/TorrentStatusLayout.java
  8. 2
      app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java
  9. 2
      app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemAdapter.java
  10. 2
      app/src/main/java/org/transdroid/core/gui/navigation/SelectionModificationSpinner.java
  11. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java
  12. 5
      app/src/main/java/org/transdroid/core/gui/rss/RssfeedLoader.java
  13. 4
      app/src/main/java/org/transdroid/core/gui/rss/RssitemStatusLayout.java
  14. 2
      app/src/main/java/org/transdroid/core/gui/search/SearchSettingsDropDownAdapter.java
  15. 25
      app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java
  16. 16
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedPreference.java
  17. 19
      app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java
  18. 16
      app/src/main/java/org/transdroid/core/gui/settings/ServerPreference.java
  19. 19
      app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java
  20. 16
      app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java
  21. 19
      app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java
  22. 16
      app/src/main/java/org/transdroid/core/seedbox/SeedboxPreference.java
  23. 5
      app/src/main/java/org/transdroid/core/service/ServerCheckerJobRunner.java
  24. 4
      app/src/main/java/org/transdroid/daemon/DaemonSettings.java
  25. 7
      app/src/main/java/org/transdroid/daemon/DummyAdapter.java
  26. 12
      app/src/main/java/org/transdroid/daemon/TorrentDetails.java
  27. 8
      app/src/main/java/org/transdroid/daemon/TorrentFilesComparator.java
  28. 28
      app/src/main/java/org/transdroid/daemon/TorrentsComparator.java
  29. 10
      app/src/main/java/org/transdroid/daemon/adapters/bitComet/BitCometAdapter.java
  30. 8
      app/src/main/java/org/transdroid/daemon/adapters/buffaloNas/BuffaloNasAdapter.java
  31. 41
      app/src/main/java/org/transdroid/daemon/adapters/kTorrent/StatsParser.java
  32. 16
      app/src/main/java/org/transdroid/daemon/adapters/rTorrent/RTorrentAdapter.java
  33. 9
      app/src/main/java/org/transdroid/daemon/adapters/synology/SynologyAdapter.java
  34. 12
      app/src/main/java/org/transdroid/daemon/adapters/tfb4rt/StatsParser.java
  35. 3
      app/src/main/java/org/transdroid/daemon/adapters/transmission/TransmissionAdapter.java
  36. 18
      app/src/main/java/org/transdroid/daemon/adapters/uTorrent/UTorrentAdapter.java
  37. 19
      app/src/main/java/org/transdroid/daemon/adapters/vuze/VuzeAdapter.java
  38. 6
      app/src/main/java/org/transdroid/daemon/adapters/vuze/VuzeXmlOverHttpClient.java
  39. 6
      app/src/main/java/org/transdroid/daemon/util/Collections2.java
  40. 4
      app/src/main/java/org/transdroid/daemon/util/SelfSignedTrustManager.java

3
app/src/main/java/org/transdroid/core/app/settings/ApplicationSettings.java

@ -74,8 +74,7 @@ public class ApplicationSettings { @@ -74,8 +74,7 @@ public class ApplicationSettings {
* @return A list of all stored server settings objects
*/
public List<ServerSetting> getAllServerSettings() {
List<ServerSetting> all = new ArrayList<>();
all.addAll(getNormalServerSettings());
List<ServerSetting> all = new ArrayList<>(getNormalServerSettings());
for (SeedboxProvider provider : SeedboxProvider.values()) {
all.addAll(provider.getSettings().getAllServerSettings(prefs, all.size()));
}

12
app/src/main/java/org/transdroid/core/gui/lists/LocalTorrent.java

@ -63,8 +63,6 @@ public class LocalTorrent { @@ -63,8 +63,6 @@ public class LocalTorrent {
switch (e.getType()) {
case MethodUnsupported:
return R.string.error_unsupported;
case ConnectionError:
return R.string.error_httperror;
case UnexpectedResponse:
return R.string.error_jsonresponseerror;
case ParsingFailed:
@ -75,6 +73,7 @@ public class LocalTorrent { @@ -75,6 +73,7 @@ public class LocalTorrent {
return R.string.error_401;
case FileAccessError:
return R.string.error_torrentfile;
case ConnectionError:
default:
return R.string.error_httperror;
}
@ -201,16 +200,15 @@ public class LocalTorrent { @@ -201,16 +200,15 @@ public class LocalTorrent {
public String getProgressSpeedText(Resources r) {
switch (t.getStatusCode()) {
case Waiting:
case Checking:
case Paused:
case Queued:
return "";
case Downloading:
return r.getString(R.string.status_speed_down, FileSizeConverter.getSize(t.getRateDownload()) + "/s") + " "
+ r.getString(R.string.status_speed_up, FileSizeConverter.getSize(t.getRateUpload()) + "/s");
case Seeding:
return r.getString(R.string.status_speed_up, FileSizeConverter.getSize(t.getRateUpload()) + "/s");
case Waiting:
case Checking:
case Paused:
case Queued:
default:
return "";
}

5
app/src/main/java/org/transdroid/core/gui/lists/MergeAdapter.java

@ -26,6 +26,7 @@ import android.widget.SectionIndexer; @@ -26,6 +26,7 @@ import android.widget.SectionIndexer;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.Arrays;
/**
* An adapter that can contain many other adapters and shows them in sequence. Taken from
@ -293,9 +294,7 @@ public class MergeAdapter extends BaseAdapter implements SectionIndexer { @@ -293,9 +294,7 @@ public class MergeAdapter extends BaseAdapter implements SectionIndexer {
Object[] curSections = ((SectionIndexer) piece).getSections();
if (curSections != null) {
for (Object section : curSections) {
sections.add(section);
}
sections.addAll(Arrays.asList(curSections));
}
}
}

4
app/src/main/java/org/transdroid/core/gui/lists/PiecesMapView.java

@ -111,9 +111,9 @@ class PiecesMapView extends View { @@ -111,9 +111,9 @@ class PiecesMapView extends View {
piecesScaled.add(state);
}
String scaledPiecesString = "";
StringBuilder scaledPiecesString = new StringBuilder();
for (int s : piecesScaled) {
scaledPiecesString += s;
scaledPiecesString.append(s);
}
// Draw downscaled peices

2
app/src/main/java/org/transdroid/core/gui/lists/SimpleListItemAdapter.java

@ -67,7 +67,7 @@ public class SimpleListItemAdapter extends BaseAdapter { @@ -67,7 +67,7 @@ public class SimpleListItemAdapter extends BaseAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
SimpleListItemView filterItemView;
if (convertView == null || !(convertView instanceof SimpleListItemView)) {
if (!(convertView instanceof SimpleListItemView)) {
filterItemView = SimpleListItemView_.build(context);
} else {
filterItemView = (SimpleListItemView) convertView;

4
app/src/main/java/org/transdroid/core/gui/lists/TorrentFilePriorityLayout.java

@ -72,9 +72,7 @@ public class TorrentFilePriorityLayout extends RelativeLayout { @@ -72,9 +72,7 @@ public class TorrentFilePriorityLayout extends RelativeLayout {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int height = getHeight();
int width = WIDTH;
fullRect.set(0, 0, width, height);
fullRect.set(0, 0, WIDTH, getHeight());
if (priority == null) {
return;

4
app/src/main/java/org/transdroid/core/gui/lists/TorrentStatusLayout.java

@ -80,9 +80,7 @@ public class TorrentStatusLayout extends RelativeLayout { @@ -80,9 +80,7 @@ public class TorrentStatusLayout extends RelativeLayout {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int height = getHeight();
int width = WIDTH;
fullRect.set(0, 0, width, height);
fullRect.set(0, 0, WIDTH, getHeight());
if (status == null) {
return;

2
app/src/main/java/org/transdroid/core/gui/log/DatabaseHelper.java

@ -59,7 +59,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper { @@ -59,7 +59,7 @@ public class DatabaseHelper extends OrmLiteSqliteOpenHelper {
switch (oldVersion) {
case 1:
TableUtils.createTable(connectionSource, ErrorLogEntry.class);
/*case 1:
/*case 2:
etc...*/
}

2
app/src/main/java/org/transdroid/core/gui/navigation/FilterListItemAdapter.java

@ -64,7 +64,7 @@ public class FilterListItemAdapter extends BaseAdapter { @@ -64,7 +64,7 @@ public class FilterListItemAdapter extends BaseAdapter {
@Override
public View getView(int position, View convertView, ViewGroup parent) {
FilterListItemView filterItemView;
if (convertView == null || !(convertView instanceof SimpleListItemView)) {
if (!(convertView instanceof SimpleListItemView)) {
filterItemView = FilterListItemView_.build(context);
} else {
filterItemView = (FilterListItemView) convertView;

2
app/src/main/java/org/transdroid/core/gui/navigation/SelectionModificationSpinner.java

@ -95,7 +95,7 @@ public class SelectionModificationSpinner extends AppCompatSpinner { @@ -95,7 +95,7 @@ public class SelectionModificationSpinner extends AppCompatSpinner {
* Local adapter that holds the actions which can be performed and a title text view that always shows instead of a
* list item as in a normal spinner.
*/
private class SelectionDropDownAdapter extends ArrayAdapter<String> {
private static class SelectionDropDownAdapter extends ArrayAdapter<String> {
protected TextView titleView = null;

4
app/src/main/java/org/transdroid/core/gui/rss/RssFeedsActivity.java

@ -139,7 +139,7 @@ public class RssFeedsActivity extends AppCompatActivity { @@ -139,7 +139,7 @@ public class RssFeedsActivity extends AppCompatActivity {
try {
hasRemoteFeeds = remoteConnection.getRemoteRssChannels(log).size() > 0;
} catch (DaemonException e) {
} catch (DaemonException ignored) {
}
if (hasRemoteFeeds) {
@ -279,7 +279,7 @@ public class RssFeedsActivity extends AppCompatActivity { @@ -279,7 +279,7 @@ public class RssFeedsActivity extends AppCompatActivity {
IDaemonAdapter currentConnection = this.getCurrentConnection();
// remote rss not supported for this connection type
if (currentConnection instanceof RemoteRssSupplier == false) {
if (!(currentConnection instanceof RemoteRssSupplier)) {
return;
}

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

@ -56,15 +56,15 @@ public class RssfeedLoader { @@ -56,15 +56,15 @@ public class RssfeedLoader {
Date pubDate = channel.getItems().get(0).getPubdate();
usePublishDate = pubDate != null && pubDate.getTime() > 0;
}
newCount = 0;
if (usePublishDate) {
// Count the number of new items, based on the date that this RSS feed was last viewed by the user
newCount = 0;
List<Item> items = channel.getItems();
// Reverse-order sort the items on their published date
Collections.sort(items, new Comparator<Item>() {
@Override
public int compare(Item lhs, Item rhs) {
return 0 - lhs.getPubdate().compareTo(rhs.getPubdate());
return -lhs.getPubdate().compareTo(rhs.getPubdate());
}
});
for (Item item : items) {
@ -77,7 +77,6 @@ public class RssfeedLoader { @@ -77,7 +77,6 @@ public class RssfeedLoader {
}
} else {
// Use the url of the last RSS item the last time the feed was viewed by the user to count new items
newCount = 0;
boolean isNew = true;
for (Item item : channel.getItems()) {
if (item.getTheLink() != null && setting.getLastViewedItemUrl() != null && item.getTheLink().equals(setting.getLastViewedItemUrl())) {

4
app/src/main/java/org/transdroid/core/gui/rss/RssitemStatusLayout.java

@ -66,9 +66,7 @@ public class RssitemStatusLayout extends RelativeLayout { @@ -66,9 +66,7 @@ public class RssitemStatusLayout extends RelativeLayout {
protected void onDraw(Canvas canvas) {
super.onDraw(canvas);
int height = getHeight();
int width = WIDTH;
fullRect.set(0, 0, width, height);
fullRect.set(0, 0, WIDTH, getHeight());
if (isNew == null) {
return;

2
app/src/main/java/org/transdroid/core/gui/search/SearchSettingsDropDownAdapter.java

@ -43,7 +43,7 @@ public class SearchSettingsDropDownAdapter extends FilterListItemAdapter { @@ -43,7 +43,7 @@ public class SearchSettingsDropDownAdapter extends FilterListItemAdapter {
public View getView(int position, View convertView, ViewGroup parent) {
// This returns the item to show in the action bar spinner
SearchSettingSelectionView filterItemView;
if (convertView == null || !(convertView instanceof SearchSettingSelectionView)) {
if (!(convertView instanceof SearchSettingSelectionView)) {
filterItemView = SearchSettingSelectionView_.build(context);
} else {
filterItemView = (SearchSettingSelectionView) convertView;

25
app/src/main/java/org/transdroid/core/gui/settings/MainSettingsActivity.java

@ -230,8 +230,8 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -230,8 +230,8 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
}
// Allow selection of the default server
ListPreference defaultServerPreference = (ListPreference) findPreference("header_defaultserver");
defaultServerPreference.setEntries(serverNames.toArray(new String[serverNames.size()]));
defaultServerPreference.setEntryValues(serverCodes.toArray(new String[serverCodes.size()]));
defaultServerPreference.setEntries(serverNames.toArray(new String[0]));
defaultServerPreference.setEntryValues(serverCodes.toArray(new String[0]));
// Add existing RSS feeds
if (!enableRssUi) {
@ -276,8 +276,8 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -276,8 +276,8 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
siteValues.add(websearch.getKey());
}
// Supply the Preference list names and values
setSite.setEntries(siteNames.toArray(new String[siteNames.size()]));
setSite.setEntryValues(siteValues.toArray(new String[siteValues.size()]));
setSite.setEntries(siteNames.toArray(new String[0]));
setSite.setEntryValues(siteValues.toArray(new String[0]));
}
@ -289,15 +289,14 @@ public class MainSettingsActivity extends PreferenceCompatActivity { @@ -289,15 +289,14 @@ public class MainSettingsActivity extends PreferenceCompatActivity {
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_ADDSEEDBOX:
// Open dialog to pick one of the supported seedbox providers (or a normal server)
String[] seedboxes = new String[SeedboxProvider.values().length + 1];
seedboxes[0] = getString(R.string.pref_addserver_normal);
for (int i = 0; i < seedboxes.length - 1; i++) {
seedboxes[i + 1] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.values()[i].getSettings().getName());
}
return new AlertDialog.Builder(this).setItems(seedboxes, onAddSeedbox).create();
if (id == DIALOG_ADDSEEDBOX) {
// Open dialog to pick one of the supported seedbox providers (or a normal server)
String[] seedboxes = new String[SeedboxProvider.values().length + 1];
seedboxes[0] = getString(R.string.pref_addserver_normal);
for (int i = 0; i < seedboxes.length - 1; i++) {
seedboxes[i + 1] = getString(R.string.pref_seedbox_addseedbox, SeedboxProvider.values()[i].getSettings().getName());
}
return new AlertDialog.Builder(this).setItems(seedboxes, onAddSeedbox).create();
}
return null;
}

16
app/src/main/java/org/transdroid/core/gui/settings/RssfeedPreference.java

@ -33,17 +33,17 @@ public class RssfeedPreference extends Preference { @@ -33,17 +33,17 @@ public class RssfeedPreference extends Preference {
private RssfeedSetting rssfeedSetting;
private OnRssfeedClickedListener onRssfeedClickedListener = null;
private OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onRssfeedClickedListener != null)
onRssfeedClickedListener.onRssfeedClicked(rssfeedSetting);
return true;
}
};
public RssfeedPreference(Context context) {
super(context);
OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onRssfeedClickedListener != null)
onRssfeedClickedListener.onRssfeedClicked(rssfeedSetting);
return true;
}
};
setOnPreferenceClickListener(onPreferenceClicked);
setIconSpaceReserved(false);
}

19
app/src/main/java/org/transdroid/core/gui/settings/RssfeedSettingsActivity.java

@ -74,16 +74,15 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity { @@ -74,16 +74,15 @@ public class RssfeedSettingsActivity extends KeyBoundPreferencesActivity {
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRMREMOVE:
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(RssfeedSettingsActivity.this).removeRssfeedSettings(key);
finish();
}
}).setNegativeButton(android.R.string.cancel, null).create();
if (id == DIALOG_CONFIRMREMOVE) {
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(RssfeedSettingsActivity.this).removeRssfeedSettings(key);
finish();
}
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;
}

16
app/src/main/java/org/transdroid/core/gui/settings/ServerPreference.java

@ -33,17 +33,17 @@ public class ServerPreference extends Preference { @@ -33,17 +33,17 @@ public class ServerPreference extends Preference {
protected ServerSetting serverSetting;
private OnServerClickedListener onServerClickedListener = null;
private OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onServerClickedListener != null)
onServerClickedListener.onServerClicked(serverSetting);
return true;
}
};
public ServerPreference(Context context) {
super(context);
OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onServerClickedListener != null)
onServerClickedListener.onServerClicked(serverSetting);
return true;
}
};
setOnPreferenceClickListener(onPreferenceClicked);
setIconSpaceReserved(false);
}

19
app/src/main/java/org/transdroid/core/gui/settings/ServerSettingsActivity.java

@ -114,16 +114,15 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity { @@ -114,16 +114,15 @@ public class ServerSettingsActivity extends KeyBoundPreferencesActivity {
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRMREMOVE:
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(ServerSettingsActivity.this).removeNormalServerSettings(key);
finish();
}
}).setNegativeButton(android.R.string.cancel, null).create();
if (id == DIALOG_CONFIRMREMOVE) {
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(ServerSettingsActivity.this).removeNormalServerSettings(key);
finish();
}
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;
}

16
app/src/main/java/org/transdroid/core/gui/settings/WebsearchPreference.java

@ -33,17 +33,17 @@ public class WebsearchPreference extends Preference { @@ -33,17 +33,17 @@ public class WebsearchPreference extends Preference {
private WebsearchSetting websearchSetting;
private OnWebsearchClickedListener onWebsearchClickedListener = null;
private OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onWebsearchClickedListener != null)
onWebsearchClickedListener.onWebsearchClicked(websearchSetting);
return true;
}
};
public WebsearchPreference(Context context) {
super(context);
OnPreferenceClickListener onPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onWebsearchClickedListener != null)
onWebsearchClickedListener.onWebsearchClicked(websearchSetting);
return true;
}
};
setOnPreferenceClickListener(onPreferenceClicked);
setIconSpaceReserved(false);
}

19
app/src/main/java/org/transdroid/core/gui/settings/WebsearchSettingsActivity.java

@ -70,16 +70,15 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity { @@ -70,16 +70,15 @@ public class WebsearchSettingsActivity extends KeyBoundPreferencesActivity {
@Override
protected Dialog onCreateDialog(int id) {
switch (id) {
case DIALOG_CONFIRMREMOVE:
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(WebsearchSettingsActivity.this).removeWebsearchSettings(key);
finish();
}
}).setNegativeButton(android.R.string.cancel, null).create();
if (id == DIALOG_CONFIRMREMOVE) {
return new AlertDialog.Builder(this).setMessage(R.string.pref_confirmremove)
.setPositiveButton(android.R.string.ok, new OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
ApplicationSettings_.getInstance_(WebsearchSettingsActivity.this).removeWebsearchSettings(key);
finish();
}
}).setNegativeButton(android.R.string.cancel, null).create();
}
return null;
}

16
app/src/main/java/org/transdroid/core/seedbox/SeedboxPreference.java

@ -33,17 +33,17 @@ public class SeedboxPreference extends ServerPreference { @@ -33,17 +33,17 @@ public class SeedboxPreference extends ServerPreference {
private SeedboxProvider provider = null;
private OnSeedboxClickedListener onSeedboxClickedListener = null;
private int onSeedboxClickedListenerOffset = 0;
private OnPreferenceClickListener onSeedboxPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onSeedboxClickedListener != null)
onSeedboxClickedListener.onSeedboxClicked(serverSetting, provider, onSeedboxClickedListenerOffset);
return true;
}
};
public SeedboxPreference(Context context) {
super(context);
OnPreferenceClickListener onSeedboxPreferenceClicked = new OnPreferenceClickListener() {
@Override
public boolean onPreferenceClick(Preference preference) {
if (onSeedboxClickedListener != null)
onSeedboxClickedListener.onSeedboxClicked(serverSetting, provider, onSeedboxClickedListenerOffset);
return true;
}
};
setOnPreferenceClickListener(onSeedboxPreferenceClicked);
}

5
app/src/main/java/org/transdroid/core/service/ServerCheckerJobRunner.java

@ -171,10 +171,11 @@ public class ServerCheckerJobRunner { @@ -171,10 +171,11 @@ public class ServerCheckerJobRunner {
// No notification to show
continue;
}
String forString = "";
StringBuilder forStringBuilder = new StringBuilder();
for (Torrent affected : affectedTorrents) {
forString += affected.getName() + ", ";
forStringBuilder.append(affected.getName()).append(", ");
}
String forString = forStringBuilder.toString();
forString = forString.substring(0, forString.length() - 2);
// Build the basic notification

4
app/src/main/java/org/transdroid/daemon/DaemonSettings.java

@ -191,11 +191,11 @@ public final class DaemonSettings { @@ -191,11 +191,11 @@ public final class DaemonSettings {
public String getHumanReadableIdentifier() {
if (isAutoGenerated) {
// Hide the 'implementation details'; just give the username and server
return (this.shouldUseAuthentication() && this.getUsername() != null && this.getUsername() != "" ? this
return (this.shouldUseAuthentication() && this.getUsername() != null && !this.getUsername().equals("") ? this
.getUsername() + "@" : "") + getAddress();
}
return (this.ssl ? "https://" : "http://")
+ (this.shouldUseAuthentication() && this.getUsername() != null && this.getUsername() != "" ? this
+ (this.shouldUseAuthentication() && this.getUsername() != null && !this.getUsername().equals("") ? this
.getUsername() + "@" : "") + getAddress() + ":" + getPort()
+ (Daemon.supportsCustomFolder(getType()) && getFolder() != null ? getFolder() : "");
}

7
app/src/main/java/org/transdroid/daemon/DummyAdapter.java

@ -201,6 +201,8 @@ public class DummyAdapter implements IDaemonAdapter { @@ -201,6 +201,8 @@ public class DummyAdapter implements IDaemonAdapter {
case Pause:
case Resume:
task.getTargetTorrent().mimicPause();
return new DaemonTaskSuccessResult(task);
@ -211,11 +213,6 @@ public class DummyAdapter implements IDaemonAdapter { @@ -211,11 +213,6 @@ public class DummyAdapter implements IDaemonAdapter {
}
return new DaemonTaskSuccessResult(task);
case Resume:
task.getTargetTorrent().mimicPause();
return new DaemonTaskSuccessResult(task);
case ResumeAll:
for (Torrent torrent : dummyTorrents) {

12
app/src/main/java/org/transdroid/daemon/TorrentDetails.java

@ -81,11 +81,11 @@ public final class TorrentDetails implements Parcelable { @@ -81,11 +81,11 @@ public final class TorrentDetails implements Parcelable {
*/
public String getTrackersText() {
// Build a string with one tracker URL per line
String trackersText = "";
StringBuilder trackersText = new StringBuilder();
for (String tracker : trackers) {
trackersText += (trackersText.length() == 0 ? "" : "\n") + tracker;
trackersText.append(trackersText.length() == 0 ? "" : "\n").append(tracker);
}
return trackersText;
return trackersText.toString();
}
/**
@ -95,11 +95,11 @@ public final class TorrentDetails implements Parcelable { @@ -95,11 +95,11 @@ public final class TorrentDetails implements Parcelable {
*/
public String getErrorsText() {
// Build a string with one tracker error per line
String errorsText = "";
StringBuilder errorsText = new StringBuilder();
for (String error : errors) {
errorsText += (errorsText.length() == 0 ? "" : "\n") + error;
errorsText.append(errorsText.length() == 0 ? "" : "\n").append(error);
}
return errorsText;
return errorsText.toString();
}
public List<Integer> getPieces() {

8
app/src/main/java/org/transdroid/daemon/TorrentFilesComparator.java

@ -49,18 +49,18 @@ public class TorrentFilesComparator implements Comparator<TorrentFile> { @@ -49,18 +49,18 @@ public class TorrentFilesComparator implements Comparator<TorrentFile> {
case PartDone:
return Float.compare(file1.getPartDone(), file2.getPartDone());
case TotalSize:
return Long.valueOf(file1.getTotalSize()).compareTo(file2.getTotalSize());
return Long.compare(file1.getTotalSize(), file2.getTotalSize());
default:
return alphanumComparator.compare(file1.getName().toLowerCase(), file2.getName().toLowerCase());
}
} else {
switch (sortBy) {
case PartDone:
return 0 - Float.compare(file1.getPartDone(), file2.getPartDone());
return -Float.compare(file1.getPartDone(), file2.getPartDone());
case TotalSize:
return 0 - Long.valueOf(file1.getTotalSize()).compareTo(file2.getTotalSize());
return -Long.compare(file1.getTotalSize(), file2.getTotalSize());
default:
return 0 - alphanumComparator.compare(file1.getName().toLowerCase(), file2.getName().toLowerCase());
return -alphanumComparator.compare(file1.getName().toLowerCase(), file2.getName().toLowerCase());
}
}
}

28
app/src/main/java/org/transdroid/daemon/TorrentsComparator.java

@ -67,42 +67,42 @@ public class TorrentsComparator implements Comparator<Torrent> { @@ -67,42 +67,42 @@ public class TorrentsComparator implements Comparator<Torrent> {
case DateDone:
return tor1.getDateDone().compareTo(tor2.getDateDone());
case Percent:
return Float.valueOf(tor1.getDownloadedPercentage()).compareTo(tor2.getDownloadedPercentage());
return Float.compare(tor1.getDownloadedPercentage(), tor2.getDownloadedPercentage());
case DownloadSpeed:
return Integer.valueOf(tor1.getRateDownload()).compareTo(tor2.getRateDownload());
return Integer.compare(tor1.getRateDownload(), tor2.getRateDownload());
case UploadSpeed:
return Integer.valueOf(tor1.getRateUpload()).compareTo(tor2.getRateUpload());
return Integer.compare(tor1.getRateUpload(), tor2.getRateUpload());
case Ratio:
return Double.valueOf(tor1.getRatio()).compareTo(tor2.getRatio());
return Double.compare(tor1.getRatio(), tor2.getRatio());
case Size:
return Double.valueOf(tor1.getTotalSize()).compareTo((double) tor2.getTotalSize());
return Double.compare(tor1.getTotalSize(), (double) tor2.getTotalSize());
default:
return alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
}
} else {
switch (sortBy) {
case Status:
return 0 - tor1.getStatusCode().compareStatusCodeTo(tor2.getStatusCode());
return -tor1.getStatusCode().compareStatusCodeTo(tor2.getStatusCode());
case DateAdded:
if (tor1.getDateAdded() == null)
return 1;
if (tor2.getDateAdded() == null)
return -1;
return 0 - tor1.getDateAdded().compareTo(tor2.getDateAdded());
return -tor1.getDateAdded().compareTo(tor2.getDateAdded());
case DateDone:
return 0 - tor1.getDateDone().compareTo(tor2.getDateDone());
return -tor1.getDateDone().compareTo(tor2.getDateDone());
case Percent:
return 0 - (Float.valueOf(tor1.getDownloadedPercentage()).compareTo(tor2.getDownloadedPercentage()));
return -(Float.compare(tor1.getDownloadedPercentage(), tor2.getDownloadedPercentage()));
case DownloadSpeed:
return 0 - (Integer.valueOf(tor1.getRateDownload()).compareTo(tor2.getRateDownload()));
return -(Integer.compare(tor1.getRateDownload(), tor2.getRateDownload()));
case UploadSpeed:
return 0 - (Integer.valueOf(tor1.getRateUpload()).compareTo(tor2.getRateUpload()));
return -(Integer.compare(tor1.getRateUpload(), tor2.getRateUpload()));
case Ratio:
return 0 - Double.valueOf(tor1.getRatio()).compareTo(tor2.getRatio());
return -Double.compare(tor1.getRatio(), tor2.getRatio());
case Size:
return 0 - Double.valueOf(tor1.getTotalSize()).compareTo((double) tor2.getTotalSize());
return -Double.compare(tor1.getTotalSize(), (double) tor2.getTotalSize());
default:
return 0 - alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
return -alphanumComparator.compare(tor1.getName().toLowerCase(), tor2.getName().toLowerCase());
}
}
}

10
app/src/main/java/org/transdroid/daemon/adapters/bitComet/BitCometAdapter.java

@ -107,7 +107,7 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -107,7 +107,7 @@ public class BitCometAdapter implements IDaemonAdapter {
} else if (size.endsWith("B")) {
return (long) (Float.parseFloat(size.substring(0, size.indexOf("B"))));
}
} catch (Exception e) {
} catch (Exception ignored) {
}
return 0;
}
@ -277,15 +277,17 @@ public class BitCometAdapter implements IDaemonAdapter { @@ -277,15 +277,17 @@ public class BitCometAdapter implements IDaemonAdapter {
// Add the parameters to the query string
boolean first = true;
StringBuilder urlBuilder = new StringBuilder(url);
for (NameValuePair param : params) {
if (first) {
url += "?";
urlBuilder.append("?");
first = false;
} else {
url += "&";
urlBuilder.append("&");
}
url += param.getName() + "=" + param.getValue();
urlBuilder.append(param.getName()).append("=").append(param.getValue());
}
url = urlBuilder.toString();
// Make the request
HttpResponse response = httpclient.execute(new HttpGet(buildWebUIUrl(url)));

8
app/src/main/java/org/transdroid/daemon/adapters/buffaloNas/BuffaloNasAdapter.java

@ -180,15 +180,17 @@ public class BuffaloNasAdapter implements IDaemonAdapter { @@ -180,15 +180,17 @@ public class BuffaloNasAdapter implements IDaemonAdapter {
// Add the parameters to the query string
boolean first = true;
StringBuilder urlBuilder = new StringBuilder(url);
for (NameValuePair param : params) {
if (first) {
url += "?";
urlBuilder.append("?");
first = false;
} else {
url += "&";
urlBuilder.append("&");
}
url += param.getName() + "=" + param.getValue();
urlBuilder.append(param.getName()).append("=").append(param.getValue());
}
url = urlBuilder.toString();
// Make the request
HttpResponse response = httpclient.execute(new HttpGet(buildWebUIUrl(url)));

41
app/src/main/java/org/transdroid/daemon/adapters/kTorrent/StatsParser.java

@ -209,12 +209,13 @@ public class StatsParser { @@ -209,12 +209,13 @@ public class StatsParser {
* @return The size in number of kB
*/
public static long convertSize(String size) {
String s = size.substring(0, size.length() - 4);
if (size.endsWith("GiB")) {
return (long) (convertStringToFloat(size.substring(0, size.length() - 4)) * 1024 * 1024 * 1024);
return (long) (convertStringToFloat(s) * 1024 * 1024 * 1024);
} else if (size.endsWith("MiB")) {
return (long) (convertStringToFloat(size.substring(0, size.length() - 4)) * 1024 * 1024);
return (long) (convertStringToFloat(s) * 1024 * 1024);
} else if (size.endsWith("KiB")) {
return (long) (convertStringToFloat(size.substring(0, size.length() - 4)) * 1024);
return (long) (convertStringToFloat(s) * 1024);
} else if (size.endsWith("B")) {
return convertStringToFloat(size.substring(0, size.length() - 2)).longValue();
}
@ -228,10 +229,11 @@ public class StatsParser { @@ -228,10 +229,11 @@ public class StatsParser {
* @return The rate (or speed) in KiB/s
*/
public static int convertRate(String rate) {
String s = rate.substring(0, rate.length() - 6);
if (rate.endsWith("MiB/s")) {
return (int) (convertStringToFloat(rate.substring(0, rate.length() - 6)) * 1024 * 1024);
return (int) (convertStringToFloat(s) * 1024 * 1024);
} else if (rate.endsWith("KiB/s")) {
return (int) (convertStringToFloat(rate.substring(0, rate.length() - 6)) * 1024);
return (int) (convertStringToFloat(s) * 1024);
} else if (rate.endsWith("B/s")) {
return convertStringToFloat(rate.substring(0, rate.length() - 4)).intValue();
}
@ -245,22 +247,19 @@ public class StatsParser { @@ -245,22 +247,19 @@ public class StatsParser {
* @return The status as TorrentStatus or Unknown if it could not been parsed
*/
private static TorrentStatus convertStatus(String status) {
if (status.equals("Downloading")) {
return TorrentStatus.Downloading;
} else if (status.equals("Seeding")) {
return TorrentStatus.Seeding;
} else if (status.equals("Stopped")) {
return TorrentStatus.Paused;
} else if (status.equals("Stalled")) {
return TorrentStatus.Paused;
} else if (status.equals("Download completed")) {
return TorrentStatus.Paused;
} else if (status.equals("Not started")) {
return TorrentStatus.Paused;
} else if (status.equals("Stalled")) {
return TorrentStatus.Waiting;
} else if (status.equals("Checking data")) {
return TorrentStatus.Checking;
switch (status) {
case "Downloading":
return TorrentStatus.Downloading;
case "Seeding":
return TorrentStatus.Seeding;
case "Stopped":
case "Download completed":
case "Not started":
return TorrentStatus.Paused;
case "Stalled":
return TorrentStatus.Waiting;
case "Checking data":
return TorrentStatus.Checking;
}
return TorrentStatus.Unknown;
}

16
app/src/main/java/org/transdroid/daemon/adapters/rTorrent/RTorrentAdapter.java

@ -332,13 +332,15 @@ public class RTorrentAdapter implements IDaemonAdapter { @@ -332,13 +332,15 @@ public class RTorrentAdapter implements IDaemonAdapter {
initialise();
}
String params = "";
StringBuilder paramsBuilder = new StringBuilder();
for (Object arg : arguments) {
params += " " + arg.toString();
paramsBuilder.append(" ").append(arg.toString());
}
String params = paramsBuilder.toString();
String s = params.length() > 100 ? params.substring(0, 100) + "..." : params;
try {
log.d(LOG_NAME, "Calling " + serverMethod + " with params [" +
(params.length() > 100 ? params.substring(0, 100) + "..." : params) + " ]");
s + " ]");
return rpcclient.call(serverMethod, arguments);
} catch (IllegalArgumentException e) {
log.d(LOG_NAME, "Using " + buildWebUIUrl() + ": " + e.toString());
@ -353,7 +355,7 @@ public class RTorrentAdapter implements IDaemonAdapter { @@ -353,7 +355,7 @@ public class RTorrentAdapter implements IDaemonAdapter {
}
throw new DaemonException(ExceptionType.ConnectionError,
"Error making call to " + serverMethod + " with params [" +
(params.length() > 100 ? params.substring(0, 100) + "..." : params) + " ]: " +
s + " ]: " +
e.toString());
}
@ -386,7 +388,7 @@ public class RTorrentAdapter implements IDaemonAdapter { @@ -386,7 +388,7 @@ public class RTorrentAdapter implements IDaemonAdapter {
private List<Torrent> onTorrentsRetrieved(Object response) throws DaemonException {
if (response == null || !(response instanceof Object[])) {
if (!(response instanceof Object[])) {
throw new DaemonException(ExceptionType.ParsingFailed,
"Response on retrieveing torrents did not return a list of objects");
@ -532,7 +534,7 @@ public class RTorrentAdapter implements IDaemonAdapter { @@ -532,7 +534,7 @@ public class RTorrentAdapter implements IDaemonAdapter {
private List<TorrentFile> onTorrentFilesRetrieved(Object response, Torrent torrent) throws DaemonException {
if (response == null || !(response instanceof Object[])) {
if (!(response instanceof Object[])) {
throw new DaemonException(ExceptionType.ParsingFailed,
"Response on retrieveing torrent files did not return a list of objects");
@ -639,7 +641,7 @@ public class RTorrentAdapter implements IDaemonAdapter { @@ -639,7 +641,7 @@ public class RTorrentAdapter implements IDaemonAdapter {
private TorrentDetails onTorrentDetailsRetrieved(Log log, Object response) throws DaemonException {
if (response == null || !(response instanceof Object[])) {
if (!(response instanceof Object[])) {
throw new DaemonException(ExceptionType.ParsingFailed,
"Response on retrieveing trackers did not return a list of objects");

9
app/src/main/java/org/transdroid/daemon/adapters/synology/SynologyAdapter.java

@ -91,8 +91,6 @@ public class SynologyAdapter implements IDaemonAdapter { @@ -91,8 +91,6 @@ public class SynologyAdapter implements IDaemonAdapter {
switch (task.getMethod()) {
case Retrieve:
return new RetrieveTaskSuccessResult((RetrieveTask) task, tasksList(log), null);
case GetStats:
return null;
case GetTorrentDetails:
tid = task.getTargetTorrent().getUniqueID();
return new GetTorrentDetailsTaskSuccessResult((GetTorrentDetailsTask) task,
@ -129,10 +127,6 @@ public class SynologyAdapter implements IDaemonAdapter { @@ -129,10 +127,6 @@ public class SynologyAdapter implements IDaemonAdapter {
case ResumeAll:
resumeAllTasks(log);
return new DaemonTaskSuccessResult(task);
case SetDownloadLocation:
return null;
case SetFilePriorities:
return null;
case SetTransferRates:
SetTransferRatesTask ratesTask = (SetTransferRatesTask) task;
int uploadRate = ratesTask.getUploadRate() == null ? 0 : ratesTask.getUploadRate();
@ -140,6 +134,9 @@ public class SynologyAdapter implements IDaemonAdapter { @@ -140,6 +134,9 @@ public class SynologyAdapter implements IDaemonAdapter {
setTransferRates(log, uploadRate, downloadRate);
return new DaemonTaskSuccessResult(task);
case SetAlternativeMode:
case GetStats:
case SetDownloadLocation:
case SetFilePriorities:
default:
return null;
}

12
app/src/main/java/org/transdroid/daemon/adapters/tfb4rt/StatsParser.java

@ -163,12 +163,13 @@ public class StatsParser { @@ -163,12 +163,13 @@ public class StatsParser {
* @return The size in number of kB
*/
private static long convertSize(String size) {
float v = Float.parseFloat(size.substring(0, size.length() - 3));
if (size.endsWith("GB")) {
return (long) (Float.parseFloat(size.substring(0, size.length() - 3)) * 1024 * 1024 * 1024);
return (long) (v * 1024 * 1024 * 1024);
} else if (size.endsWith("MB")) {
return (long) (Float.parseFloat(size.substring(0, size.length() - 3)) * 1024 * 1024);
return (long) (v * 1024 * 1024);
} else if (size.endsWith("kB")) {
return (long) (Float.parseFloat(size.substring(0, size.length() - 3)) * 1024);
return (long) (v * 1024);
} else if (size.endsWith("B")) {
return (long) (Float.parseFloat(size.substring(0, size.length() - 2)));
}
@ -216,10 +217,11 @@ public class StatsParser { @@ -216,10 +217,11 @@ public class StatsParser {
* @return The rate (or speed) in kB/s
*/
private static int convertRate(String rate) {
float v = Float.parseFloat(rate.substring(0, rate.length() - 5));
if (rate.endsWith("MB/s")) {
return (int) (Float.parseFloat(rate.substring(0, rate.length() - 5)) * 1024 * 1024);
return (int) (v * 1024 * 1024);
} else if (rate.endsWith("kB/s")) {
return (int) (Float.parseFloat(rate.substring(0, rate.length() - 5)) * 1024);
return (int) (v * 1024);
} else if (rate.endsWith("B/s")) {
return (int) Float.parseFloat(rate.substring(0, rate.length() - 4));
}

3
app/src/main/java/org/transdroid/daemon/adapters/transmission/TransmissionAdapter.java

@ -567,11 +567,10 @@ public class TransmissionAdapter implements IDaemonAdapter { @@ -567,11 +567,10 @@ public class TransmissionAdapter implements IDaemonAdapter {
case 2:
return TorrentStatus.Checking;
case 3:
case 5:
return TorrentStatus.Queued;
case 4:
return TorrentStatus.Downloading;
case 5:
return TorrentStatus.Queued;
case 6:
return TorrentStatus.Seeding;
}

18
app/src/main/java/org/transdroid/daemon/adapters/uTorrent/UTorrentAdapter.java

@ -259,9 +259,9 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -259,9 +259,9 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier {
// Set priorities of the files of some torrent
SetFilePriorityTask prioTask = (SetFilePriorityTask) task;
String prioUrl = "&p=" + convertPriority(prioTask.getNewPriority());
StringBuilder prioUrl = new StringBuilder("&p=" + convertPriority(prioTask.getNewPriority()));
for (TorrentFile forFile : prioTask.getForFiles()) {
prioUrl += "&f=" + forFile.getKey();
prioUrl.append("&f=").append(forFile.getKey());
}
makeUtorrentRequest(log,
"&action=setprio" + RPC_URL_HASH + task.getTargetTorrent().getUniqueID() + prioUrl);
@ -291,13 +291,13 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -291,13 +291,13 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier {
// Set the trackers of some torrent
SetTrackersTask trackersTask = (SetTrackersTask) task;
// Build list of tracker lines, separated by a \r\n
String newTrackersText = "";
StringBuilder newTrackersText = new StringBuilder();
for (String tracker : trackersTask.getNewTrackers()) {
newTrackersText += (newTrackersText.length() == 0 ? "" : "\r\n") + tracker;
newTrackersText.append(newTrackersText.length() == 0 ? "" : "\r\n").append(tracker);
}
makeUtorrentRequest(log,
"&action=setprops" + RPC_URL_HASH + trackersTask.getTargetTorrent().getUniqueID() +
"&s=trackers&v=" + URLEncoder.encode(newTrackersText, "UTF-8"));
"&s=trackers&v=" + URLEncoder.encode(newTrackersText.toString(), "UTF-8"));
return new DaemonTaskSuccessResult(task);
case ForceRecheck:
@ -552,7 +552,7 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -552,7 +552,7 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier {
for (int i = 0; i < results.length(); i++) {
JSONArray tor = results.getJSONArray(i);
String name = tor.getString(RPC_NAME_IDX);
boolean downloaded = (tor.getLong(RPC_PARTDONE) == 1000l);
boolean downloaded = (tor.getLong(RPC_PARTDONE) == 1000L);
float available = ((float) tor.getInt(RPC_AVAILABILITY_IDX)) / 65536f; // Integer in 1/65536ths
// The full torrent path is not available in uTorrent web UI API
// Guess the torrent's directory based on the user-specific default download dir and the torrent name
@ -641,11 +641,11 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier { @@ -641,11 +641,11 @@ public class UTorrentAdapter implements IDaemonAdapter, RemoteRssSupplier {
ArrayList<Torrent> torrents = parseJsonRetrieveTorrents(result.getJSONArray("torrents"));
// Build a string of hashes of all the torrents
String hashes = "";
StringBuilder hashes = new StringBuilder();
for (Torrent torrent : torrents) {
hashes += RPC_URL_HASH + torrent.getUniqueID();
hashes.append(RPC_URL_HASH).append(torrent.getUniqueID());
}
return hashes;
return hashes.toString();
}

19
app/src/main/java/org/transdroid/daemon/adapters/vuze/VuzeAdapter.java

@ -256,11 +256,9 @@ public class VuzeAdapter implements IDaemonAdapter { @@ -256,11 +256,9 @@ public class VuzeAdapter implements IDaemonAdapter {
throw new DaemonException(ExceptionType.UnexpectedResponse, "No plugin config ID returned on getPluginconfig");
}
savedPluginConfigID = (Long) config.get("_object_id");
vuzeObjectID = savedPluginConfigID;
} else {
// We stored the plugin config ID, so no need to ask for it again
vuzeObjectID = savedPluginConfigID;
}
// We stored the plugin config ID, so no need to ask for it again
vuzeObjectID = savedPluginConfigID;
} else if (serverMethod.equals("createFromBEncodedData[byte[]]")) {
@ -272,11 +270,10 @@ public class VuzeAdapter implements IDaemonAdapter { @@ -272,11 +270,10 @@ public class VuzeAdapter implements IDaemonAdapter {
throw new DaemonException(ExceptionType.UnexpectedResponse, "No torrent manager ID returned on getTorrentManager");
}
savedTorrentManagerID = (Long) manager.get("_object_id");
vuzeObjectID = savedTorrentManagerID;
} else {
// We stored the torrent manager ID, so no need to ask for it again
vuzeObjectID = savedTorrentManagerID;
}
// We stored the torrent manager ID, so no need to ask for it again
vuzeObjectID = savedTorrentManagerID;
// And we will need the download manager as well later on (for addDownload after createFromBEncodedData)
if (savedDownloadManagerID == null) {
// Download manager needed, but we don't know it's ID yet
@ -297,11 +294,9 @@ public class VuzeAdapter implements IDaemonAdapter { @@ -297,11 +294,9 @@ public class VuzeAdapter implements IDaemonAdapter {
throw new DaemonException(ExceptionType.UnexpectedResponse, "No download manager ID returned on getDownloadManager");
}
savedDownloadManagerID = (Long) manager.get("_object_id");
vuzeObjectID = savedDownloadManagerID;
} else {
// We stored the download manager ID, so no need to ask for it again
vuzeObjectID = savedDownloadManagerID;
}
// We stored the download manager ID, so no need to ask for it again
vuzeObjectID = savedDownloadManagerID;
}
} else {

6
app/src/main/java/org/transdroid/daemon/adapters/vuze/VuzeXmlOverHttpClient.java

@ -172,16 +172,14 @@ public class VuzeXmlOverHttpClient { @@ -172,16 +172,14 @@ public class VuzeXmlOverHttpClient {
// Long?
try {
Long longnum = Long.parseLong(rawText);
return longnum;
return Long.parseLong(rawText);
} catch (NumberFormatException e) {
// Just continue trying the next type
}
// Double?
try {
Double doublenum = Double.parseDouble(rawText);
return doublenum;
return Double.parseDouble(rawText);
} catch (NumberFormatException e) {
// Just continue trying the next type
}

6
app/src/main/java/org/transdroid/daemon/util/Collections2.java

@ -10,12 +10,12 @@ public class Collections2 { @@ -10,12 +10,12 @@ public class Collections2 {
*/
public static <T> String joinString(Iterable<T> iterable, String separator) {
boolean first = true;
String result = "";
StringBuilder result = new StringBuilder();
for (T anIterable : iterable) {
result += (first ? "" : separator) + anIterable.toString();
result.append(first ? "" : separator).append(anIterable.toString());
first = false;
}
return result;
return result.toString();
}
}

4
app/src/main/java/org/transdroid/daemon/util/SelfSignedTrustManager.java

@ -78,10 +78,8 @@ public class SelfSignedTrustManager implements X509TrustManager { @@ -78,10 +78,8 @@ public class SelfSignedTrustManager implements X509TrustManager {
return;
}
CertificateException certificateException =
new CertificateException("Certificate key [" + thumbprint + "] doesn't match expected value.");
//Log.e(SelfSignedTrustManager.class.getSimpleName(), certificateException.toString());
throw certificateException;
throw new CertificateException("Certificate key [" + thumbprint + "] doesn't match expected value.");
} catch (NoSuchAlgorithmException e) {
throw new CertificateException("Unable to check self-signed cert, unknown algorithm. " + e.toString());

Loading…
Cancel
Save