Reorganize api utils package

This commit is contained in:
Shinokuni 2020-10-23 21:30:34 +02:00
parent 738e201653
commit 5e76eb4134
31 changed files with 62 additions and 43 deletions

View File

@ -7,7 +7,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.rule.GrantPermissionRule import androidx.test.rule.GrantPermissionRule
import com.readrops.api.opml.OPMLParser import com.readrops.api.opml.OPMLParser
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder import com.readrops.db.entities.Folder
import io.reactivex.schedulers.Schedulers import io.reactivex.schedulers.Schedulers

View File

@ -5,8 +5,8 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.LibUtils import com.readrops.api.utils.LibUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.UnknownFormatException import com.readrops.api.utils.exceptions.UnknownFormatException
import junit.framework.TestCase.* import junit.framework.TestCase.*
import okhttp3.Headers import okhttp3.Headers
import okhttp3.HttpUrl import okhttp3.HttpUrl

View File

@ -4,7 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.DateUtils import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import junit.framework.TestCase.* import junit.framework.TestCase.*
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test

View File

@ -4,7 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.DateUtils import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi
import com.squareup.moshi.Types import com.squareup.moshi.Types

View File

@ -4,7 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.DateUtils import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import junit.framework.TestCase.* import junit.framework.TestCase.*
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test

View File

@ -3,7 +3,7 @@ package com.readrops.api.localfeed.rss2
import android.content.Context import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertEquals
import org.junit.Test import org.junit.Test
import org.junit.runner.RunWith import org.junit.runner.RunWith

View File

@ -4,7 +4,7 @@ import android.content.Context
import androidx.test.ext.junit.runners.AndroidJUnit4 import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry import androidx.test.platform.app.InstrumentationRegistry
import com.readrops.api.utils.DateUtils import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import junit.framework.TestCase.* import junit.framework.TestCase.*
import org.junit.Assert import org.junit.Assert
import org.junit.Test import org.junit.Test

View File

@ -5,8 +5,8 @@ import androidx.annotation.WorkerThread
import com.readrops.api.localfeed.json.JSONFeedAdapter import com.readrops.api.localfeed.json.JSONFeedAdapter
import com.readrops.api.localfeed.json.JSONItemsAdapter import com.readrops.api.localfeed.json.JSONItemsAdapter
import com.readrops.api.utils.LibUtils import com.readrops.api.utils.LibUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.UnknownFormatException import com.readrops.api.utils.exceptions.UnknownFormatException
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import com.squareup.moshi.Moshi import com.squareup.moshi.Moshi

View File

@ -5,9 +5,9 @@ import com.gitlab.mvysny.konsumexml.Names
import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore
import com.gitlab.mvysny.konsumexml.konsumeXml import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.localfeed.XmlAdapter import com.readrops.api.localfeed.XmlAdapter
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.nonNullText import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.nullableText import com.readrops.api.utils.extensions.nullableText
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import java.io.InputStream import java.io.InputStream

View File

@ -6,6 +6,10 @@ import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore
import com.gitlab.mvysny.konsumexml.konsumeXml import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.localfeed.XmlAdapter import com.readrops.api.localfeed.XmlAdapter
import com.readrops.api.utils.* import com.readrops.api.utils.*
import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.extensions.nullableText
import com.readrops.api.utils.extensions.nullableTextRecursively
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import org.joda.time.LocalDateTime import org.joda.time.LocalDateTime
import java.io.InputStream import java.io.InputStream

View File

@ -1,8 +1,8 @@
package com.readrops.api.localfeed.json package com.readrops.api.localfeed.json
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.nextNonEmptyString import com.readrops.api.utils.extensions.nextNonEmptyString
import com.readrops.api.utils.nextNullableString import com.readrops.api.utils.extensions.nextNullableString
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.squareup.moshi.FromJson import com.squareup.moshi.FromJson
import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonReader

View File

@ -2,9 +2,9 @@ package com.readrops.api.localfeed.json
import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX
import com.readrops.api.utils.DateUtils import com.readrops.api.utils.DateUtils
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.nextNonEmptyString import com.readrops.api.utils.extensions.nextNonEmptyString
import com.readrops.api.utils.nextNullableString import com.readrops.api.utils.extensions.nextNullableString
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonReader

View File

@ -4,9 +4,9 @@ import com.gitlab.mvysny.konsumexml.Names
import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore
import com.gitlab.mvysny.konsumexml.konsumeXml import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.localfeed.XmlAdapter import com.readrops.api.localfeed.XmlAdapter
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.nonNullText import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.nullableText import com.readrops.api.utils.extensions.nullableText
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import java.io.InputStream import java.io.InputStream

View File

@ -6,6 +6,10 @@ import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.localfeed.XmlAdapter import com.readrops.api.localfeed.XmlAdapter
import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX
import com.readrops.api.utils.* import com.readrops.api.utils.*
import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.extensions.nullableText
import com.readrops.api.utils.extensions.nullableTextRecursively
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import org.joda.time.LocalDateTime import org.joda.time.LocalDateTime
import java.io.InputStream import java.io.InputStream

View File

@ -4,9 +4,9 @@ import com.gitlab.mvysny.konsumexml.Names
import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore import com.gitlab.mvysny.konsumexml.allChildrenAutoIgnore
import com.gitlab.mvysny.konsumexml.konsumeXml import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.localfeed.XmlAdapter import com.readrops.api.localfeed.XmlAdapter
import com.readrops.api.utils.ParseException import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.nonNullText import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.nullableText import com.readrops.api.utils.extensions.nullableText
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import org.jsoup.Jsoup import org.jsoup.Jsoup
import java.io.InputStream import java.io.InputStream

View File

@ -4,6 +4,10 @@ import com.gitlab.mvysny.konsumexml.*
import com.readrops.api.localfeed.XmlAdapter import com.readrops.api.localfeed.XmlAdapter
import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX import com.readrops.api.localfeed.XmlAdapter.Companion.AUTHORS_MAX
import com.readrops.api.utils.* import com.readrops.api.utils.*
import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.extensions.nullableText
import com.readrops.api.utils.extensions.nullableTextRecursively
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import org.joda.time.LocalDateTime import org.joda.time.LocalDateTime
import java.io.InputStream import java.io.InputStream

View File

@ -7,8 +7,7 @@ import com.readrops.api.opml.model.Body
import com.readrops.api.opml.model.Head import com.readrops.api.opml.model.Head
import com.readrops.api.opml.model.OPML import com.readrops.api.opml.model.OPML
import com.readrops.api.opml.model.Outline import com.readrops.api.opml.model.Outline
import com.readrops.api.utils.LibUtils import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.ParseException
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.readrops.db.entities.Folder import com.readrops.db.entities.Folder
import io.reactivex.Completable import io.reactivex.Completable

View File

@ -8,9 +8,9 @@ import androidx.annotation.Nullable;
import com.readrops.api.services.SyncResult; import com.readrops.api.services.SyncResult;
import com.readrops.api.services.SyncType; import com.readrops.api.services.SyncType;
import com.readrops.api.services.nextcloudnews.json.NextNewsUser; import com.readrops.api.services.nextcloudnews.json.NextNewsUser;
import com.readrops.api.utils.ConflictException; import com.readrops.api.utils.exceptions.ConflictException;
import com.readrops.api.utils.LibUtils; import com.readrops.api.utils.LibUtils;
import com.readrops.api.utils.UnknownFormatException; import com.readrops.api.utils.exceptions.UnknownFormatException;
import com.readrops.db.entities.Feed; import com.readrops.db.entities.Feed;
import com.readrops.db.entities.Folder; import com.readrops.db.entities.Folder;
import com.readrops.db.entities.Item; import com.readrops.db.entities.Item;

View File

@ -2,7 +2,7 @@ package com.readrops.api.services.nextcloudnews.adapters
import android.annotation.SuppressLint import android.annotation.SuppressLint
import com.readrops.db.entities.Feed import com.readrops.db.entities.Feed
import com.readrops.api.utils.nextNullableString import com.readrops.api.utils.extensions.nextNullableString
import com.squareup.moshi.FromJson import com.squareup.moshi.FromJson
import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonReader
import com.squareup.moshi.ToJson import com.squareup.moshi.ToJson

View File

@ -3,7 +3,7 @@ package com.readrops.api.services.nextcloudnews.adapters
import android.annotation.SuppressLint import android.annotation.SuppressLint
import com.readrops.db.entities.Item import com.readrops.db.entities.Item
import com.readrops.api.utils.LibUtils import com.readrops.api.utils.LibUtils
import com.readrops.api.utils.nextNullableString import com.readrops.api.utils.extensions.nextNullableString
import com.squareup.moshi.JsonAdapter import com.squareup.moshi.JsonAdapter
import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonReader
import com.squareup.moshi.JsonWriter import com.squareup.moshi.JsonWriter

View File

