Refactor
This commit is contained in:
parent
acbda70e28
commit
16dd26a7e4
|
@ -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,12 +27,21 @@ 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)) {
|
||||
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) {
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Received feeds list: " + Arrays.toString(feedUrls));
|
||||
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 {
|
||||
|
@ -43,14 +52,5 @@ public class SPAReceiver extends BroadcastReceiver{
|
|||
}
|
||||
}
|
||||
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");
|
||||
ClientConfig.initialize(context);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue