Clean LibUtils class

This commit is contained in:
Shinokuni 2020-10-06 22:20:53 +02:00
parent b6d4f9296d
commit b8219b5dde
2 changed files with 1 additions and 25 deletions

View File

@ -35,10 +35,9 @@ object OPMLParser {
fun read(stream: InputStream): Single<Map<Folder?, List<Feed>>> {
return Single.create { emitter ->
try {
val fileString = LibUtils.inputStreamToString(stream)
val serializer: Serializer = Persister()
val opml: OPML = serializer.read(OPML::class.java, fileString)
val opml: OPML = serializer.read(OPML::class.java, stream)
emitter.onSuccess(opmlToFoldersAndFeeds(opml))
} catch (e: Exception) {

View File

@ -1,26 +1,15 @@
package com.readrops.api.utils;
import android.content.Context;
import android.net.Uri;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import org.jsoup.Jsoup;
import java.io.FileNotFoundException;
import java.io.InputStream;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public final class LibUtils {
public static final String RSS_DEFAULT_CONTENT_TYPE = "application/rss+xml";
public static final String RSS_TEXT_CONTENT_TYPE = "text/xml";
public static final String RSS_APPLICATION_CONTENT_TYPE = "application/xml";
public static final String ATOM_CONTENT_TYPE = "application/atom+xml";
public static final String JSON_CONTENT_TYPE = "application/json";
public static final String HTML_CONTENT_TYPE = "text/html";
public static final String CONTENT_TYPE_HEADER = "content-type";
@ -35,18 +24,6 @@ public final class LibUtils {
private static final String RSS_CONTENT_TYPE_REGEX = "([^;]+)";
public static String inputStreamToString(InputStream input) {
Scanner scanner = new Scanner(input).useDelimiter("\\A");
return scanner.hasNext() ? scanner.next() : "";
}
public static String fileToString(Uri uri, Context context) throws FileNotFoundException {
InputStream inputStream = context.getContentResolver().openInputStream(uri);
return inputStreamToString(inputStream);
}
public static boolean isMimeImage(@NonNull String type) {
return type.equals("image") || type.equals("image/jpeg") || type.equals("image/jpg")
|| type.equals("image/png");