mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-02-01 19:26:46 +01:00
Address FindBugs warnings
This commit fixes 36 of the 109 warnings.
This commit is contained in:
parent
941fa9062e
commit
b1cdfe2041
@ -348,7 +348,9 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
||||
* CREATE_DIRECTORY_NAME.
|
||||
*/
|
||||
private int createFolder() {
|
||||
if (selectedDir != null && selectedDir.canWrite()) {
|
||||
if (selectedDir == null) {
|
||||
return R.string.create_folder_error;
|
||||
} else if (selectedDir.canWrite()) {
|
||||
File newDir = new File(selectedDir, CREATE_DIRECTORY_NAME);
|
||||
if (!newDir.exists()) {
|
||||
boolean result = newDir.mkdir();
|
||||
@ -360,10 +362,8 @@ public class DirectoryChooserActivity extends SherlockActivity {
|
||||
} else {
|
||||
return R.string.create_folder_error_already_exists;
|
||||
}
|
||||
} else if (selectedDir.canWrite() == false) {
|
||||
return R.string.create_folder_error_no_write_access;
|
||||
} else {
|
||||
return R.string.create_folder_error;
|
||||
return R.string.create_folder_error_no_write_access;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -113,7 +113,7 @@ public class DownloadActivity extends SherlockListActivity implements
|
||||
contentRefresher.cancel(true);
|
||||
}
|
||||
contentRefresher = new AsyncTask<Void, Void, Void>() {
|
||||
private final int WAITING_INTERVALL = 1000;
|
||||
private final static int WAITING_INTERVALL = 1000;
|
||||
|
||||
@Override
|
||||
protected void onProgressUpdate(Void... values) {
|
||||
|
@ -24,7 +24,7 @@ import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
public class MiroGuideCategoryActivity extends SherlockFragmentActivity {
|
||||
private static final String TAG = "MiroGuideCategoryActivity";
|
||||
|
||||
public static String EXTRA_CATEGORY = "category";
|
||||
public static final String EXTRA_CATEGORY = "category";
|
||||
|
||||
private ViewPager viewpager;
|
||||
private CategoryPagerAdapter pagerAdapter;
|
||||
|
@ -154,7 +154,7 @@ public abstract class OnlineFeedViewActivity extends SherlockFragmentActivity {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
String reasonDetailed = new String();
|
||||
String reasonDetailed = "";
|
||||
boolean successful = false;
|
||||
FeedHandler handler = new FeedHandler();
|
||||
try {
|
||||
|
@ -7,6 +7,7 @@ import java.net.URL;
|
||||
import android.app.AlertDialog;
|
||||
import android.os.Bundle;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.util.LangUtils;
|
||||
|
||||
/** Lets the user start the OPML-import process. */
|
||||
public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
||||
@ -20,7 +21,8 @@ public class OpmlImportFromIntentActivity extends OpmlImportBaseActivity {
|
||||
|
||||
try {
|
||||
URL mOpmlURL = new URL(getIntent().getData().toString());
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mOpmlURL.openStream()));
|
||||
BufferedReader in = new BufferedReader(new InputStreamReader(mOpmlURL.openStream(),
|
||||
LangUtils.UTF_8));
|
||||
startImport(in);
|
||||
} catch (Exception e) {
|
||||
new AlertDialog.Builder(this).setMessage("Cannot open XML - Reason: " + e.getMessage()).show();
|
||||
|
@ -1,8 +1,10 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.IOException;
|
||||
import java.io.Reader;
|
||||
|
||||
import android.app.AlertDialog;
|
||||
@ -21,6 +23,7 @@ import com.actionbarsherlock.view.MenuItem;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.util.LangUtils;
|
||||
import de.danoeh.antennapod.util.StorageUtils;
|
||||
|
||||
/**
|
||||
@ -126,13 +129,24 @@ public class OpmlImportFromPathActivity extends OpmlImportBaseActivity {
|
||||
}
|
||||
|
||||
private void startImport(File file) {
|
||||
Reader mReader = null;
|
||||
try {
|
||||
Reader mReader = new FileReader(file);
|
||||
mReader = new InputStreamReader(new FileInputStream(file),
|
||||
LangUtils.UTF_8);
|
||||
if (AppConfig.DEBUG) Log.d(TAG, "Parsing " + file.toString());
|
||||
startImport(mReader);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.d(TAG, "File not found which really should be there");
|
||||
// this should never happen as it is a file we have just chosen
|
||||
} finally {
|
||||
if (mReader != null) {
|
||||
try {
|
||||
mReader.close();
|
||||
} catch (IOException ioe) {
|
||||
Log.w(TAG, "IOException while importing OPML: " +
|
||||
ioe.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ public class BitmapDecodeWorkerTask extends Thread {
|
||||
*/
|
||||
protected boolean tagsMatching(ImageView target) {
|
||||
return target.getTag() == null
|
||||
|| target.getTag() == imageResource.getImageLoaderCacheKey();
|
||||
|| target.getTag().equals(imageResource.getImageLoaderCacheKey());
|
||||
}
|
||||
|
||||
protected void onPostExecute() {
|
||||
|
@ -14,7 +14,7 @@ public class DownloadStatus {
|
||||
public static final int SIZE_UNKNOWN = -1;
|
||||
|
||||
public Date getCompletionDate() {
|
||||
return completionDate;
|
||||
return (Date) completionDate.clone();
|
||||
}
|
||||
|
||||
// ----------------------------------- ATTRIBUTES STORED IN DB
|
||||
@ -72,7 +72,7 @@ public class DownloadStatus {
|
||||
this.feedfile = feedfile;
|
||||
this.reason = reason;
|
||||
this.successful = successful;
|
||||
this.completionDate = completionDate;
|
||||
this.completionDate = (Date) completionDate.clone();
|
||||
this.reasonDetailed = reasonDetailed;
|
||||
this.feedfileType = feedfileType;
|
||||
}
|
||||
@ -172,7 +172,7 @@ public class DownloadStatus {
|
||||
}
|
||||
|
||||
public void setCompletionDate(Date completionDate) {
|
||||
this.completionDate = completionDate;
|
||||
this.completionDate = (Date) completionDate.clone();
|
||||
}
|
||||
|
||||
public String getReasonDetailed() {
|
||||
|
@ -1,8 +1,9 @@
|
||||
package de.danoeh.antennapod.asynctask;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.util.Arrays;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@ -17,6 +18,7 @@ import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.opml.OpmlWriter;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.util.LangUtils;
|
||||
|
||||
/** Writes an OPML file into the export directory in the background. */
|
||||
public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
|
||||
@ -49,14 +51,22 @@ public class OpmlExportWorker extends AsyncTask<Void, Void, Void> {
|
||||
output.delete();
|
||||
}
|
||||
}
|
||||
OutputStreamWriter writer = null;
|
||||
try {
|
||||
FileWriter writer = new FileWriter(output);
|
||||
writer = new OutputStreamWriter(new FileOutputStream(output), LangUtils.UTF_8);
|
||||
opmlWriter.writeDocument(Arrays.asList(FeedManager.getInstance().getFeedsArray()),
|
||||
writer);
|
||||
writer.close();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
exception = e;
|
||||
} finally {
|
||||
if (writer != null) {
|
||||
try {
|
||||
writer.close();
|
||||
} catch (IOException ioe) {
|
||||
exception = ioe;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package de.danoeh.antennapod.asynctask;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Date;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
@ -22,7 +23,7 @@ public class OpmlFeedQueuer extends AsyncTask<Void, Void, Void> {
|
||||
public OpmlFeedQueuer(Context context, int[] selection) {
|
||||
super();
|
||||
this.context = context;
|
||||
this.selection = selection;
|
||||
this.selection = Arrays.copyOf(selection, selection.length);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -40,7 +40,7 @@ public class Feed extends FeedFile {
|
||||
public Feed(Date lastUpdate) {
|
||||
super();
|
||||
items = Collections.synchronizedList(new ArrayList<FeedItem>());
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.lastUpdate = (Date) lastUpdate.clone();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -298,11 +298,11 @@ public class Feed extends FeedFile {
|
||||
}
|
||||
|
||||
public Date getLastUpdate() {
|
||||
return lastUpdate;
|
||||
return (Date) lastUpdate.clone();
|
||||
}
|
||||
|
||||
public void setLastUpdate(Date lastUpdate) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.lastUpdate = (Date) lastUpdate.clone();
|
||||
}
|
||||
|
||||
public String getFeedIdentifier() {
|
||||
|
@ -138,11 +138,11 @@ public class FeedItem extends FeedComponent implements
|
||||
}
|
||||
|
||||
public Date getPubDate() {
|
||||
return pubDate;
|
||||
return (Date) pubDate.clone();
|
||||
}
|
||||
|
||||
public void setPubDate(Date pubDate) {
|
||||
this.pubDate = pubDate;
|
||||
this.pubDate = (Date) pubDate.clone();
|
||||
}
|
||||
|
||||
public FeedMedia getMedia() {
|
||||
|
@ -47,7 +47,8 @@ public class FeedMedia extends FeedFile implements Playable {
|
||||
this.position = position;
|
||||
this.size = size;
|
||||
this.mime_type = mime_type;
|
||||
this.playbackCompletionDate = playbackCompletionDate;
|
||||
this.playbackCompletionDate = playbackCompletionDate == null
|
||||
? null : (Date) playbackCompletionDate.clone();
|
||||
}
|
||||
|
||||
public FeedMedia(long id, FeedItem item) {
|
||||
@ -161,11 +162,13 @@ public class FeedMedia extends FeedFile implements Playable {
|
||||
}
|
||||
|
||||
public Date getPlaybackCompletionDate() {
|
||||
return playbackCompletionDate;
|
||||
return playbackCompletionDate == null
|
||||
? null : (Date) playbackCompletionDate.clone();
|
||||
}
|
||||
|
||||
public void setPlaybackCompletionDate(Date playbackCompletionDate) {
|
||||
this.playbackCompletionDate = playbackCompletionDate;
|
||||
this.playbackCompletionDate = playbackCompletionDate == null
|
||||
? null : (Date) playbackCompletionDate.clone();
|
||||
}
|
||||
|
||||
public boolean isInProgress() {
|
||||
|
@ -16,6 +16,8 @@ import org.json.JSONObject;
|
||||
|
||||
import android.net.Uri;
|
||||
|
||||
import de.danoeh.antennapod.util.LangUtils;
|
||||
|
||||
/** Executes HTTP requests and returns the results. */
|
||||
public class MiroGuideConnector {
|
||||
private HttpClient httpClient;
|
||||
@ -73,12 +75,14 @@ public class MiroGuideConnector {
|
||||
if (response.getStatusLine().getStatusCode() == 200) {
|
||||
HttpEntity entity = response.getEntity();
|
||||
if (entity != null) {
|
||||
InputStream in = entity.getContent();
|
||||
|
||||
BufferedReader reader = new BufferedReader(
|
||||
new InputStreamReader(in));
|
||||
result = reader.readLine();
|
||||
in.close();
|
||||
new InputStreamReader(entity.getContent(),
|
||||
LangUtils.UTF_8));
|
||||
try {
|
||||
result = reader.readLine();
|
||||
} finally {
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new MiroGuideException(response.getStatusLine()
|
||||
|
@ -12,7 +12,7 @@ public class MiroGuideItem {
|
||||
super();
|
||||
this.name = name;
|
||||
this.description = description;
|
||||
this.date = date;
|
||||
this.date = (Date) date.clone();
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
@ -30,7 +30,7 @@ public class MiroGuideItem {
|
||||
}
|
||||
|
||||
public Date getDate() {
|
||||
return date;
|
||||
return (Date) date.clone();
|
||||
}
|
||||
|
||||
public String getUrl() {
|
||||
|
@ -79,9 +79,8 @@ public class HttpDownloader extends Downloader {
|
||||
File destination = new File(status.getFeedFile()
|
||||
.getFile_url());
|
||||
if (!destination.exists()) {
|
||||
connection = AndroidHttpClient
|
||||
.getUngzippedContent(httpEntity);
|
||||
InputStream in = new BufferedInputStream(connection);
|
||||
connection = new BufferedInputStream(AndroidHttpClient
|
||||
.getUngzippedContent(httpEntity));
|
||||
out = new BufferedOutputStream(new FileOutputStream(
|
||||
destination));
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
@ -104,7 +103,7 @@ public class HttpDownloader extends Downloader {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Starting download");
|
||||
while (!cancelled
|
||||
&& (count = in.read(buffer)) != -1) {
|
||||
&& (count = connection.read(buffer)) != -1) {
|
||||
out.write(buffer, 0, count);
|
||||
status.setSoFar(status.getSoFar() + count);
|
||||
status.setProgressPercent((int) (((double) status
|
||||
|
@ -24,9 +24,9 @@ import de.danoeh.antennapod.util.URLChecker;
|
||||
public class DownloadRequester {
|
||||
private static final String TAG = "DownloadRequester";
|
||||
|
||||
public static String IMAGE_DOWNLOADPATH = "images/";
|
||||
public static String FEED_DOWNLOADPATH = "cache/";
|
||||
public static String MEDIA_DOWNLOADPATH = "media/";
|
||||
public static final String IMAGE_DOWNLOADPATH = "images/";
|
||||
public static final String FEED_DOWNLOADPATH = "cache/";
|
||||
public static final String MEDIA_DOWNLOADPATH = "media/";
|
||||
|
||||
private static DownloadRequester downloader;
|
||||
|
||||
@ -223,10 +223,6 @@ public class DownloadRequester {
|
||||
return downloads.isEmpty();
|
||||
}
|
||||
|
||||
public FeedFile getDownloadAt(int index) {
|
||||
return downloads.get(index);
|
||||
}
|
||||
|
||||
/** Remove an object from the downloads-list of the requester. */
|
||||
public void removeDownload(FeedFile f) {
|
||||
if (downloads.remove(f.getDownload_url()) == null) {
|
||||
|
@ -203,7 +203,7 @@ public class PodDBAdapter {
|
||||
public static final int IDX_FI_SMALL_ITEM_IDENTIFIER = 9;
|
||||
|
||||
/** Select id, description and content-encoded column from feeditems. */
|
||||
public static final String[] SEL_FI_EXTRA = { KEY_ID, KEY_DESCRIPTION,
|
||||
private static final String[] SEL_FI_EXTRA = { KEY_ID, KEY_DESCRIPTION,
|
||||
KEY_CONTENT_ENCODED, KEY_FEED };
|
||||
|
||||
// column indices for SEL_FI_EXTRA
|
||||
|
@ -121,7 +121,7 @@ public class NSAtom extends Namespace {
|
||||
if (state.getContentBuf() != null) {
|
||||
content = state.getContentBuf().toString();
|
||||
} else {
|
||||
content = new String();
|
||||
content = "";
|
||||
}
|
||||
SyndElement topElement = state.getTagstack().peek();
|
||||
String top = topElement.getName();
|
||||
|
@ -11,7 +11,7 @@ import android.util.Log;
|
||||
public class SyndDateUtils {
|
||||
private static final String TAG = "DateUtils";
|
||||
|
||||
public static final String[] RFC822DATES = { "dd MMM yy HH:mm:ss Z", };
|
||||
private static final String[] RFC822DATES = { "dd MMM yy HH:mm:ss Z", };
|
||||
|
||||
/** RFC 3339 date format for UTC dates. */
|
||||
public static final String RFC3339UTC = "yyyy-MM-dd'T'HH:mm:ss'Z'";
|
||||
@ -123,12 +123,12 @@ public class SyndDateUtils {
|
||||
int idx = 0;
|
||||
if (parts.length == 3) {
|
||||
// string has hours
|
||||
result += Integer.valueOf(parts[idx]) * 3600000;
|
||||
result += Integer.valueOf(parts[idx]) * 3600000L;
|
||||
idx++;
|
||||
}
|
||||
result += Integer.valueOf(parts[idx]) * 60000;
|
||||
result += Integer.valueOf(parts[idx]) * 60000L;
|
||||
idx++;
|
||||
result += (Float.valueOf(parts[idx])) * 1000;
|
||||
result += (Float.valueOf(parts[idx])) * 1000L;
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,11 @@
|
||||
package de.danoeh.antennapod.util;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class LangUtils {
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
|
||||
private static HashMap<String, String> languages;
|
||||
static {
|
||||
languages = new HashMap<String, String>();
|
||||
|
@ -9,8 +9,7 @@ public class DownloadStatusComparator implements Comparator<DownloadStatus> {
|
||||
|
||||
@Override
|
||||
public int compare(DownloadStatus lhs, DownloadStatus rhs) {
|
||||
return -lhs.getCompletionDate().compareTo(rhs.getCompletionDate());
|
||||
|
||||
return rhs.getCompletionDate().compareTo(lhs.getCompletionDate());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,7 @@ public class FeedItemPubdateComparator implements Comparator<FeedItem> {
|
||||
}*/
|
||||
@Override
|
||||
public int compare(FeedItem lhs, FeedItem rhs) {
|
||||
return -lhs.getPubDate().compareTo(rhs.getPubDate());
|
||||
return rhs.getPubDate().compareTo(lhs.getPubDate());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -11,8 +11,8 @@ public class PlaybackCompletionDateComparator implements Comparator<FeedItem> {
|
||||
&& lhs.getMedia().getPlaybackCompletionDate() != null
|
||||
&& rhs.getMedia() != null
|
||||
&& rhs.getMedia().getPlaybackCompletionDate() != null) {
|
||||
return -lhs.getMedia().getPlaybackCompletionDate()
|
||||
.compareTo(rhs.getMedia().getPlaybackCompletionDate());
|
||||
return rhs.getMedia().getPlaybackCompletionDate()
|
||||
.compareTo(lhs.getMedia().getPlaybackCompletionDate());
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ public class ExternalMedia implements Playable {
|
||||
|
||||
private String episodeTitle;
|
||||
private String feedTitle;
|
||||
private String shownotes;
|
||||
private MediaType mediaType = MediaType.AUDIO;
|
||||
private List<Chapter> chapters;
|
||||
private int duration;
|
||||
|
Loading…
x
Reference in New Issue
Block a user