mirror of
https://github.com/AntennaPod/AntennaPod.git
synced 2025-01-31 19:04:52 +01:00
Implemented EventDistributor
This commit is contained in:
parent
f9e00f72a0
commit
955d296638
@ -6,6 +6,7 @@ import android.content.res.Configuration;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
@ -40,6 +41,7 @@ public class PodcastApp extends Application implements
|
||||
PlaybackService.NO_MEDIA_PLAYING);
|
||||
prefs.registerOnSharedPreferenceChangeListener(this);
|
||||
UserPreferences.createInstance(this);
|
||||
EventDistributor.getInstance();
|
||||
FeedManager manager = FeedManager.getInstance();
|
||||
manager.loadDBData(getApplicationContext());
|
||||
}
|
||||
|
@ -1,9 +1,5 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockListActivity;
|
||||
@ -11,6 +7,7 @@ import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
|
||||
import de.danoeh.antennapod.adapter.DownloadLogAdapter;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
@ -38,14 +35,13 @@ public class DownloadLogActivity extends SherlockListActivity {
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
unregisterReceiver(contentUpdate);
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
registerReceiver(contentUpdate, new IntentFilter(
|
||||
FeedManager.ACTION_DOWNLOADLOG_UPDATE));
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@ -66,12 +62,11 @@ public class DownloadLogActivity extends SherlockListActivity {
|
||||
return true;
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction()
|
||||
.equals(FeedManager.ACTION_DOWNLOADLOG_UPDATE)) {
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((arg & EventDistributor.DOWNLOADLOG_UPDATE) != 0) {
|
||||
dla.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
@ -1,9 +1,7 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
import android.support.v4.app.FragmentManager;
|
||||
@ -21,6 +19,7 @@ import com.viewpagerindicator.TabPageIndicator;
|
||||
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.fragment.EpisodesFragment;
|
||||
import de.danoeh.antennapod.fragment.ExternalPlayerFragment;
|
||||
@ -35,6 +34,9 @@ import de.danoeh.antennapod.util.StorageUtils;
|
||||
public class MainActivity extends SherlockFragmentActivity {
|
||||
private static final String TAG = "MainActivity";
|
||||
|
||||
private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED
|
||||
| EventDistributor.DOWNLOAD_QUEUED;
|
||||
|
||||
private FeedManager manager;
|
||||
private ViewPager viewpager;
|
||||
private MainPagerAdapter pagerAdapter;
|
||||
@ -79,7 +81,7 @@ public class MainActivity extends SherlockFragmentActivity {
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
unregisterReceiver(contentUpdate);
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,18 +89,19 @@ public class MainActivity extends SherlockFragmentActivity {
|
||||
super.onResume();
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
updateProgressBarVisibility();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||
registerReceiver(contentUpdate, filter);
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
updateProgressBarVisibility();
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
updateProgressBarVisibility();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
package de.danoeh.antennapod.activity;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.res.TypedArray;
|
||||
import android.os.Bundle;
|
||||
import android.view.LayoutInflater;
|
||||
@ -20,6 +17,7 @@ import com.mobeta.android.dslv.DragSortListView;
|
||||
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
@ -48,30 +46,25 @@ public class OrganizeQueueActivity extends SherlockListActivity {
|
||||
@Override
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
try {
|
||||
unregisterReceiver(contentUpdate);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
}
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
IntentFilter filter = new IntentFilter(FeedManager.ACTION_QUEUE_UPDATE);
|
||||
filter.addAction(FeedManager.ACTION_FEED_LIST_UPDATE);
|
||||
registerReceiver(contentUpdate, filter);
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if (((EventDistributor.QUEUE_UPDATE | EventDistributor.FEED_LIST_UPDATE) & arg) != 0) {
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
private DragSortListView.DropListener dropListener = new DragSortListView.DropListener() {
|
||||
|
@ -10,7 +10,6 @@ import android.widget.BaseExpandableListAdapter;
|
||||
import android.widget.ImageButton;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.asynctask.FeedImageLoader;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
@ -18,7 +17,6 @@ import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.feed.FeedMedia;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.util.Converter;
|
||||
import de.danoeh.antennapod.util.EpisodeFilter;
|
||||
|
||||
/**
|
||||
* Displays unread items and items in the queue in one combined list. The
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.danoeh.antennapod.adapter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.res.TypedArray;
|
||||
|
@ -1,14 +1,12 @@
|
||||
package de.danoeh.antennapod.adapter;
|
||||
|
||||
import java.text.DateFormat;
|
||||
import java.util.List;
|
||||
|
||||
import android.content.Context;
|
||||
import android.text.format.DateUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ArrayAdapter;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
|
140
src/de/danoeh/antennapod/feed/EventDistributor.java
Normal file
140
src/de/danoeh/antennapod/feed/EventDistributor.java
Normal file
@ -0,0 +1,140 @@
|
||||
package de.danoeh.antennapod.feed;
|
||||
|
||||
import java.util.AbstractQueue;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
import java.util.concurrent.ConcurrentLinkedQueue;
|
||||
|
||||
import android.os.Handler;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
|
||||
/**
|
||||
* Notifies its observers about changes in the feed database. Observers can
|
||||
* register by retrieving an instance of this class and registering an
|
||||
* EventListener. When new events arrive, the EventDistributor will process the
|
||||
* event queue in a handler that runs on the main thread. The observers will only
|
||||
* be notified once if the event queue contains multiple elements.
|
||||
*
|
||||
* Events can be sent with the send* methods.
|
||||
*/
|
||||
public class EventDistributor extends Observable {
|
||||
private static final String TAG = "EventDistributor";
|
||||
|
||||
public static final int FEED_LIST_UPDATE = 1;
|
||||
public static final int UNREAD_ITEMS_UPDATE = 2;
|
||||
public static final int QUEUE_UPDATE = 4;
|
||||
public static final int DOWNLOADLOG_UPDATE = 8;
|
||||
public static final int PLAYBACK_HISTORY_UPDATE = 16;
|
||||
public static final int DOWNLOAD_QUEUED = 32;
|
||||
public static final int DOWNLOAD_HANDLED = 64;
|
||||
|
||||
private Handler handler;
|
||||
private AbstractQueue<Integer> events;
|
||||
|
||||
private static EventDistributor instance;
|
||||
|
||||
private EventDistributor() {
|
||||
this.handler = new Handler();
|
||||
events = new ConcurrentLinkedQueue<Integer>();
|
||||
}
|
||||
|
||||
public static EventDistributor getInstance() {
|
||||
if (instance == null) {
|
||||
instance = new EventDistributor();
|
||||
}
|
||||
return instance;
|
||||
}
|
||||
|
||||
public void register(EventListener el) {
|
||||
addObserver(el);
|
||||
}
|
||||
|
||||
public void unregister(EventListener el) {
|
||||
deleteObserver(el);
|
||||
}
|
||||
|
||||
public void addEvent(Integer i) {
|
||||
events.offer(i);
|
||||
handler.post(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
processEventQueue();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private void processEventQueue() {
|
||||
Integer result = 0;
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG,
|
||||
"Processing event queue. Number of events: "
|
||||
+ events.size());
|
||||
for (Integer current = events.poll(); current != null; current = events
|
||||
.poll()) {
|
||||
result |= current;
|
||||
}
|
||||
if (result != 0) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Notifying observers. Data: " + result);
|
||||
setChanged();
|
||||
notifyObservers(result);
|
||||
} else {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG,
|
||||
"Event queue didn't contain any new events. Observers will not be notified.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addObserver(Observer observer) {
|
||||
super.addObserver(observer);
|
||||
if (!(observer instanceof EventListener)) {
|
||||
throw new IllegalArgumentException(
|
||||
"Observer must be instance of FeedManager.EventListener");
|
||||
}
|
||||
}
|
||||
|
||||
public void sendDownloadQueuedBroadcast() {
|
||||
addEvent(DOWNLOAD_QUEUED);
|
||||
}
|
||||
|
||||
public void sendUnreadItemsUpdateBroadcast() {
|
||||
addEvent(UNREAD_ITEMS_UPDATE);
|
||||
}
|
||||
|
||||
public void sendQueueUpdateBroadcast() {
|
||||
addEvent(QUEUE_UPDATE);
|
||||
}
|
||||
|
||||
public void sendFeedUpdateBroadcast() {
|
||||
addEvent(FEED_LIST_UPDATE);
|
||||
}
|
||||
|
||||
public void sendPlaybackHistoryUpdateBroadcast() {
|
||||
addEvent(PLAYBACK_HISTORY_UPDATE);
|
||||
}
|
||||
|
||||
public void sendDownloadLogUpdateBroadcast() {
|
||||
addEvent(DOWNLOADLOG_UPDATE);
|
||||
}
|
||||
|
||||
public void sendDownloadHandledBroadcast() {
|
||||
addEvent(DOWNLOAD_HANDLED);
|
||||
}
|
||||
|
||||
public static abstract class EventListener implements Observer {
|
||||
|
||||
@Override
|
||||
public void update(Observable observable, Object data) {
|
||||
if (observable instanceof EventDistributor
|
||||
&& data instanceof Integer) {
|
||||
update((EventDistributor) observable, (Integer) data);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract void update(EventDistributor eventDistributor,
|
||||
Integer arg);
|
||||
}
|
||||
}
|
@ -4,11 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import android.content.SyncResult;
|
||||
import android.preference.PreferenceManager;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
import de.danoeh.antennapod.util.EpisodeFilter;
|
||||
|
||||
|
@ -41,14 +41,6 @@ import de.danoeh.antennapod.util.exception.MediaFileNotFoundException;
|
||||
public class FeedManager {
|
||||
private static final String TAG = "FeedManager";
|
||||
|
||||
public static final String ACTION_FEED_LIST_UPDATE = "de.danoeh.antennapod.action.feed.feedlistUpdate";
|
||||
public static final String ACTION_UNREAD_ITEMS_UPDATE = "de.danoeh.antennapod.action.feed.unreadItemsUpdate";
|
||||
public static final String ACTION_QUEUE_UPDATE = "de.danoeh.antennapod.action.feed.queueUpdate";
|
||||
public static final String ACTION_DOWNLOADLOG_UPDATE = "de.danoeh.antennapod.action.feed.downloadLogUpdate";
|
||||
public static final String ACTION_PLAYBACK_HISTORY_UPDATE = "de.danoeh.antennapod.action.feed.playbackHistoryUpdate";
|
||||
public static final String EXTRA_FEED_ITEM_ID = "de.danoeh.antennapod.extra.feed.feedItemId";
|
||||
public static final String EXTRA_FEED_ID = "de.danoeh.antennapod.extra.feed.feedId";
|
||||
|
||||
/** Number of completed Download status entries to store. */
|
||||
private static final int DOWNLOAD_LOG_SIZE = 50;
|
||||
|
||||
@ -81,6 +73,8 @@ public class FeedManager {
|
||||
/** Prevents user from starting several feed updates at the same time. */
|
||||
private static boolean isStartingFeedRefresh = false;
|
||||
|
||||
private EventDistributor eventDist = EventDistributor.getInstance();
|
||||
|
||||
private FeedManager() {
|
||||
feeds = Collections.synchronizedList(new ArrayList<Feed>());
|
||||
unreadItems = Collections.synchronizedList(new ArrayList<FeedItem>());
|
||||
@ -214,7 +208,7 @@ public class FeedManager {
|
||||
@Override
|
||||
public void run() {
|
||||
feeds.remove(feed);
|
||||
sendFeedUpdateBroadcast(context);
|
||||
eventDist.sendFeedUpdateBroadcast();
|
||||
dbExec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -267,32 +261,6 @@ public class FeedManager {
|
||||
|
||||
}
|
||||
|
||||
private void sendUnreadItemsUpdateBroadcast(Context context, FeedItem item) {
|
||||
Intent update = new Intent(ACTION_UNREAD_ITEMS_UPDATE);
|
||||
if (item != null) {
|
||||
update.putExtra(EXTRA_FEED_ID, item.getFeed().getId());
|
||||
update.putExtra(EXTRA_FEED_ITEM_ID, item.getId());
|
||||
}
|
||||
context.sendBroadcast(update);
|
||||
}
|
||||
|
||||
private void sendQueueUpdateBroadcast(Context context, FeedItem item) {
|
||||
Intent update = new Intent(ACTION_QUEUE_UPDATE);
|
||||
if (item != null) {
|
||||
update.putExtra(EXTRA_FEED_ID, item.getFeed().getId());
|
||||
update.putExtra(EXTRA_FEED_ITEM_ID, item.getId());
|
||||
}
|
||||
context.sendBroadcast(update);
|
||||
}
|
||||
|
||||
private void sendFeedUpdateBroadcast(Context context) {
|
||||
context.sendBroadcast(new Intent(ACTION_FEED_LIST_UPDATE));
|
||||
}
|
||||
|
||||
private void sendPlaybackHistoryUpdateBroadcast(Context context) {
|
||||
context.sendBroadcast(new Intent(ACTION_PLAYBACK_HISTORY_UPDATE));
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes sure that playback history is sorted and is not larger than
|
||||
* PLAYBACK_HISTORY_SIZE.
|
||||
@ -354,7 +322,7 @@ public class FeedManager {
|
||||
final FeedItem[] items = playbackHistory
|
||||
.toArray(new FeedItem[playbackHistory.size()]);
|
||||
playbackHistory.clear();
|
||||
sendPlaybackHistoryUpdateBroadcast(context);
|
||||
eventDist.sendPlaybackHistoryUpdateBroadcast();
|
||||
dbExec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -383,13 +351,13 @@ public class FeedManager {
|
||||
playbackHistory.add(item);
|
||||
}
|
||||
cleanupPlaybackHistoryWithDBCleanup(context);
|
||||
sendPlaybackHistoryUpdateBroadcast(context);
|
||||
eventDist.sendPlaybackHistoryUpdateBroadcast();
|
||||
}
|
||||
}
|
||||
|
||||
private void removeItemFromPlaybackHistory(Context context, FeedItem item) {
|
||||
playbackHistory.remove(item);
|
||||
sendPlaybackHistoryUpdateBroadcast(context);
|
||||
eventDist.sendPlaybackHistoryUpdateBroadcast();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -421,7 +389,7 @@ public class FeedManager {
|
||||
Collections.sort(unreadItems,
|
||||
new FeedItemPubdateComparator());
|
||||
}
|
||||
sendUnreadItemsUpdateBroadcast(context, item);
|
||||
eventDist.sendUnreadItemsUpdateBroadcast();
|
||||
}
|
||||
});
|
||||
|
||||
@ -450,7 +418,7 @@ public class FeedManager {
|
||||
final ArrayList<FeedItem> unreadItemsCopy = new ArrayList<FeedItem>(
|
||||
unreadItems);
|
||||
unreadItems.clear();
|
||||
sendUnreadItemsUpdateBroadcast(context, null);
|
||||
eventDist.sendUnreadItemsUpdateBroadcast();
|
||||
dbExec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -537,7 +505,7 @@ public class FeedManager {
|
||||
media.setDownloaded(false);
|
||||
media.setFile_url(null);
|
||||
setFeedMedia(context, media);
|
||||
sendFeedUpdateBroadcast(context);
|
||||
eventDist.sendFeedUpdateBroadcast();
|
||||
}
|
||||
|
||||
public void refreshFeed(Context context, Feed feed)
|
||||
@ -560,7 +528,7 @@ public class FeedManager {
|
||||
} else {
|
||||
removedStatus = null;
|
||||
}
|
||||
context.sendBroadcast(new Intent(ACTION_DOWNLOADLOG_UPDATE));
|
||||
eventDist.sendDownloadLogUpdateBroadcast();
|
||||
dbExec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -641,7 +609,7 @@ public class FeedManager {
|
||||
queue.add(item);
|
||||
}
|
||||
}
|
||||
sendQueueUpdateBroadcast(context, items[0]);
|
||||
eventDist.sendQueueUpdateBroadcast();
|
||||
dbExec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -677,7 +645,7 @@ public class FeedManager {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Clearing queue");
|
||||
queue.clear();
|
||||
sendQueueUpdateBroadcast(context, null);
|
||||
eventDist.sendQueueUpdateBroadcast();
|
||||
dbExec.execute(new Runnable() {
|
||||
|
||||
@Override
|
||||
@ -717,7 +685,7 @@ public class FeedManager {
|
||||
});
|
||||
|
||||
}
|
||||
sendQueueUpdateBroadcast(context, item);
|
||||
eventDist.sendQueueUpdateBroadcast();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -793,7 +761,7 @@ public class FeedManager {
|
||||
}
|
||||
});
|
||||
if (broadcastUpdate) {
|
||||
sendQueueUpdateBroadcast(context, item);
|
||||
eventDist.sendQueueUpdateBroadcast();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -817,7 +785,7 @@ public class FeedManager {
|
||||
public void run() {
|
||||
feeds.add(feed);
|
||||
Collections.sort(feeds, new FeedtitleComparator());
|
||||
sendFeedUpdateBroadcast(context);
|
||||
eventDist.sendFeedUpdateBroadcast();
|
||||
}
|
||||
});
|
||||
setCompleteFeed(context, feed);
|
||||
@ -1688,4 +1656,4 @@ public class FeedManager {
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@ -1,9 +1,6 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
@ -25,16 +22,21 @@ import de.danoeh.antennapod.activity.OrganizeQueueActivity;
|
||||
import de.danoeh.antennapod.adapter.ActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.ExternalEpisodesListAdapter;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
|
||||
public class EpisodesFragment extends SherlockFragment {
|
||||
private static final String TAG = "EpisodesFragment";
|
||||
|
||||
private static final int EVENTS = EventDistributor.QUEUE_UPDATE
|
||||
| EventDistributor.UNREAD_ITEMS_UPDATE
|
||||
| EventDistributor.FEED_LIST_UPDATE
|
||||
| EventDistributor.DOWNLOAD_HANDLED
|
||||
| EventDistributor.DOWNLOAD_QUEUED;
|
||||
|
||||
private ExpandableListView listView;
|
||||
private ExternalEpisodesListAdapter adapter;
|
||||
|
||||
@ -45,24 +47,14 @@ public class EpisodesFragment extends SherlockFragment {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
try {
|
||||
getActivity().unregisterReceiver(contentUpdate);
|
||||
} catch (IllegalArgumentException e) {
|
||||
|
||||
}
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||
filter.addAction(FeedManager.ACTION_QUEUE_UPDATE);
|
||||
filter.addAction(FeedManager.ACTION_UNREAD_ITEMS_UPDATE);
|
||||
filter.addAction(FeedManager.ACTION_FEED_LIST_UPDATE);
|
||||
|
||||
getActivity().registerReceiver(contentUpdate, filter);
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
if (adapter != null) {
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
@ -128,12 +120,15 @@ public class EpisodesFragment extends SherlockFragment {
|
||||
registerForContextMenu(listView);
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
adapter.notifyDataSetChanged();
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
adapter.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -2,11 +2,8 @@ package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.DialogInterface;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.LayoutInflater;
|
||||
@ -18,7 +15,6 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
import com.actionbarsherlock.app.SherlockFragmentActivity;
|
||||
import com.actionbarsherlock.view.ActionMode;
|
||||
import com.actionbarsherlock.view.Menu;
|
||||
import com.actionbarsherlock.view.MenuItem;
|
||||
@ -30,17 +26,22 @@ import de.danoeh.antennapod.adapter.FeedlistAdapter;
|
||||
import de.danoeh.antennapod.asynctask.FeedRemover;
|
||||
import de.danoeh.antennapod.dialog.ConfirmationDialog;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.service.download.DownloadService;
|
||||
import de.danoeh.antennapod.storage.DownloadRequestException;
|
||||
import de.danoeh.antennapod.storage.DownloadRequester;
|
||||
import de.danoeh.antennapod.util.menuhandler.FeedMenuHandler;
|
||||
|
||||
public class FeedlistFragment extends SherlockFragment implements
|
||||
ActionMode.Callback, AdapterView.OnItemClickListener,
|
||||
AdapterView.OnItemLongClickListener {
|
||||
private static final String TAG = "FeedlistFragment";
|
||||
|
||||
private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED
|
||||
| EventDistributor.DOWNLOAD_QUEUED
|
||||
| EventDistributor.FEED_LIST_UPDATE
|
||||
| EventDistributor.UNREAD_ITEMS_UPDATE;
|
||||
|
||||
public static final String EXTRA_SELECTED_FEED = "extra.de.danoeh.antennapod.activity.selected_feed";
|
||||
|
||||
private FeedManager manager;
|
||||
@ -110,36 +111,28 @@ public class FeedlistFragment extends SherlockFragment implements
|
||||
super.onResume();
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Resuming");
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||
filter.addAction(FeedManager.ACTION_UNREAD_ITEMS_UPDATE);
|
||||
filter.addAction(FeedManager.ACTION_FEED_LIST_UPDATE);
|
||||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||
getActivity().registerReceiver(contentUpdate, filter);
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
fla.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
getActivity().unregisterReceiver(contentUpdate);
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
if (mActionMode != null) {
|
||||
mActionMode.finish();
|
||||
}
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, final Intent intent) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
getActivity().runOnUiThread(new Runnable() {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
fla.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
fla.notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -28,7 +28,6 @@ import android.widget.Toast;
|
||||
import com.actionbarsherlock.app.SherlockFragment;
|
||||
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
|
@ -1,12 +1,7 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import android.view.ContextMenu;
|
||||
@ -26,6 +21,7 @@ import de.danoeh.antennapod.adapter.AbstractFeedItemlistAdapter;
|
||||
import de.danoeh.antennapod.adapter.ActionButtonCallback;
|
||||
import de.danoeh.antennapod.adapter.FeedItemlistAdapter;
|
||||
import de.danoeh.antennapod.dialog.DownloadRequestErrorDialogCreator;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
@ -37,8 +33,13 @@ import de.danoeh.antennapod.util.menuhandler.FeedItemMenuHandler;
|
||||
/** Displays a list of FeedItems. */
|
||||
@SuppressLint("ValidFragment")
|
||||
public class ItemlistFragment extends SherlockListFragment {
|
||||
|
||||
private static final String TAG = "ItemlistFragment";
|
||||
|
||||
private static final int EVENTS = EventDistributor.DOWNLOAD_HANDLED
|
||||
| EventDistributor.DOWNLOAD_QUEUED
|
||||
| EventDistributor.QUEUE_UPDATE
|
||||
| EventDistributor.UNREAD_ITEMS_UPDATE;
|
||||
|
||||
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 AbstractFeedItemlistAdapter fila;
|
||||
@ -48,14 +49,15 @@ public class ItemlistFragment extends SherlockListFragment {
|
||||
private AbstractFeedItemlistAdapter.ItemAccess itemAccess;
|
||||
|
||||
private Feed feed;
|
||||
|
||||
|
||||
protected FeedItem selectedItem = null;
|
||||
protected boolean contextMenuClosed = true;
|
||||
|
||||
/** Argument for FeeditemlistAdapter */
|
||||
protected boolean showFeedtitle;
|
||||
|
||||
public ItemlistFragment(AbstractFeedItemlistAdapter.ItemAccess itemAccess, boolean showFeedtitle) {
|
||||
public ItemlistFragment(AbstractFeedItemlistAdapter.ItemAccess itemAccess,
|
||||
boolean showFeedtitle) {
|
||||
super();
|
||||
this.itemAccess = itemAccess;
|
||||
this.showFeedtitle = showFeedtitle;
|
||||
@ -95,12 +97,12 @@ public class ItemlistFragment extends SherlockListFragment {
|
||||
final Feed feed = FeedManager.getInstance().getFeed(feedId);
|
||||
this.feed = feed;
|
||||
itemAccess = new AbstractFeedItemlistAdapter.ItemAccess() {
|
||||
|
||||
|
||||
@Override
|
||||
public FeedItem getItem(int position) {
|
||||
return feed.getItemAtIndex(true, position);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int getCount() {
|
||||
return feed.getNumOfItems(true);
|
||||
@ -122,12 +124,7 @@ public class ItemlistFragment extends SherlockListFragment {
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
try {
|
||||
getActivity().unregisterReceiver(contentUpdate);
|
||||
} catch (IllegalArgumentException e) {
|
||||
Log.w(TAG,
|
||||
"IllegalArgumentException when trying to unregister contentUpdate receiver.");
|
||||
}
|
||||
EventDistributor.getInstance().unregister(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -141,13 +138,7 @@ public class ItemlistFragment extends SherlockListFragment {
|
||||
}
|
||||
});
|
||||
updateProgressBarVisibility();
|
||||
IntentFilter filter = new IntentFilter();
|
||||
filter.addAction(DownloadRequester.ACTION_DOWNLOAD_QUEUED);
|
||||
filter.addAction(DownloadService.ACTION_DOWNLOAD_HANDLED);
|
||||
filter.addAction(FeedManager.ACTION_QUEUE_UPDATE);
|
||||
filter.addAction(FeedManager.ACTION_UNREAD_ITEMS_UPDATE);
|
||||
|
||||
getActivity().registerReceiver(contentUpdate, filter);
|
||||
EventDistributor.getInstance().register(contentUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -161,17 +152,19 @@ public class ItemlistFragment extends SherlockListFragment {
|
||||
startActivity(showItem);
|
||||
}
|
||||
|
||||
private BroadcastReceiver contentUpdate = new BroadcastReceiver() {
|
||||
private EventDistributor.EventListener contentUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
if (intent.getAction().equals(
|
||||
DownloadRequester.ACTION_DOWNLOAD_QUEUED)) {
|
||||
updateProgressBarVisibility();
|
||||
} else {
|
||||
fila.notifyDataSetChanged();
|
||||
updateProgressBarVisibility();
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EVENTS & arg) != 0) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received contentUpdate Intent.");
|
||||
if ((EventDistributor.DOWNLOAD_QUEUED & arg) != 0) {
|
||||
updateProgressBarVisibility();
|
||||
} else {
|
||||
fila.notifyDataSetChanged();
|
||||
updateProgressBarVisibility();
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -1,13 +1,10 @@
|
||||
package de.danoeh.antennapod.fragment;
|
||||
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.content.IntentFilter;
|
||||
import android.os.Bundle;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.adapter.AbstractFeedItemlistAdapter;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.FeedItem;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
|
||||
@ -33,29 +30,26 @@ public class PlaybackHistoryFragment extends ItemlistFragment {
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
getActivity().registerReceiver(historyUpdate,
|
||||
new IntentFilter(FeedManager.ACTION_PLAYBACK_HISTORY_UPDATE));
|
||||
EventDistributor.getInstance().register(historyUpdate);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDestroy() {
|
||||
super.onDestroy();
|
||||
try {
|
||||
getActivity().unregisterReceiver(historyUpdate);
|
||||
} catch (IllegalArgumentException e) {
|
||||
// ignore
|
||||
}
|
||||
EventDistributor.getInstance().unregister(historyUpdate);
|
||||
}
|
||||
|
||||
private BroadcastReceiver historyUpdate = new BroadcastReceiver() {
|
||||
|
||||
private EventDistributor.EventListener historyUpdate = new EventDistributor.EventListener() {
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received content update");
|
||||
fila.notifyDataSetChanged();
|
||||
public void update(EventDistributor eventDistributor, Integer arg) {
|
||||
if ((EventDistributor.PLAYBACK_HISTORY_UPDATE & arg) != 0) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Received content update");
|
||||
fila.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -13,7 +13,6 @@ import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.R.style;
|
||||
import de.danoeh.antennapod.activity.OpmlImportFromPathActivity;
|
||||
import de.danoeh.antennapod.receiver.FeedUpdateReceiver;
|
||||
|
||||
|
@ -5,10 +5,8 @@ import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.preference.PreferenceManager;
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.feed.FeedManager;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
|
@ -36,7 +36,6 @@ import android.util.Log;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.SurfaceHolder;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.AudioplayerActivity;
|
||||
import de.danoeh.antennapod.activity.VideoplayerActivity;
|
||||
|
@ -51,6 +51,7 @@ import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.activity.DownloadActivity;
|
||||
import de.danoeh.antennapod.activity.DownloadLogActivity;
|
||||
import de.danoeh.antennapod.asynctask.DownloadStatus;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedFile;
|
||||
import de.danoeh.antennapod.feed.FeedImage;
|
||||
@ -77,7 +78,6 @@ public class DownloadService extends Service {
|
||||
/** Extra for ACTION_CANCEL_DOWNLOAD */
|
||||
public static final String EXTRA_DOWNLOAD_URL = "downloadUrl";
|
||||
|
||||
public static final String ACTION_DOWNLOAD_HANDLED = "action.de.danoeh.antennapod.service.download_handled";
|
||||
/**
|
||||
* Sent by the DownloadService when the content of the downloads list
|
||||
* changes.
|
||||
@ -89,12 +89,6 @@ public class DownloadService extends Service {
|
||||
/** Extra for ACTION_ENQUEUE_DOWNLOAD intent. */
|
||||
public static final String EXTRA_REQUEST = "request";
|
||||
|
||||
// Download types for ACTION_DOWNLOAD_HANDLED
|
||||
public static final String EXTRA_DOWNLOAD_TYPE = "extra.de.danoeh.antennapod.service.downloadType";
|
||||
public static final int DOWNLOAD_TYPE_FEED = 1;
|
||||
public static final int DOWNLOAD_TYPE_MEDIA = 2;
|
||||
public static final int DOWNLOAD_TYPE_IMAGE = 3;
|
||||
|
||||
private CopyOnWriteArrayList<DownloadStatus> completedDownloads;
|
||||
|
||||
private ExecutorService syncExecutor;
|
||||
@ -462,7 +456,7 @@ public class DownloadService extends Service {
|
||||
Log.e(TAG, "Download failed");
|
||||
saveDownloadStatus(status);
|
||||
}
|
||||
sendDownloadHandledIntent(getDownloadType(download));
|
||||
sendDownloadHandledIntent();
|
||||
downloadsBeingHandled -= 1;
|
||||
}
|
||||
}
|
||||
@ -504,24 +498,8 @@ public class DownloadService extends Service {
|
||||
manager.addDownloadStatus(this, status);
|
||||
}
|
||||
|
||||
/** Returns correct value for EXTRA_DOWNLOAD_TYPE. */
|
||||
private int getDownloadType(FeedFile f) {
|
||||
if (f.getClass() == Feed.class) {
|
||||
return DOWNLOAD_TYPE_FEED;
|
||||
} else if (f.getClass() == FeedImage.class) {
|
||||
return DOWNLOAD_TYPE_IMAGE;
|
||||
} else if (f.getClass() == FeedMedia.class) {
|
||||
return DOWNLOAD_TYPE_MEDIA;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
private void sendDownloadHandledIntent(int type) {
|
||||
Intent intent = new Intent(ACTION_DOWNLOAD_HANDLED);
|
||||
intent.putExtra(EXTRA_DOWNLOAD_TYPE, type);
|
||||
|
||||
sendBroadcast(intent);
|
||||
private void sendDownloadHandledIntent() {
|
||||
EventDistributor.getInstance().sendDownloadHandledBroadcast();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -726,7 +704,7 @@ public class DownloadService extends Service {
|
||||
saveDownloadStatus(new DownloadStatus(savedFeed,
|
||||
savedFeed.getHumanReadableIdentifier(), reason, successful,
|
||||
reasonDetailed));
|
||||
sendDownloadHandledIntent(DOWNLOAD_TYPE_FEED);
|
||||
sendDownloadHandledIntent();
|
||||
downloadsBeingHandled -= 1;
|
||||
handler.post(new Runnable() {
|
||||
|
||||
@ -803,7 +781,7 @@ public class DownloadService extends Service {
|
||||
image.setDownloaded(true);
|
||||
|
||||
saveDownloadStatus(status);
|
||||
sendDownloadHandledIntent(DOWNLOAD_TYPE_IMAGE);
|
||||
sendDownloadHandledIntent();
|
||||
manager.setFeedImage(DownloadService.this, image);
|
||||
if (image.getFeed() != null) {
|
||||
manager.setFeed(DownloadService.this, image.getFeed());
|
||||
@ -867,7 +845,7 @@ public class DownloadService extends Service {
|
||||
}
|
||||
|
||||
saveDownloadStatus(status);
|
||||
sendDownloadHandledIntent(DOWNLOAD_TYPE_MEDIA);
|
||||
sendDownloadHandledIntent();
|
||||
if (chaptersRead) {
|
||||
manager.setFeedItem(DownloadService.this, media.getItem());
|
||||
} else {
|
||||
|
@ -11,7 +11,7 @@ import android.content.Intent;
|
||||
import android.util.Log;
|
||||
import android.webkit.URLUtil;
|
||||
import de.danoeh.antennapod.AppConfig;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.feed.EventDistributor;
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
import de.danoeh.antennapod.feed.FeedFile;
|
||||
import de.danoeh.antennapod.feed.FeedImage;
|
||||
@ -24,11 +24,6 @@ import de.danoeh.antennapod.util.URLChecker;
|
||||
public class DownloadRequester {
|
||||
private static final String TAG = "DownloadRequester";
|
||||
|
||||
public static String EXTRA_DOWNLOAD_ID = "extra.de.danoeh.antennapod.storage.download_id";
|
||||
public static String EXTRA_ITEM_ID = "extra.de.danoeh.antennapod.storage.item_id";
|
||||
|
||||
public static String ACTION_DOWNLOAD_QUEUED = "action.de.danoeh.antennapod.storage.downloadQueued";
|
||||
|
||||
public static String IMAGE_DOWNLOADPATH = "images/";
|
||||
public static String FEED_DOWNLOADPATH = "cache/";
|
||||
public static String MEDIA_DOWNLOADPATH = "media/";
|
||||
@ -71,7 +66,8 @@ public class DownloadRequester {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "Testing filename " + newName);
|
||||
newDest = new File(dest.getParent(), newName);
|
||||
if (!newDest.exists() && isFilenameAvailable(newDest.toString())) {
|
||||
if (!newDest.exists()
|
||||
&& isFilenameAvailable(newDest.toString())) {
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, "File doesn't exist yet. Using "
|
||||
+ newName);
|
||||
@ -103,7 +99,7 @@ public class DownloadRequester {
|
||||
queueIntent.putExtra(DownloadService.EXTRA_REQUEST, request);
|
||||
context.sendBroadcast(queueIntent);
|
||||
}
|
||||
context.sendBroadcast(new Intent(ACTION_DOWNLOAD_QUEUED));
|
||||
EventDistributor.getInstance().sendDownloadQueuedBroadcast();
|
||||
} else {
|
||||
Log.e(TAG, "URL " + item.getDownload_url()
|
||||
+ " is already being downloaded");
|
||||
@ -124,7 +120,8 @@ public class DownloadRequester {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (AppConfig.DEBUG) Log.d(TAG, path + " is available as a download destination");
|
||||
if (AppConfig.DEBUG)
|
||||
Log.d(TAG, path + " is available as a download destination");
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,6 @@ package de.danoeh.antennapod.syndication.handler;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Stack;
|
||||
|
||||
import de.danoeh.antennapod.feed.Feed;
|
||||
|
@ -1,7 +1,6 @@
|
||||
package de.danoeh.antennapod.util;
|
||||
|
||||
import android.util.Log;
|
||||
import de.danoeh.antennapod.PodcastApp;
|
||||
import de.danoeh.antennapod.R;
|
||||
import de.danoeh.antennapod.preferences.UserPreferences;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user