Merge branch 'develop' into exo-player
This commit is contained in:
commit
3d1646c205
34
app/sampledata/episodes.json
Normal file
34
app/sampledata/episodes.json
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
{
|
||||||
|
"data": [
|
||||||
|
{
|
||||||
|
"title": "FLOSS Weekly 482: PyPI",
|
||||||
|
"status_label": "NEW",
|
||||||
|
"duration": "00:52:40",
|
||||||
|
"published_at": "2. May"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "FLOSS Weekly 479: Pidgin",
|
||||||
|
"status_label": " ",
|
||||||
|
"duration": "01:08:08",
|
||||||
|
"published_at": "11. Apr"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Linux Outlaws 370 - Stay Free, Stay Open Source",
|
||||||
|
"status_label": "NEW",
|
||||||
|
"duration": "02:52:51",
|
||||||
|
"published_at": "29. Dec 2014"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Linux Outlaws 368 - The Dark Ages of Free Software",
|
||||||
|
"status_label": " ",
|
||||||
|
"duration": "02:26:54",
|
||||||
|
"published_at": "14. Dec 2014"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"title": "Linux Outlaws 365 - Last Stand",
|
||||||
|
"status_label": " ",
|
||||||
|
"duration": "00:39:59",
|
||||||
|
"published_at": "3. Nov 2014"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
2
app/sampledata/inplaylist
Normal file
2
app/sampledata/inplaylist
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
@null
|
||||||
|
@drawable/ic_list_grey600_24dp
|
3
app/sampledata/secondaryaction
Normal file
3
app/sampledata/secondaryaction
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
@drawable/ic_play_arrow_grey600_36dp
|
||||||
|
@drawable/ic_file_download_grey600_24dp
|
||||||
|
@drawable/ic_cancel_grey600_24dp
|
@ -31,6 +31,7 @@ import android.widget.ListView;
|
|||||||
import com.bumptech.glide.Glide;
|
import com.bumptech.glide.Glide;
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.event.ServiceEvent;
|
import de.danoeh.antennapod.core.event.ServiceEvent;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
@ -627,8 +628,7 @@ public class MainActivity extends CastEnabledActivity implements NavDrawerActivi
|
|||||||
remover.skipOnCompletion = true;
|
remover.skipOnCompletion = true;
|
||||||
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
||||||
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
||||||
sendBroadcast(new Intent(
|
IntentUtils.sendLocalBroadcast(MainActivity.this, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remover.executeAsync();
|
remover.executeAsync();
|
||||||
|
@ -45,6 +45,7 @@ import de.danoeh.antennapod.core.storage.DBWriter;
|
|||||||
import de.danoeh.antennapod.core.util.Converter;
|
import de.danoeh.antennapod.core.util.Converter;
|
||||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||||
import de.danoeh.antennapod.core.util.Flavors;
|
import de.danoeh.antennapod.core.util.Flavors;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.ShareUtils;
|
import de.danoeh.antennapod.core.util.ShareUtils;
|
||||||
import de.danoeh.antennapod.core.util.StorageUtils;
|
import de.danoeh.antennapod.core.util.StorageUtils;
|
||||||
import de.danoeh.antennapod.core.util.Supplier;
|
import de.danoeh.antennapod.core.util.Supplier;
|
||||||
@ -690,7 +691,6 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||||||
if(controller == null || controller.getMedia() == null) {
|
if(controller == null || controller.getMedia() == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Playable media = controller.getMedia();
|
|
||||||
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
|
SharedPreferences prefs = getSharedPreferences(PREFS, MODE_PRIVATE);
|
||||||
showTimeLeft = prefs.getBoolean(PREF_SHOW_TIME_LEFT, false);
|
showTimeLeft = prefs.getBoolean(PREF_SHOW_TIME_LEFT, false);
|
||||||
onPositionObserverUpdate();
|
onPositionObserverUpdate();
|
||||||
@ -863,7 +863,8 @@ public abstract class MediaplayerActivity extends CastEnabledActivity implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (butSkip != null) {
|
if (butSkip != null) {
|
||||||
butSkip.setOnClickListener(v -> sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE)));
|
butSkip.setOnClickListener(v ->
|
||||||
|
IntentUtils.sendLocalBroadcast(MediaplayerActivity.this, PlaybackService.ACTION_SKIP_CURRENT_EPISODE));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,7 @@ import de.danoeh.antennapod.core.service.playback.PlayerStatus;
|
|||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.playback.Playable;
|
import de.danoeh.antennapod.core.util.playback.Playable;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
import de.danoeh.antennapod.core.util.playback.PlaybackController;
|
||||||
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
||||||
@ -413,8 +414,7 @@ public abstract class MediaplayerInfoActivity extends MediaplayerActivity implem
|
|||||||
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
|
Log.d(TAG, "Currently playing episode is about to be deleted, skipping");
|
||||||
remover.skipOnCompletion = true;
|
remover.skipOnCompletion = true;
|
||||||
if(controller.getStatus() == PlayerStatus.PLAYING) {
|
if(controller.getStatus() == PlayerStatus.PLAYING) {
|
||||||
sendBroadcast(new Intent(
|
IntentUtils.sendLocalBroadcast(MediaplayerInfoActivity.this, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,7 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import com.afollestad.materialdialogs.MaterialDialog;
|
import com.afollestad.materialdialogs.MaterialDialog;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
import de.danoeh.antennapod.core.util.playback.PlaybackServiceStarter;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
@ -86,13 +87,13 @@ public class DefaultActionButtonCallback implements ActionButtonCallback {
|
|||||||
.startWhenPrepared(true)
|
.startWhenPrepared(true)
|
||||||
.shouldStream(false)
|
.shouldStream(false)
|
||||||
.start();
|
.start();
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||||
} else if (media.isCurrentlyPaused()) {
|
} else if (media.isCurrentlyPaused()) {
|
||||||
new PlaybackServiceStarter(context, media)
|
new PlaybackServiceStarter(context, media)
|
||||||
.startWhenPrepared(true)
|
.startWhenPrepared(true)
|
||||||
.shouldStream(false)
|
.shouldStream(false)
|
||||||
.start();
|
.start();
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE));
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_RESUME_PLAY_CURRENT_EPISODE);
|
||||||
} else {
|
} else {
|
||||||
DBTasks.playMedia(context, media, false, true, false);
|
DBTasks.playMedia(context, media, false, true, false);
|
||||||
}
|
}
|
||||||
|
@ -121,15 +121,6 @@ public class DownloadlistAdapter extends BaseAdapter {
|
|||||||
ImageButton butSecondary;
|
ImageButton butSecondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSelectedItemIndex() {
|
|
||||||
return selectedItemIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSelectedItemIndex(int selectedItemIndex) {
|
|
||||||
this.selectedItemIndex = selectedItemIndex;
|
|
||||||
notifyDataSetChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
public interface ItemAccess {
|
public interface ItemAccess {
|
||||||
int getCount();
|
int getCount();
|
||||||
|
|
||||||
|
@ -16,6 +16,7 @@ import android.widget.GridView;
|
|||||||
|
|
||||||
import de.danoeh.antennapod.R;
|
import de.danoeh.antennapod.R;
|
||||||
import de.danoeh.antennapod.activity.MainActivity;
|
import de.danoeh.antennapod.activity.MainActivity;
|
||||||
|
import de.danoeh.antennapod.activity.MediaplayerInfoActivity;
|
||||||
import de.danoeh.antennapod.adapter.SubscriptionsAdapter;
|
import de.danoeh.antennapod.adapter.SubscriptionsAdapter;
|
||||||
import de.danoeh.antennapod.core.asynctask.FeedRemover;
|
import de.danoeh.antennapod.core.asynctask.FeedRemover;
|
||||||
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
import de.danoeh.antennapod.core.dialog.ConfirmationDialog;
|
||||||
@ -26,6 +27,7 @@ import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
|||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
import de.danoeh.antennapod.core.util.FeedItemUtil;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
import de.danoeh.antennapod.dialog.RenameFeedDialog;
|
||||||
import rx.Observable;
|
import rx.Observable;
|
||||||
import rx.Subscription;
|
import rx.Subscription;
|
||||||
@ -211,8 +213,8 @@ public class SubscriptionFragment extends Fragment {
|
|||||||
remover.skipOnCompletion = true;
|
remover.skipOnCompletion = true;
|
||||||
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
int playerStatus = PlaybackPreferences.getCurrentPlayerStatus();
|
||||||
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
if(playerStatus == PlaybackPreferences.PLAYER_STATUS_PLAYING) {
|
||||||
getActivity().sendBroadcast(new Intent(
|
IntentUtils.sendLocalBroadcast(getContext(), PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE);
|
||||||
PlaybackService.ACTION_PAUSE_PLAY_CURRENT_EPISODE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
remover.executeAsync();
|
remover.executeAsync();
|
||||||
|
@ -158,7 +158,7 @@ public class FeedItemMenuHandler {
|
|||||||
FeedItem selectedItem) {
|
FeedItem selectedItem) {
|
||||||
switch (menuItemId) {
|
switch (menuItemId) {
|
||||||
case R.id.skip_episode_item:
|
case R.id.skip_episode_item:
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE));
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||||
break;
|
break;
|
||||||
case R.id.remove_item:
|
case R.id.remove_item:
|
||||||
DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId());
|
DBWriter.deleteFeedMediaOfItem(context, selectedItem.getMedia().getId());
|
||||||
|
@ -13,7 +13,9 @@
|
|||||||
android:scrollbarStyle="outsideOverlay"
|
android:scrollbarStyle="outsideOverlay"
|
||||||
android:paddingTop="@dimen/list_vertical_padding"
|
android:paddingTop="@dimen/list_vertical_padding"
|
||||||
android:paddingBottom="@dimen/list_vertical_padding"
|
android:paddingBottom="@dimen/list_vertical_padding"
|
||||||
android:clipToPadding="false"/>
|
android:clipToPadding="false"
|
||||||
|
tools:listitem="@layout/new_episodes_listitem"
|
||||||
|
tools:itemCount="13"/>
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/progLoading"
|
android:id="@+id/progLoading"
|
||||||
@ -22,7 +24,7 @@
|
|||||||
android:layout_gravity="center"
|
android:layout_gravity="center"
|
||||||
android:indeterminateOnly="true"
|
android:indeterminateOnly="true"
|
||||||
android:visibility="gone"
|
android:visibility="gone"
|
||||||
tools:visibility="visible"
|
tools:visibility="gone"
|
||||||
tools:layout_width="match_parent"
|
tools:layout_width="match_parent"
|
||||||
tools:layout_height="64dp"
|
tools:layout_height="64dp"
|
||||||
tools:background="@android:color/holo_red_light"/>
|
tools:background="@android:color/holo_red_light"/>
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:background="?attr/selectableItemBackground"
|
android:background="?attr/selectableItemBackground"
|
||||||
android:orientation="horizontal"
|
android:orientation="horizontal"
|
||||||
tools:background="@android:color/darker_gray"
|
|
||||||
android:gravity="center_vertical">
|
android:gravity="center_vertical">
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
@ -42,8 +41,7 @@
|
|||||||
android:layout_alignRight="@id/txtvPlaceholder"
|
android:layout_alignRight="@id/txtvPlaceholder"
|
||||||
android:layout_alignBottom="@id/txtvPlaceholder"
|
android:layout_alignBottom="@id/txtvPlaceholder"
|
||||||
android:contentDescription="@string/cover_label"
|
android:contentDescription="@string/cover_label"
|
||||||
tools:src="@drawable/ic_stat_antenna_default"
|
tools:src="@tools:sample/avatars" />
|
||||||
tools:background="@android:color/holo_green_dark" />
|
|
||||||
|
|
||||||
</RelativeLayout>
|
</RelativeLayout>
|
||||||
|
|
||||||
@ -54,8 +52,7 @@
|
|||||||
android:layout_marginLeft="@dimen/listitem_threeline_textleftpadding"
|
android:layout_marginLeft="@dimen/listitem_threeline_textleftpadding"
|
||||||
android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
|
android:layout_marginRight="@dimen/listitem_threeline_textrightpadding"
|
||||||
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
|
android:layout_marginTop="@dimen/listitem_threeline_verticalpadding"
|
||||||
android:layout_weight="1"
|
android:layout_weight="1">
|
||||||
tools:background="@android:color/white" >
|
|
||||||
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
@ -65,7 +62,8 @@
|
|||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_marginLeft="8dp"/>
|
android:layout_marginLeft="8dp"
|
||||||
|
tools:text="@sample/episodes.json/data/status_label"/>
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvTitle"
|
android:id="@+id/txtvTitle"
|
||||||
@ -75,8 +73,7 @@
|
|||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_toLeftOf="@id/statusUnread"
|
android:layout_toLeftOf="@id/statusUnread"
|
||||||
tools:text="Episode title"
|
tools:text="@sample/episodes.json/data/title" />
|
||||||
tools:background="@android:color/holo_green_dark" />
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:id="@+id/bottom_bar"
|
android:id="@+id/bottom_bar"
|
||||||
@ -85,8 +82,7 @@
|
|||||||
android:layout_below="@id/txtvTitle"
|
android:layout_below="@id/txtvTitle"
|
||||||
android:layout_alignParentBottom="true"
|
android:layout_alignParentBottom="true"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true">
|
||||||
tools:background="@android:color/holo_red_light" >
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvDuration"
|
android:id="@+id/txtvDuration"
|
||||||
@ -94,8 +90,7 @@
|
|||||||
android:layout_width="wrap_content"
|
android:layout_width="wrap_content"
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_alignParentLeft="true"
|
android:layout_alignParentLeft="true"
|
||||||
tools:text="00:42:23"
|
tools:text="@sample/episodes.json/data/duration" />
|
||||||
tools:background="@android:color/holo_blue_dark" />
|
|
||||||
|
|
||||||
<ImageView
|
<ImageView
|
||||||
android:id="@+id/imgvInPlaylist"
|
android:id="@+id/imgvInPlaylist"
|
||||||
@ -105,8 +100,7 @@
|
|||||||
android:layout_marginLeft="8dp"
|
android:layout_marginLeft="8dp"
|
||||||
android:contentDescription="@string/in_queue_label"
|
android:contentDescription="@string/in_queue_label"
|
||||||
android:src="?attr/stat_playlist"
|
android:src="?attr/stat_playlist"
|
||||||
tools:src="@drawable/ic_list_grey600_24dp"
|
tools:src="@sample/inplaylist" />
|
||||||
tools:background="@android:color/black" />
|
|
||||||
|
|
||||||
<TextView
|
<TextView
|
||||||
android:id="@+id/txtvPublished"
|
android:id="@+id/txtvPublished"
|
||||||
@ -116,8 +110,7 @@
|
|||||||
android:layout_alignParentTop="true"
|
android:layout_alignParentTop="true"
|
||||||
android:layout_toLeftOf="@id/imgvInPlaylist"
|
android:layout_toLeftOf="@id/imgvInPlaylist"
|
||||||
android:ellipsize="end"
|
android:ellipsize="end"
|
||||||
tools:text="Jan 23"
|
tools:text="@sample/episodes.json/data/published_at" />
|
||||||
tools:background="@android:color/holo_green_dark" />
|
|
||||||
|
|
||||||
<ProgressBar
|
<ProgressBar
|
||||||
android:id="@+id/pbar_progress"
|
android:id="@+id/pbar_progress"
|
||||||
|
@ -9,5 +9,4 @@
|
|||||||
android:focusable="false"
|
android:focusable="false"
|
||||||
android:focusableInTouchMode="false"
|
android:focusableInTouchMode="false"
|
||||||
tools:ignore="ContentDescription"
|
tools:ignore="ContentDescription"
|
||||||
tools:src="@drawable/ic_play_arrow_grey600_36dp"
|
tools:src="@sample/secondaryaction" />
|
||||||
tools:background="@android:color/holo_green_dark" />
|
|
||||||
|
@ -16,8 +16,8 @@ buildscript {
|
|||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
|
||||||
google()
|
google()
|
||||||
|
jcenter()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,29 +0,0 @@
|
|||||||
package de.danoeh.antennapod.core.asynctask;
|
|
||||||
|
|
||||||
import android.content.Context;
|
|
||||||
import android.support.v4.content.AsyncTaskLoader;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subclass of AsyncTaskLoader that is made for loading data with one of the DB*-classes.
|
|
||||||
* This class will provide a useful default implementation that would otherwise always be necessary when interacting
|
|
||||||
* with the DB*-classes with an AsyncTaskLoader.
|
|
||||||
*/
|
|
||||||
abstract class DBTaskLoader<D> extends AsyncTaskLoader<D> {
|
|
||||||
|
|
||||||
public DBTaskLoader(Context context) {
|
|
||||||
super(context);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStopLoading() {
|
|
||||||
super.onStopLoading();
|
|
||||||
cancelLoad();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStartLoading() {
|
|
||||||
super.onStartLoading();
|
|
||||||
// according to https://code.google.com/p/android/issues/detail?id=14944, this has to be called manually
|
|
||||||
forceLoad();
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,8 +9,10 @@ import java.util.concurrent.ExecutionException;
|
|||||||
|
|
||||||
import de.danoeh.antennapod.core.R;
|
import de.danoeh.antennapod.core.R;
|
||||||
import de.danoeh.antennapod.core.feed.Feed;
|
import de.danoeh.antennapod.core.feed.Feed;
|
||||||
|
import de.danoeh.antennapod.core.service.download.DownloadService;
|
||||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
|
|
||||||
/** Removes a feed in the background. */
|
/** Removes a feed in the background. */
|
||||||
public class FeedRemover extends AsyncTask<Void, Void, Void> {
|
public class FeedRemover extends AsyncTask<Void, Void, Void> {
|
||||||
@ -41,7 +43,7 @@ public class FeedRemover extends AsyncTask<Void, Void, Void> {
|
|||||||
dialog.dismiss();
|
dialog.dismiss();
|
||||||
}
|
}
|
||||||
if(skipOnCompletion) {
|
if(skipOnCompletion) {
|
||||||
context.sendBroadcast(new Intent(PlaybackService.ACTION_SKIP_CURRENT_EPISODE));
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SKIP_CURRENT_EPISODE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ import de.danoeh.antennapod.core.gpoddernet.model.GpodnetEpisodeAction;
|
|||||||
import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
|
import de.danoeh.antennapod.core.preferences.GpodnetPreferences;
|
||||||
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
import de.danoeh.antennapod.core.preferences.PlaybackPreferences;
|
||||||
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
import de.danoeh.antennapod.core.preferences.UserPreferences;
|
||||||
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
import de.danoeh.antennapod.core.storage.DBReader;
|
import de.danoeh.antennapod.core.storage.DBReader;
|
||||||
import de.danoeh.antennapod.core.storage.DBTasks;
|
import de.danoeh.antennapod.core.storage.DBTasks;
|
||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
@ -218,7 +219,7 @@ public class FeedMedia extends FeedFile implements Playable {
|
|||||||
* currently being played and the current player status is playing.
|
* currently being played and the current player status is playing.
|
||||||
*/
|
*/
|
||||||
public boolean isCurrentlyPlaying() {
|
public boolean isCurrentlyPlaying() {
|
||||||
return isPlaying() &&
|
return isPlaying() && PlaybackService.isRunning &&
|
||||||
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING));
|
((PlaybackPreferences.getCurrentPlayerStatus() == PlaybackPreferences.PLAYER_STATUS_PLAYING));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -109,7 +109,6 @@ public class UserPreferences {
|
|||||||
|
|
||||||
// Experimental
|
// Experimental
|
||||||
private static final String PREF_STEREO_TO_MONO = "PrefStereoToMono";
|
private static final String PREF_STEREO_TO_MONO = "PrefStereoToMono";
|
||||||
public static final String PREF_NORMALIZER = "prefNormalizer";
|
|
||||||
public static final String PREF_CAST_ENABLED = "prefCast"; //Used for enabling Chromecast support
|
public static final String PREF_CAST_ENABLED = "prefCast"; //Used for enabling Chromecast support
|
||||||
public static final int EPISODE_CLEANUP_QUEUE = -1;
|
public static final int EPISODE_CLEANUP_QUEUE = -1;
|
||||||
public static final int EPISODE_CLEANUP_NULL = -2;
|
public static final int EPISODE_CLEANUP_NULL = -2;
|
||||||
@ -122,7 +121,6 @@ public class UserPreferences {
|
|||||||
private static final int EPISODE_CACHE_SIZE_UNLIMITED = -1;
|
private static final int EPISODE_CACHE_SIZE_UNLIMITED = -1;
|
||||||
public static final int FEED_ORDER_COUNTER = 0;
|
public static final int FEED_ORDER_COUNTER = 0;
|
||||||
public static final int FEED_ORDER_ALPHABETICAL = 1;
|
public static final int FEED_ORDER_ALPHABETICAL = 1;
|
||||||
public static final int FEED_ORDER_LAST_UPDATE = 2;
|
|
||||||
public static final int FEED_ORDER_MOST_PLAYED = 3;
|
public static final int FEED_ORDER_MOST_PLAYED = 3;
|
||||||
public static final int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
|
public static final int FEED_COUNTER_SHOW_NEW_UNPLAYED_SUM = 0;
|
||||||
public static final int FEED_COUNTER_SHOW_NEW = 1;
|
public static final int FEED_COUNTER_SHOW_NEW = 1;
|
||||||
|
@ -211,10 +211,6 @@ public class DownloadRequest implements Parcelable {
|
|||||||
this.size = size;
|
this.size = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getStatusMsg() {
|
|
||||||
return statusMsg;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setStatusMsg(int statusMsg) {
|
public void setStatusMsg(int statusMsg) {
|
||||||
this.statusMsg = statusMsg;
|
this.statusMsg = statusMsg;
|
||||||
}
|
}
|
||||||
|
@ -1,10 +0,0 @@
|
|||||||
package de.danoeh.antennapod.core.service.download;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Callback used by the Downloader-classes to notify the requester that the
|
|
||||||
* download has completed.
|
|
||||||
*/
|
|
||||||
public interface DownloaderCallback {
|
|
||||||
|
|
||||||
void onDownloadCompleted(Downloader downloader);
|
|
||||||
}
|
|
@ -614,13 +614,26 @@ public class LocalPSMP extends PlaybackServiceMediaPlayer {
|
|||||||
executor.shutdown();
|
executor.shutdown();
|
||||||
if (mediaPlayer != null) {
|
if (mediaPlayer != null) {
|
||||||
try {
|
try {
|
||||||
|
removeMediaPlayerErrorListener();
|
||||||
|
if (mediaPlayer.isPlaying()) {
|
||||||
mediaPlayer.stop();
|
mediaPlayer.stop();
|
||||||
|
}
|
||||||
} catch (Exception ignore) { }
|
} catch (Exception ignore) { }
|
||||||
mediaPlayer.release();
|
mediaPlayer.release();
|
||||||
}
|
}
|
||||||
releaseWifiLockIfNecessary();
|
releaseWifiLockIfNecessary();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void removeMediaPlayerErrorListener() {
|
||||||
|
if (mediaPlayer instanceof VideoPlayer) {
|
||||||
|
VideoPlayer vp = (VideoPlayer) mediaPlayer;
|
||||||
|
vp.setOnErrorListener((mp, what, extra) -> true);
|
||||||
|
} else if (mediaPlayer instanceof AudioPlayer) {
|
||||||
|
AudioPlayer ap = (AudioPlayer) mediaPlayer;
|
||||||
|
ap.setOnErrorListener((mediaPlayer, i, i1) -> true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Releases internally used resources. This method should only be called when the object is not used anymore.
|
* Releases internally used resources. This method should only be called when the object is not used anymore.
|
||||||
* This method is executed on an internal executor service.
|
* This method is executed on an internal executor service.
|
||||||
|
@ -65,6 +65,7 @@ import de.danoeh.antennapod.core.storage.DBTasks;
|
|||||||
import de.danoeh.antennapod.core.storage.DBWriter;
|
import de.danoeh.antennapod.core.storage.DBWriter;
|
||||||
import de.danoeh.antennapod.core.storage.FeedSearcher;
|
import de.danoeh.antennapod.core.storage.FeedSearcher;
|
||||||
import de.danoeh.antennapod.core.util.IntList;
|
import de.danoeh.antennapod.core.util.IntList;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
import de.danoeh.antennapod.core.util.gui.NotificationUtils;
|
||||||
import de.danoeh.antennapod.core.util.QueueAccess;
|
import de.danoeh.antennapod.core.util.QueueAccess;
|
||||||
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
import de.danoeh.antennapod.core.util.playback.ExternalMedia;
|
||||||
@ -316,9 +317,6 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
NotificationCompat.Builder notificationBuilder = createBasicNotification();
|
NotificationCompat.Builder notificationBuilder = createBasicNotification();
|
||||||
startForeground(NOTIFICATION_ID, notificationBuilder.build());
|
startForeground(NOTIFICATION_ID, notificationBuilder.build());
|
||||||
EventBus.getDefault().post(new ServiceEvent(ServiceEvent.Action.SERVICE_STARTED));
|
EventBus.getDefault().post(new ServiceEvent(ServiceEvent.Action.SERVICE_STARTED));
|
||||||
|
|
||||||
|
|
||||||
setupNotification(Playable.PlayableUtils.createInstanceFromPreferences(getApplicationContext()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private NotificationCompat.Builder createBasicNotification() {
|
private NotificationCompat.Builder createBasicNotification() {
|
||||||
@ -468,10 +466,13 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
Log.d(TAG, "onStartCommand is a redelivered intent, calling stopForeground now.");
|
Log.d(TAG, "onStartCommand is a redelivered intent, calling stopForeground now.");
|
||||||
stopForeground(true);
|
stopForeground(true);
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
if (keycode != -1) {
|
if (keycode != -1) {
|
||||||
Log.d(TAG, "Received media button event");
|
Log.d(TAG, "Received media button event");
|
||||||
handleKeycode(keycode, true);
|
boolean handled = handleKeycode(keycode, true);
|
||||||
|
if (!handled) {
|
||||||
|
stopSelf();
|
||||||
|
return Service.START_NOT_STICKY;
|
||||||
|
}
|
||||||
} else if (!flavorHelper.castDisconnect(castDisconnect) && playable != null) {
|
} else if (!flavorHelper.castDisconnect(castDisconnect) && playable != null) {
|
||||||
started = true;
|
started = true;
|
||||||
boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM,
|
boolean stream = intent.getBooleanExtra(EXTRA_SHOULD_STREAM,
|
||||||
@ -486,6 +487,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
}
|
}
|
||||||
mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately);
|
mediaPlayer.playMediaObject(playable, stream, startWhenPrepared, prepareImmediately);
|
||||||
}
|
}
|
||||||
|
setupNotification(playable);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Service.START_NOT_STICKY;
|
return Service.START_NOT_STICKY;
|
||||||
@ -677,7 +679,7 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case STOPPED:
|
case STOPPED:
|
||||||
//setCurrentlyPlayingMedia(PlaybackPreferences.NO_MEDIA_PLAYING);
|
//writePlaybackPreferencesNoMediaPlaying();
|
||||||
//stopSelf();
|
//stopSelf();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@ -695,13 +697,12 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
|
|
||||||
case ERROR:
|
case ERROR:
|
||||||
writePlaybackPreferencesNoMediaPlaying();
|
writePlaybackPreferencesNoMediaPlaying();
|
||||||
|
stopSelf();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Intent statusUpdate = new Intent(ACTION_PLAYER_STATUS_CHANGED);
|
IntentUtils.sendLocalBroadcast(getApplicationContext(), ACTION_PLAYER_STATUS_CHANGED);
|
||||||
// statusUpdate.putExtra(EXTRA_NEW_PLAYER_STATUS, newInfo.playerStatus.ordinal());
|
|
||||||
sendBroadcast(statusUpdate);
|
|
||||||
PlayerWidgetJobService.updateWidget(getBaseContext());
|
PlayerWidgetJobService.updateWidget(getBaseContext());
|
||||||
bluetoothNotifyChange(newInfo, AVRCP_ACTION_PLAYER_STATUS_CHANGED);
|
bluetoothNotifyChange(newInfo, AVRCP_ACTION_PLAYER_STATUS_CHANGED);
|
||||||
bluetoothNotifyChange(newInfo, AVRCP_ACTION_META_CHANGED);
|
bluetoothNotifyChange(newInfo, AVRCP_ACTION_META_CHANGED);
|
||||||
@ -1042,17 +1043,11 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Send ACTION_PLAYER_STATUS_CHANGED without changing the status attribute.
|
|
||||||
*/
|
|
||||||
private void postStatusUpdateIntent() {
|
|
||||||
sendBroadcast(new Intent(ACTION_PLAYER_STATUS_CHANGED));
|
|
||||||
}
|
|
||||||
|
|
||||||
private void sendNotificationBroadcast(int type, int code) {
|
private void sendNotificationBroadcast(int type, int code) {
|
||||||
Intent intent = new Intent(ACTION_PLAYER_NOTIFICATION);
|
Intent intent = new Intent(ACTION_PLAYER_NOTIFICATION);
|
||||||
intent.putExtra(EXTRA_NOTIFICATION_TYPE, type);
|
intent.putExtra(EXTRA_NOTIFICATION_TYPE, type);
|
||||||
intent.putExtra(EXTRA_NOTIFICATION_CODE, code);
|
intent.putExtra(EXTRA_NOTIFICATION_CODE, code);
|
||||||
|
intent.setPackage(getPackageName());
|
||||||
sendBroadcast(intent);
|
sendBroadcast(intent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1215,13 +1210,28 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
if (notificationSetupThread != null) {
|
if (notificationSetupThread != null) {
|
||||||
notificationSetupThread.interrupt();
|
notificationSetupThread.interrupt();
|
||||||
}
|
}
|
||||||
|
if (playable == null) {
|
||||||
|
Log.d(TAG, "setupNotification: playable is null");
|
||||||
|
if (!started) {
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
Runnable notificationSetupTask = new Runnable() {
|
Runnable notificationSetupTask = new Runnable() {
|
||||||
Bitmap icon = null;
|
Bitmap icon = null;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
Log.d(TAG, "Starting background work");
|
Log.d(TAG, "Starting background work");
|
||||||
if (playable != null) {
|
|
||||||
|
if (mediaPlayer == null) {
|
||||||
|
Log.d(TAG, "notificationSetupTask: mediaPlayer is null");
|
||||||
|
if (!started) {
|
||||||
|
stopSelf();
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
int iconSize = getResources().getDimensionPixelSize(
|
int iconSize = getResources().getDimensionPixelSize(
|
||||||
android.R.dimen.notification_large_icon_width);
|
android.R.dimen.notification_large_icon_width);
|
||||||
try {
|
try {
|
||||||
@ -1235,18 +1245,15 @@ public class PlaybackService extends MediaBrowserServiceCompat {
|
|||||||
} catch (Throwable tr) {
|
} catch (Throwable tr) {
|
||||||
Log.e(TAG, "Error loading the media icon for the notification", tr);
|
Log.e(TAG, "Error loading the media icon for the notification", tr);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (icon == null) {
|
if (icon == null) {
|
||||||
icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
|
icon = BitmapFactory.decodeResource(getApplicationContext().getResources(),
|
||||||
ClientConfig.playbackServiceCallbacks.getNotificationIconResource(getApplicationContext()));
|
ClientConfig.playbackServiceCallbacks.getNotificationIconResource(getApplicationContext()));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mediaPlayer == null) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
PlayerStatus playerStatus = mediaPlayer.getPlayerStatus();
|
PlayerStatus playerStatus = mediaPlayer.getPlayerStatus();
|
||||||
|
|
||||||
if (!Thread.currentThread().isInterrupted() && started && playable != null) {
|
if (!Thread.currentThread().isInterrupted() && started) {
|
||||||
String contentText = playable.getEpisodeTitle();
|
String contentText = playable.getEpisodeTitle();
|
||||||
String contentTitle = playable.getFeedTitle();
|
String contentTitle = playable.getFeedTitle();
|
||||||
Notification notification;
|
Notification notification;
|
||||||
|
@ -36,6 +36,7 @@ import de.danoeh.antennapod.core.service.download.DownloadStatus;
|
|||||||
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
import de.danoeh.antennapod.core.util.Converter;
|
import de.danoeh.antennapod.core.util.Converter;
|
||||||
import de.danoeh.antennapod.core.util.DownloadError;
|
import de.danoeh.antennapod.core.util.DownloadError;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import de.danoeh.antennapod.core.util.LongList;
|
import de.danoeh.antennapod.core.util.LongList;
|
||||||
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
|
import de.danoeh.antennapod.core.util.comparator.FeedItemPubdateComparator;
|
||||||
import de.danoeh.antennapod.core.util.exception.MediaFileNotFoundException;
|
import de.danoeh.antennapod.core.util.exception.MediaFileNotFoundException;
|
||||||
@ -142,8 +143,7 @@ public final class DBTasks {
|
|||||||
} catch (MediaFileNotFoundException e) {
|
} catch (MediaFileNotFoundException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
if (media.isPlaying()) {
|
if (media.isPlaying()) {
|
||||||
context.sendBroadcast(new Intent(
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
|
||||||
}
|
}
|
||||||
notifyMissingFeedMediaFile(context, media);
|
notifyMissingFeedMediaFile(context, media);
|
||||||
}
|
}
|
||||||
@ -236,27 +236,6 @@ public final class DBTasks {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Downloads all pages of the given feed.
|
|
||||||
*
|
|
||||||
* @param context Used for requesting the download.
|
|
||||||
* @param feed The Feed object.
|
|
||||||
*/
|
|
||||||
public static void refreshCompleteFeed(final Context context, final Feed feed) {
|
|
||||||
try {
|
|
||||||
refreshFeed(context, feed, true, false);
|
|
||||||
} catch (DownloadRequestException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
DBWriter.addDownloadStatus(
|
|
||||||
new DownloadStatus(feed, feed
|
|
||||||
.getHumanReadableIdentifier(),
|
|
||||||
DownloadError.ERROR_REQUEST_ERROR, false, e
|
|
||||||
.getMessage()
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Downloads all pages of the given feed even if feed has not been modified since last refresh
|
* Downloads all pages of the given feed even if feed has not been modified since last refresh
|
||||||
*
|
*
|
||||||
@ -377,27 +356,6 @@ public final class DBTasks {
|
|||||||
EventDistributor.getInstance().sendFeedUpdateBroadcast();
|
EventDistributor.getInstance().sendFeedUpdateBroadcast();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Request the download of all objects in the queue. from a separate Thread.
|
|
||||||
*
|
|
||||||
* @param context Used for requesting the download an accessing the database.
|
|
||||||
*/
|
|
||||||
public static void downloadAllItemsInQueue(final Context context) {
|
|
||||||
new Thread() {
|
|
||||||
public void run() {
|
|
||||||
List<FeedItem> queue = DBReader.getQueue();
|
|
||||||
if (!queue.isEmpty()) {
|
|
||||||
try {
|
|
||||||
downloadFeedItems(context,
|
|
||||||
queue.toArray(new FeedItem[queue.size()]));
|
|
||||||
} catch (DownloadRequestException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.start();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Requests the download of a list of FeedItem objects.
|
* Requests the download of a list of FeedItem objects.
|
||||||
*
|
*
|
||||||
|
@ -7,6 +7,7 @@ import android.content.SharedPreferences;
|
|||||||
import android.preference.PreferenceManager;
|
import android.preference.PreferenceManager;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import org.shredzone.flattr4j.model.Flattr;
|
import org.shredzone.flattr4j.model.Flattr;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -115,11 +116,8 @@ public class DBWriter {
|
|||||||
true);
|
true);
|
||||||
editor.commit();
|
editor.commit();
|
||||||
}
|
}
|
||||||
if (PlaybackPreferences
|
if (PlaybackPreferences.getCurrentlyPlayingFeedMediaId() == media.getId()) {
|
||||||
.getCurrentlyPlayingFeedMediaId() == media
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||||
.getId()) {
|
|
||||||
context.sendBroadcast(new Intent(
|
|
||||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Gpodder: queue delete action for synchronization
|
// Gpodder: queue delete action for synchronization
|
||||||
@ -156,8 +154,7 @@ public class DBWriter {
|
|||||||
if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA
|
if (PlaybackPreferences.getCurrentlyPlayingMedia() == FeedMedia.PLAYABLE_TYPE_FEEDMEDIA
|
||||||
&& PlaybackPreferences.getLastPlayedFeedId() == feed
|
&& PlaybackPreferences.getLastPlayedFeedId() == feed
|
||||||
.getId()) {
|
.getId()) {
|
||||||
context.sendBroadcast(new Intent(
|
IntentUtils.sendLocalBroadcast(context, PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE);
|
||||||
PlaybackService.ACTION_SHUTDOWN_PLAYBACK_SERVICE));
|
|
||||||
SharedPreferences.Editor editor = prefs.edit();
|
SharedPreferences.Editor editor = prefs.edit();
|
||||||
editor.putLong(
|
editor.putLong(
|
||||||
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID,
|
PlaybackPreferences.PREF_CURRENTLY_PLAYING_FEED_ID,
|
||||||
@ -460,22 +457,6 @@ public class DBWriter {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Future<?> addFavoriteItemById(final long itemId) {
|
|
||||||
return dbExec.submit(() -> {
|
|
||||||
final FeedItem item = DBReader.getFeedItem(itemId);
|
|
||||||
if (item == null) {
|
|
||||||
Log.d(TAG, "Can't find item for itemId " + itemId);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final PodDBAdapter adapter = PodDBAdapter.getInstance().open();
|
|
||||||
adapter.addFavoriteItem(item);
|
|
||||||
adapter.close();
|
|
||||||
item.addTag(FeedItem.TAG_FAVORITE);
|
|
||||||
EventBus.getDefault().post(FavoritesEvent.added(item));
|
|
||||||
EventBus.getDefault().post(FeedItemEvent.updated(item));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Future<?> removeFavoriteItem(final FeedItem item) {
|
public static Future<?> removeFavoriteItem(final FeedItem item) {
|
||||||
return dbExec.submit(() -> {
|
return dbExec.submit(() -> {
|
||||||
final PodDBAdapter adapter = PodDBAdapter.getInstance().open();
|
final PodDBAdapter adapter = PodDBAdapter.getInstance().open();
|
||||||
|
@ -9,6 +9,8 @@ import android.text.TextUtils;
|
|||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
import android.webkit.URLUtil;
|
import android.webkit.URLUtil;
|
||||||
|
|
||||||
|
import de.danoeh.antennapod.core.service.playback.PlaybackService;
|
||||||
|
import de.danoeh.antennapod.core.util.IntentUtils;
|
||||||
import org.apache.commons.io.FilenameUtils;
|
import org.apache.commons.io.FilenameUtils;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -242,6 +244,7 @@ public class DownloadRequester {
|
|||||||
Log.d(TAG, "Cancelling download with url " + downloadUrl);
|
Log.d(TAG, "Cancelling download with url " + downloadUrl);
|
||||||
Intent cancelIntent = new Intent(DownloadService.ACTION_CANCEL_DOWNLOAD);
|
Intent cancelIntent = new Intent(DownloadService.ACTION_CANCEL_DOWNLOAD);
|
||||||
cancelIntent.putExtra(DownloadService.EXTRA_DOWNLOAD_URL, downloadUrl);
|
cancelIntent.putExtra(DownloadService.EXTRA_DOWNLOAD_URL, downloadUrl);
|
||||||
|
cancelIntent.setPackage(context.getPackageName());
|
||||||
context.sendBroadcast(cancelIntent);
|
context.sendBroadcast(cancelIntent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -250,8 +253,7 @@ public class DownloadRequester {
|
|||||||
*/
|
*/
|
||||||
public synchronized void cancelAllDownloads(Context context) {
|
public synchronized void cancelAllDownloads(Context context) {
|
||||||
Log.d(TAG, "Cancelling all running downloads");
|
Log.d(TAG, "Cancelling all running downloads");
|
||||||
context.sendBroadcast(new Intent(
|
IntentUtils.sendLocalBroadcast(context, DownloadService.ACTION_CANCEL_ALL_DOWNLOADS);
|
||||||
DownloadService.ACTION_CANCEL_ALL_DOWNLOADS));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -542,31 +542,6 @@ public class PodDBAdapter {
|
|||||||
new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)}, null, null, null);
|
new String[]{String.valueOf(FlattrStatus.STATUS_QUEUE)}, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Counts feeds and feed items in the flattr queue
|
|
||||||
*/
|
|
||||||
public int getFlattrQueueSize() {
|
|
||||||
int res = 0;
|
|
||||||
Cursor c = db.rawQuery(String.format("SELECT count(*) FROM %s WHERE %s=%s",
|
|
||||||
TABLE_NAME_FEEDS, KEY_FLATTR_STATUS, String.valueOf(FlattrStatus.STATUS_QUEUE)), null);
|
|
||||||
if (c.moveToFirst()) {
|
|
||||||
res = c.getInt(0);
|
|
||||||
c.close();
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Unable to determine size of flattr queue: Could not count number of feeds");
|
|
||||||
}
|
|
||||||
c = db.rawQuery(String.format("SELECT count(*) FROM %s WHERE %s=%s",
|
|
||||||
TABLE_NAME_FEED_ITEMS, KEY_FLATTR_STATUS, String.valueOf(FlattrStatus.STATUS_QUEUE)), null);
|
|
||||||
if (c.moveToFirst()) {
|
|
||||||
res += c.getInt(0);
|
|
||||||
c.close();
|
|
||||||
} else {
|
|
||||||
Log.e(TAG, "Unable to determine size of flattr queue: Could not count number of feed items");
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Updates the download URL of a Feed.
|
* Updates the download URL of a Feed.
|
||||||
*/
|
*/
|
||||||
@ -874,17 +849,6 @@ public class PodDBAdapter {
|
|||||||
return count > 0;
|
return count > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public long getDownloadLogSize() {
|
|
||||||
final String query = String.format("SELECT COUNT(%s) FROM %s", KEY_ID, TABLE_NAME_DOWNLOAD_LOG);
|
|
||||||
Cursor result = db.rawQuery(query, null);
|
|
||||||
long count = 0;
|
|
||||||
if (result.moveToFirst()) {
|
|
||||||
count = result.getLong(0);
|
|
||||||
}
|
|
||||||
result.close();
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setQueue(List<FeedItem> queue) {
|
public void setQueue(List<FeedItem> queue) {
|
||||||
ContentValues values = new ContentValues();
|
ContentValues values = new ContentValues();
|
||||||
try {
|
try {
|
||||||
@ -1012,18 +976,6 @@ public class PodDBAdapter {
|
|||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns a cursor for a DB query in the FeedMedia table for a given ID.
|
|
||||||
*
|
|
||||||
* @param item The item you want to get the FeedMedia from
|
|
||||||
* @return The cursor of the query
|
|
||||||
*/
|
|
||||||
public final Cursor getFeedMediaOfItemCursor(final FeedItem item) {
|
|
||||||
return db.query(TABLE_NAME_FEED_MEDIA, null, KEY_ID + "=?",
|
|
||||||
new String[]{String.valueOf(item.getMedia().getId())}, null,
|
|
||||||
null, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a cursor for a DB query in the FeedImages table for given IDs.
|
* Returns a cursor for a DB query in the FeedImages table for given IDs.
|
||||||
*
|
*
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
package de.danoeh.antennapod.core.util;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import de.danoeh.antennapod.core.feed.FeedItem;
|
|
||||||
|
|
||||||
class EpisodeFilter {
|
|
||||||
|
|
||||||
private EpisodeFilter() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/** Return a copy of the itemlist without items which have no media. */
|
|
||||||
public static ArrayList<FeedItem> getEpisodeList(List<FeedItem> items) {
|
|
||||||
ArrayList<FeedItem> episodes = new ArrayList<>(items);
|
|
||||||
for (FeedItem item : items) {
|
|
||||||
if (item.getMedia() == null) {
|
|
||||||
episodes.remove(item);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return episodes;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static int countItemsWithEpisodes(List<FeedItem> items) {
|
|
||||||
int count = 0;
|
|
||||||
for (FeedItem item : items) {
|
|
||||||
if (item.getMedia() != null) {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static FeedItem accessEpisodeByIndex(List<FeedItem> items,
|
|
||||||
int position) {
|
|
||||||
int count = 0;
|
|
||||||
for (FeedItem item : items) {
|
|
||||||
|
|
||||||
if (item.getMedia() != null) {
|
|
||||||
if (count == position) {
|
|
||||||
return item;
|
|
||||||
} else {
|
|
||||||
count++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -23,4 +23,8 @@ public class IntentUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void sendLocalBroadcast(Context context, String action) {
|
||||||
|
context.sendBroadcast(new Intent(action).setPackage(context.getPackageName()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -58,19 +58,4 @@ public abstract class QueueAccess {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static QueueAccess NotInQueueAccess() {
|
|
||||||
return new QueueAccess() {
|
|
||||||
@Override
|
|
||||||
public boolean contains(long id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean remove(long id) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,11 +12,6 @@ public class MediaFileNotFoundException extends Exception {
|
|||||||
this.media = media;
|
this.media = media;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaFileNotFoundException(FeedMedia media) {
|
|
||||||
super();
|
|
||||||
this.media = media;
|
|
||||||
}
|
|
||||||
|
|
||||||
public FeedMedia getMedia() {
|
public FeedMedia getMedia() {
|
||||||
return media;
|
return media;
|
||||||
}
|
}
|
||||||
|
@ -131,14 +131,6 @@ public class RemoteMedia implements Playable {
|
|||||||
return feedUrl;
|
return feedUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
public FeedMedia lookForFeedMedia() {
|
|
||||||
FeedItem feedItem = DBReader.getFeedItem(feedUrl, itemIdentifier);
|
|
||||||
if (feedItem == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return feedItem.getMedia();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeToPreferences(SharedPreferences.Editor prefEditor) {
|
public void writeToPreferences(SharedPreferences.Editor prefEditor) {
|
||||||
//it seems pointless to do it, since the session should be kept by the remote device.
|
//it seems pointless to do it, since the session should be kept by the remote device.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user