This commit is contained in:
Martin Fietz 2016-02-19 13:35:10 +01:00
parent acbda70e28
commit 16dd26a7e4
2 changed files with 26 additions and 27 deletions

View File

@ -9,8 +9,8 @@ import android.widget.Toast;
import java.util.Arrays;
import de.danoeh.antennapod.BuildConfig;
import de.danoeh.antennapod.R;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.feed.Feed;
import de.danoeh.antennapod.core.storage.DownloadRequestException;
import de.danoeh.antennapod.core.storage.DownloadRequester;
@ -27,30 +27,30 @@ public class SPAReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) {
if (TextUtils.equals(intent.getAction(), ACTION_SP_APPS_QUERY_FEEDS_REPSONSE)) {
if (BuildConfig.DEBUG) Log.d(TAG, "Received SP_APPS_QUERY_RESPONSE");
if (intent.hasExtra(ACTION_SP_APPS_QUERY_FEEDS_REPSONSE_FEEDS_EXTRA)) {
String[] feedUrls = intent.getStringArrayExtra(ACTION_SP_APPS_QUERY_FEEDS_REPSONSE_FEEDS_EXTRA);
if (feedUrls != null) {
if (BuildConfig.DEBUG) Log.d(TAG, "Received feeds list: " + Arrays.toString(feedUrls));
for (String url : feedUrls) {
Feed f = new Feed(url, null);
try {
DownloadRequester.getInstance().downloadFeed(context, f);
} catch (DownloadRequestException e) {
Log.e(TAG, "Error while trying to add feed " + url);
e.printStackTrace();
}
}
Toast.makeText(context, R.string.sp_apps_importing_feeds_msg, Toast.LENGTH_LONG).show();
} else {
Log.e(TAG, "Received invalid SP_APPS_QUERY_REPSONSE: extra was null");
}
} else {
Log.e(TAG, "Received invalid SP_APPS_QUERY_RESPONSE: Contains no extra");
if (!TextUtils.equals(intent.getAction(), ACTION_SP_APPS_QUERY_FEEDS_REPSONSE)) {
return;
}
Log.d(TAG, "Received SP_APPS_QUERY_RESPONSE");
if (!intent.hasExtra(ACTION_SP_APPS_QUERY_FEEDS_REPSONSE_FEEDS_EXTRA)) {
Log.e(TAG, "Received invalid SP_APPS_QUERY_RESPONSE: Contains no extra");
return;
}
String[] feedUrls = intent.getStringArrayExtra(ACTION_SP_APPS_QUERY_FEEDS_REPSONSE_FEEDS_EXTRA);
if (feedUrls == null) {
Log.e(TAG, "Received invalid SP_APPS_QUERY_REPSONSE: extra was null");
return;
}
Log.d(TAG, "Received feeds list: " + Arrays.toString(feedUrls));
ClientConfig.initialize(context);
for (String url : feedUrls) {
Feed f = new Feed(url, null);
try {
DownloadRequester.getInstance().downloadFeed(context, f);
} catch (DownloadRequestException e) {
Log.e(TAG, "Error while trying to add feed " + url);
e.printStackTrace();
}
}
Toast.makeText(context, R.string.sp_apps_importing_feeds_msg, Toast.LENGTH_LONG).show();
}
}

View File

@ -5,7 +5,7 @@ import android.content.Context;
import android.content.Intent;
import android.util.Log;
import android.view.KeyEvent;
import de.danoeh.antennapod.core.BuildConfig;
import de.danoeh.antennapod.core.ClientConfig;
import de.danoeh.antennapod.core.service.playback.PlaybackService;
@ -18,9 +18,8 @@ public class MediaButtonReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (BuildConfig.DEBUG) Log.d(TAG, "Received intent");
KeyEvent event = (KeyEvent) intent.getExtras().get(
Intent.EXTRA_KEY_EVENT);
Log.d(TAG, "Received intent");
KeyEvent event = (KeyEvent) intent.getExtras().get(Intent.EXTRA_KEY_EVENT);
if (event.getAction() == KeyEvent.ACTION_DOWN) {
ClientConfig.initialize(context);
Intent serviceIntent = new Intent(context, PlaybackService.class);