@ -1,4 +1,4 @@
package com.readrops.api.utils; package com.readrops.api.utils.exceptions;
public class ConflictException extends Exception { public class ConflictException extends Exception {

View File

@ -1,4 +1,4 @@
package com.readrops.api.utils; package com.readrops.api.utils.exceptions;
public class ParseException extends Exception { public class ParseException extends Exception {

View File

@ -1,4 +1,4 @@
package com.readrops.api.utils; package com.readrops.api.utils.exceptions;
public class UnknownFormatException extends Exception { public class UnknownFormatException extends Exception {

View File

@ -1,5 +1,6 @@
package com.readrops.api.utils package com.readrops.api.utils.extensions
import com.readrops.api.utils.exceptions.ParseException
import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonReader
fun JsonReader.nextNullableString(): String? = fun JsonReader.nextNullableString(): String? =

View File

@ -1,8 +1,9 @@
package com.readrops.api.utils package com.readrops.api.utils.extensions
import com.gitlab.mvysny.konsumexml.Konsumer import com.gitlab.mvysny.konsumexml.Konsumer
import com.gitlab.mvysny.konsumexml.Whitespace import com.gitlab.mvysny.konsumexml.Whitespace
import com.gitlab.mvysny.konsumexml.textRecursively import com.gitlab.mvysny.konsumexml.textRecursively
import com.readrops.api.utils.exceptions.ParseException
fun Konsumer.nonNullText(): String { fun Konsumer.nonNullText(): String {
val text = text(whitespace = Whitespace.preserve) val text = text(whitespace = Whitespace.preserve)

View File

@ -1,5 +1,8 @@
package com.readrops.api.utils package com.readrops.api.utils
import com.readrops.api.utils.exceptions.ParseException
import com.readrops.api.utils.extensions.nextNonEmptyString
import com.readrops.api.utils.extensions.nextNullableString
import com.squareup.moshi.JsonReader import com.squareup.moshi.JsonReader
import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertEquals
import junit.framework.TestCase.assertNull import junit.framework.TestCase.assertNull

View File

@ -2,6 +2,9 @@ package com.readrops.api.utils
import com.gitlab.mvysny.konsumexml.KonsumerException import com.gitlab.mvysny.konsumexml.KonsumerException
import com.gitlab.mvysny.konsumexml.konsumeXml import com.gitlab.mvysny.konsumexml.konsumeXml
import com.readrops.api.utils.extensions.nonNullText
import com.readrops.api.utils.extensions.nullableText
import com.readrops.api.utils.extensions.nullableTextRecursively
import junit.framework.TestCase.assertEquals import junit.framework.TestCase.assertEquals
import junit.framework.TestCase.assertNull import junit.framework.TestCase.assertNull
import org.junit.Test import org.junit.Test

View File

@ -11,8 +11,8 @@ import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentPagerAdapter; import androidx.fragment.app.FragmentPagerAdapter;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.readrops.api.utils.ConflictException; import com.readrops.api.utils.exceptions.ConflictException;
import com.readrops.api.utils.UnknownFormatException; import com.readrops.api.utils.exceptions.UnknownFormatException;
import com.readrops.app.R; import com.readrops.app.R;
import com.readrops.app.databinding.ActivityManageFeedsFoldersBinding; import com.readrops.app.databinding.ActivityManageFeedsFoldersBinding;
import com.readrops.app.fragments.FeedsFragment; import com.readrops.app.fragments.FeedsFragment;

View File

@ -13,8 +13,8 @@ import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.LinearLayoutManager;
import com.afollestad.materialdialogs.MaterialDialog; import com.afollestad.materialdialogs.MaterialDialog;
import com.readrops.api.utils.ConflictException; import com.readrops.api.utils.exceptions.ConflictException;
import com.readrops.api.utils.UnknownFormatException; import com.readrops.api.utils.exceptions.UnknownFormatException;
import com.readrops.app.R; import com.readrops.app.R;
import com.readrops.app.adapters.FoldersAdapter; import com.readrops.app.adapters.FoldersAdapter;
import com.readrops.app.databinding.FragmentFoldersBinding; import com.readrops.app.databinding.FragmentFoldersBinding;

View File

@ -10,8 +10,8 @@ import androidx.annotation.Nullable;
import com.readrops.api.localfeed.LocalRSSDataSource; import com.readrops.api.localfeed.LocalRSSDataSource;
import com.readrops.api.services.SyncResult; import com.readrops.api.services.SyncResult;
import com.readrops.api.utils.LibUtils; import com.readrops.api.utils.LibUtils;
import com.readrops.api.utils.ParseException; import com.readrops.api.utils.exceptions.ParseException;
import com.readrops.api.utils.UnknownFormatException; import com.readrops.api.utils.exceptions.UnknownFormatException;
import com.readrops.app.utils.FeedInsertionResult; import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.ParsingResult; import com.readrops.app.utils.ParsingResult;
import com.readrops.app.utils.SharedPreferencesManager; import com.readrops.app.utils.SharedPreferencesManager;

View File

@ -12,7 +12,7 @@ import com.readrops.api.services.SyncType;
import com.readrops.api.services.nextcloudnews.NextNewsDataSource; import com.readrops.api.services.nextcloudnews.NextNewsDataSource;
import com.readrops.api.services.nextcloudnews.NextNewsSyncData; import com.readrops.api.services.nextcloudnews.NextNewsSyncData;
import com.readrops.api.services.nextcloudnews.json.NextNewsUser; import com.readrops.api.services.nextcloudnews.json.NextNewsUser;
import com.readrops.api.utils.UnknownFormatException; import com.readrops.api.utils.exceptions.UnknownFormatException;
import com.readrops.app.utils.FeedInsertionResult; import com.readrops.app.utils.FeedInsertionResult;
import com.readrops.app.utils.ParsingResult; import com.readrops.app.utils.ParsingResult;
import com.readrops.app.utils.Utils; import com.readrops.app.utils.Utils;