Move isRSSType() method to LocalRSSHelper
This commit is contained in:
parent
52fda0f8d8
commit
b6d4f9296d
@ -51,6 +51,11 @@ object LocalRSSHelper {
|
||||
return type
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun isRSSType(type: String?): Boolean {
|
||||
return if (type != null) getRSSType(type) != RSSType.UNKNOWN else false
|
||||
}
|
||||
|
||||
enum class RSSType {
|
||||
RSS_1,
|
||||
RSS_2,
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.readrops.api.localfeed
|
||||
|
||||
import junit.framework.TestCase.assertEquals
|
||||
import junit.framework.TestCase.*
|
||||
import org.junit.Test
|
||||
import java.io.ByteArrayInputStream
|
||||
|
||||
@ -76,4 +76,16 @@ xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/r
|
||||
)), LocalRSSHelper.RSSType.UNKNOWN)
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isRSSTypeTest() {
|
||||
assertTrue(LocalRSSHelper.isRSSType("application/rss+xml"))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun isRSSTypeNullCaseTest() {
|
||||
assertFalse(LocalRSSHelper.isRSSType(null))
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import android.util.Log;
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.readrops.api.localfeed.LocalRSSHelper;
|
||||
import com.readrops.api.utils.HttpManager;
|
||||
import com.readrops.api.utils.LibUtils;
|
||||
|
||||
@ -42,7 +43,7 @@ public final class HtmlParser {
|
||||
for (Element element : elements) {
|
||||
String type = element.attributes().get("type");
|
||||
|
||||
if (isTypeRssFeed(type)) {
|
||||
if (LocalRSSHelper.isRSSType(type)) {
|
||||
String feedUrl = element.absUrl("href");
|
||||
String label = element.attributes().get("title");
|
||||
|
||||
@ -56,14 +57,6 @@ public final class HtmlParser {
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean isTypeRssFeed(String type) {
|
||||
return type.equals(LibUtils.RSS_DEFAULT_CONTENT_TYPE) ||
|
||||
type.equals(LibUtils.ATOM_CONTENT_TYPE) ||
|
||||
type.equals(LibUtils.JSON_CONTENT_TYPE) ||
|
||||
type.equals(LibUtils.RSS_TEXT_CONTENT_TYPE) ||
|
||||
type.equals(LibUtils.RSS_APPLICATION_CONTENT_TYPE);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public static String getFaviconLink(@NonNull String url) {
|
||||
String favUrl = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user