Null handling in OnlineFeedViewActivity (#3004)
This commit is contained in:
parent
3b67381656
commit
7f100b3fa6
|
@ -29,6 +29,7 @@ import android.widget.TextView;
|
|||
import com.bumptech.glide.Glide;
|
||||
|
||||
import com.bumptech.glide.request.RequestOptions;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.jsoup.Jsoup;
|
||||
import org.jsoup.nodes.Document;
|
||||
|
@ -140,7 +141,7 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
|
||||
StorageUtils.checkStorageAvailability(this);
|
||||
|
||||
final String feedUrl;
|
||||
String feedUrl = null;
|
||||
if (getIntent().hasExtra(ARG_FEEDURL)) {
|
||||
feedUrl = getIntent().getStringExtra(ARG_FEEDURL);
|
||||
} else if (TextUtils.equals(getIntent().getAction(), Intent.ACTION_SEND)
|
||||
|
@ -150,16 +151,23 @@ public class OnlineFeedViewActivity extends AppCompatActivity {
|
|||
if (actionBar != null) {
|
||||
actionBar.setTitle(R.string.add_feed_label);
|
||||
}
|
||||
} else {
|
||||
throw new IllegalArgumentException("Activity must be started with feedurl argument!");
|
||||
}
|
||||
|
||||
Log.d(TAG, "Activity was started with url " + feedUrl);
|
||||
setLoadingLayout();
|
||||
if (savedInstanceState == null) {
|
||||
startFeedDownload(feedUrl, null, null);
|
||||
if (feedUrl == null) {
|
||||
Log.e(TAG, "feedUrl is null.");
|
||||
new AlertDialog.Builder(OnlineFeedViewActivity.this).
|
||||
setNeutralButton(android.R.string.ok,
|
||||
(dialog, which) -> dialog.dismiss()).
|
||||
setTitle(R.string.error_label).
|
||||
setMessage(R.string.null_value_podcast_error).create().show();
|
||||
} else {
|
||||
startFeedDownload(feedUrl, savedInstanceState.getString("username"), savedInstanceState.getString("password"));
|
||||
Log.d(TAG, "Activity was started with url " + feedUrl);
|
||||
setLoadingLayout();
|
||||
if (savedInstanceState == null) {
|
||||
startFeedDownload(feedUrl, null, null);
|
||||
} else {
|
||||
startFeedDownload(feedUrl, savedInstanceState.getString("username"), savedInstanceState.getString("password"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package de.danoeh.antennapod.core.util;
|
||||
|
||||
import android.net.Uri;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.util.Log;
|
||||
|
||||
import de.danoeh.antennapod.core.BuildConfig;
|
||||
|
@ -29,7 +30,7 @@ public final class URLChecker {
|
|||
* @param url The url which is going to be prepared
|
||||
* @return The prepared url
|
||||
*/
|
||||
public static String prepareURL(String url) {
|
||||
public static String prepareURL(@NonNull String url) {
|
||||
url = url.trim();
|
||||
if (url.startsWith("feed://")) {
|
||||
if (BuildConfig.DEBUG) Log.d(TAG, "Replacing feed:// with http://");
|
||||
|
|
|
@ -229,6 +229,7 @@
|
|||
<string name="download_type_media">Media file</string>
|
||||
<string name="download_type_image">Image</string>
|
||||
<string name="download_request_error_dialog_message_prefix">An error occurred when trying to download the file:\u0020</string>
|
||||
<string name="null_value_podcast_error">No podcast was provided that could be shown.</string>
|
||||
<string name="authentication_notification_title">Authentication required</string>
|
||||
<string name="authentication_notification_msg">The resource you requested requires a username and a password</string>
|
||||
<string name="confirm_mobile_download_dialog_title">Confirm Mobile Download</string>
|
||||
|
|
Loading…
Reference in New Issue