Reduced number of FindBugs warnings
This commit is contained in:
parent
ffd1070270
commit
fd5f1fcc0b
|
@ -4,6 +4,7 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.app.SearchManager;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
|
@ -140,10 +141,10 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
|
|||
@Override
|
||||
public void run() {
|
||||
Log.d(TAG, "Starting background work");
|
||||
final Activity activity = SearchActivity.this;
|
||||
final List<SearchResult> result = FeedSearcher
|
||||
.performSearch(SearchActivity.this, query, feedID);
|
||||
if (SearchActivity.this != null) {
|
||||
SearchActivity.this.runOnUiThread(new Runnable() {
|
||||
.performSearch(activity, query, feedID);
|
||||
activity.runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
|
@ -167,7 +168,7 @@ public class SearchActivity extends ActionBarActivity implements AdapterView.OnI
|
|||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
};
|
||||
thread.start();
|
||||
|
|
|
@ -144,53 +144,6 @@ public class ChapterListAdapter extends ArrayAdapter<Chapter> {
|
|||
TextView link;
|
||||
}
|
||||
|
||||
private LinkMovementMethod linkMovementMethod = new LinkMovementMethod() {
|
||||
|
||||
@Override
|
||||
public boolean onTouchEvent(TextView widget, Spannable buffer,
|
||||
MotionEvent event) {
|
||||
Object text = widget.getText();
|
||||
if (text instanceof Spanned) {
|
||||
int action = event.getAction();
|
||||
|
||||
if (action == MotionEvent.ACTION_UP
|
||||
|| action == MotionEvent.ACTION_DOWN) {
|
||||
int x = (int) event.getX();
|
||||
int y = (int) event.getY();
|
||||
|
||||
x -= widget.getTotalPaddingLeft();
|
||||
y -= widget.getTotalPaddingTop();
|
||||
|
||||
x += widget.getScrollX();
|
||||
y += widget.getScrollY();
|
||||
|
||||
Layout layout = widget.getLayout();
|
||||
int line = layout.getLineForVertical(y);
|
||||
int off = layout.getOffsetForHorizontal(line, x);
|
||||
|
||||
ClickableSpan[] link = buffer.getSpans(off, off,
|
||||
ClickableSpan.class);
|
||||
|
||||
if (link.length != 0) {
|
||||
if (action == MotionEvent.ACTION_UP) {
|
||||
link[0].onClick(widget);
|
||||
} else if (action == MotionEvent.ACTION_DOWN) {
|
||||
Selection.setSelection(buffer,
|
||||
buffer.getSpanStart(link[0]),
|
||||
buffer.getSpanEnd(link[0]));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
// ignore invalid chapters
|
||||
|
|
|
@ -77,7 +77,7 @@ public class ImageLoader {
|
|||
});
|
||||
}
|
||||
|
||||
public static ImageLoader getInstance() {
|
||||
public static synchronized ImageLoader getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new ImageLoader();
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class EventDistributor extends Observable {
|
|||
events = new ConcurrentLinkedQueue<Integer>();
|
||||
}
|
||||
|
||||
public static EventDistributor getInstance() {
|
||||
public static synchronized EventDistributor getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new EventDistributor();
|
||||
}
|
||||
|
|
|
@ -87,11 +87,7 @@ public class Feed extends FeedFile {
|
|||
*/
|
||||
public Feed(String url, Date lastUpdate) {
|
||||
super(null, url, false);
|
||||
if (lastUpdate != null) {
|
||||
this.lastUpdate = lastUpdate;
|
||||
} else {
|
||||
this.lastUpdate = null;
|
||||
}
|
||||
this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -323,19 +319,11 @@ public class Feed extends FeedFile {
|
|||
}
|
||||
|
||||
public Date getLastUpdate() {
|
||||
if (lastUpdate != null) {
|
||||
return (Date) lastUpdate.clone();
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
return (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
}
|
||||
|
||||
public void setLastUpdate(Date lastUpdate) {
|
||||
if (lastUpdate != null) {
|
||||
this.lastUpdate = (Date) lastUpdate.clone();
|
||||
} else {
|
||||
this.lastUpdate = null;
|
||||
}
|
||||
this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
}
|
||||
|
||||
public String getFeedIdentifier() {
|
||||
|
|
|
@ -265,9 +265,9 @@ public class FeedlistFragment extends Fragment implements
|
|||
public boolean onItemLongClick(AdapterView<?> parent, View view,
|
||||
int position, long id) {
|
||||
Feed selection = fla.getItem(position);
|
||||
if (selection != null) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Selected Feed with title " + selection.getTitle());
|
||||
if (selection != null) {
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
|
|
|
@ -374,11 +374,10 @@ public class ItemDescriptionFragment extends Fragment {
|
|||
Callable<String> shownotesLoadTask = shownotesProvider.loadShownotes();
|
||||
final String shownotes = shownotesLoadTask.call();
|
||||
|
||||
data = "";
|
||||
data = StringEscapeUtils.unescapeHtml4(shownotes);
|
||||
Activity activity = getActivity();
|
||||
if (activity != null) {
|
||||
TypedArray res = getActivity()
|
||||
TypedArray res = activity
|
||||
.getTheme()
|
||||
.obtainStyledAttributes(
|
||||
new int[]{android.R.attr.textColorPrimary});
|
||||
|
|
|
@ -50,7 +50,6 @@ public class ItemlistFragment extends ListFragment {
|
|||
public static final String EXTRA_SELECTED_FEEDITEM = "extra.de.danoeh.antennapod.activity.selected_feeditem";
|
||||
public static final String ARGUMENT_FEED_ID = "argument.de.danoeh.antennapod.feed_id";
|
||||
protected InternalFeedItemlistAdapter fila;
|
||||
protected DownloadRequester requester = DownloadRequester.getInstance();
|
||||
|
||||
private Feed feed;
|
||||
protected List<Long> queue;
|
||||
|
@ -156,8 +155,6 @@ public class ItemlistFragment extends ListFragment {
|
|||
} else {
|
||||
Log.e(TAG, "Could not load queue");
|
||||
}
|
||||
if (result.getItems().isEmpty()) {
|
||||
}
|
||||
setEmptyViewIfListIsEmpty();
|
||||
if (fila != null) {
|
||||
fila.notifyDataSetChanged();
|
||||
|
|
|
@ -184,7 +184,7 @@ public class DownloadService extends Service {
|
|||
public int onStartCommand(Intent intent, int flags, int startId) {
|
||||
if (intent.getParcelableExtra(EXTRA_REQUEST) != null) {
|
||||
onDownloadQueued(intent);
|
||||
} else if (numberOfDownloads.equals(0)) {
|
||||
} else if (numberOfDownloads.get() == 0) {
|
||||
stopSelf();
|
||||
}
|
||||
return Service.START_NOT_STICKY;
|
||||
|
|
|
@ -70,10 +70,25 @@ public class HttpDownloader extends Downloader {
|
|||
int responseCode = response.getStatusLine().getStatusCode();
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Response code is " + responseCode);
|
||||
if (responseCode == HttpURLConnection.HTTP_OK && httpEntity != null) {
|
||||
if (StorageUtils.storageAvailable(PodcastApp.getInstance())) {
|
||||
|
||||
if (responseCode != HttpURLConnection.HTTP_OK || httpEntity == null) {
|
||||
onFail(DownloadError.ERROR_HTTP_DATA_ERROR,
|
||||
String.valueOf(responseCode));
|
||||
return;
|
||||
}
|
||||
|
||||
if (!StorageUtils.storageAvailable(PodcastApp.getInstance())) {
|
||||
onFail(DownloadError.ERROR_DEVICE_NOT_FOUND, null);
|
||||
return;
|
||||
}
|
||||
|
||||
File destination = new File(request.getDestination());
|
||||
if (!destination.exists()) {
|
||||
if (destination.exists()) {
|
||||
Log.w(TAG, "File already exists");
|
||||
onFail(DownloadError.ERROR_FILE_EXISTS, null);
|
||||
return;
|
||||
}
|
||||
|
||||
connection = new BufferedInputStream(AndroidHttpClient
|
||||
.getUngzippedContent(httpEntity));
|
||||
out = new BufferedOutputStream(new FileOutputStream(
|
||||
|
@ -93,8 +108,13 @@ public class HttpDownloader extends Downloader {
|
|||
long freeSpace = StorageUtils.getFreeSpaceAvailable();
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Free space is " + freeSpace);
|
||||
if (request.getSize() == DownloadStatus.SIZE_UNKNOWN
|
||||
|| request.getSize() <= freeSpace) {
|
||||
|
||||
if (request.getSize() != DownloadStatus.SIZE_UNKNOWN
|
||||
&& request.getSize() > freeSpace) {
|
||||
onFail(DownloadError.ERROR_NOT_ENOUGH_SPACE, null);
|
||||
return;
|
||||
}
|
||||
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Starting download");
|
||||
while (!cancelled
|
||||
|
@ -120,20 +140,7 @@ public class HttpDownloader extends Downloader {
|
|||
}
|
||||
onSuccess();
|
||||
}
|
||||
} else {
|
||||
onFail(DownloadError.ERROR_NOT_ENOUGH_SPACE, null);
|
||||
}
|
||||
} else {
|
||||
Log.w(TAG, "File already exists");
|
||||
onFail(DownloadError.ERROR_FILE_EXISTS, null);
|
||||
}
|
||||
} else {
|
||||
onFail(DownloadError.ERROR_DEVICE_NOT_FOUND, null);
|
||||
}
|
||||
} else {
|
||||
onFail(DownloadError.ERROR_HTTP_DATA_ERROR,
|
||||
String.valueOf(responseCode));
|
||||
}
|
||||
|
||||
} catch (IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
onFail(DownloadError.ERROR_MALFORMED_URL, e.getMessage());
|
||||
|
@ -179,7 +186,9 @@ public class HttpDownloader extends Downloader {
|
|||
cleanup();
|
||||
}
|
||||
|
||||
/** Deletes unfinished downloads. */
|
||||
/**
|
||||
* Deletes unfinished downloads.
|
||||
*/
|
||||
private void cleanup() {
|
||||
if (request.getDestination() != null) {
|
||||
File dest = new File(request.getDestination());
|
||||
|
|
|
@ -229,9 +229,11 @@ public final class DBReader {
|
|||
title, item, link);
|
||||
break;
|
||||
}
|
||||
if (chapter != null) {
|
||||
chapter.setId(chapterCursor
|
||||
.getLong(PodDBAdapter.KEY_ID_INDEX));
|
||||
item.getChapters().add(chapter);
|
||||
}
|
||||
} while (chapterCursor.moveToNext());
|
||||
}
|
||||
chapterCursor.close();
|
||||
|
|
|
@ -38,7 +38,7 @@ public class DownloadRequester {
|
|||
downloads = new ConcurrentHashMap<String, DownloadRequest>();
|
||||
}
|
||||
|
||||
public static DownloadRequester getInstance() {
|
||||
public static synchronized DownloadRequester getInstance() {
|
||||
if (downloader == null) {
|
||||
downloader = new DownloadRequester();
|
||||
}
|
||||
|
|
|
@ -17,7 +17,7 @@ public class FeedItemStatistics {
|
|||
this.numberOfItems = numberOfItems;
|
||||
this.numberOfNewItems = numberOfNewItems;
|
||||
this.numberOfInProgressItems = numberOfInProgressItems;
|
||||
this.lastUpdate = lastUpdate;
|
||||
this.lastUpdate = (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
}
|
||||
|
||||
public long getFeedID() {
|
||||
|
@ -37,6 +37,6 @@ public class FeedItemStatistics {
|
|||
}
|
||||
|
||||
public Date getLastUpdate() {
|
||||
return lastUpdate;
|
||||
return (lastUpdate != null) ? (Date) lastUpdate.clone() : null;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -35,9 +35,9 @@ public class ChapterUtils {
|
|||
* chapters.
|
||||
*/
|
||||
public static void readID3ChaptersFromPlayableStreamUrl(Playable p) {
|
||||
if (p != null && p.getStreamUrl() != null) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Reading id3 chapters from item " + p.getEpisodeTitle());
|
||||
if (p != null && p.getStreamUrl() != null) {
|
||||
InputStream in = null;
|
||||
try {
|
||||
URL url = new URL(p.getStreamUrl());
|
||||
|
@ -86,9 +86,9 @@ public class ChapterUtils {
|
|||
* chapters.
|
||||
*/
|
||||
public static void readID3ChaptersFromPlayableFileUrl(Playable p) {
|
||||
if (p != null && p.localFileAvailable() && p.getLocalMediaUrl() != null) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Reading id3 chapters from item " + p.getEpisodeTitle());
|
||||
if (p != null && p.localFileAvailable() && p.getLocalMediaUrl() != null) {
|
||||
File source = new File(p.getLocalMediaUrl());
|
||||
if (source.exists()) {
|
||||
ChapterReader reader = new ChapterReader();
|
||||
|
|
Loading…
Reference in New Issue