Remove all unnecessary jvm annotations
This commit is contained in:
1 parent
3c64486c3b
commit
b07fd2bc4f
30 files changed
+27
-107
No files matched your search
@@ -31,7 +31,6 @@ import kotlinx.coroutines.cancel
|
||||
import kotlinx.coroutines.delay
|
||||
import kotlinx.coroutines.launch
|
||||
import kotlinx.coroutines.withContext
|
||||
import java.util.ArrayList
|
||||
import java.util.Locale
|
||||
import java.util.concurrent.locks.ReadWriteLock
|
||||
import java.util.concurrent.locks.ReentrantReadWriteLock
|
||||
@@ -1713,7 +1712,6 @@ open class SubsamplingScaleImageView @JvmOverloads constructor(
|
||||
* @param sTarget target object for result. The same instance is also returned.
|
||||
* @return a coordinate representing the corresponding source coordinate. This is the same instance passed to the sTarget param.
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun viewToSourceCoord(vx: Float, vy: Float, sTarget: PointF = PointF()): PointF? {
|
||||
if (vTranslate == null) {
|
||||
return null
|
||||
@@ -1765,7 +1763,6 @@ open class SubsamplingScaleImageView @JvmOverloads constructor(
|
||||
* @param vTarget target object for result. The same instance is also returned.
|
||||
* @return view coordinates. This is the same instance passed to the vTarget param.
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun sourceToViewCoord(sx: Float, sy: Float, vTarget: PointF = PointF()): PointF? {
|
||||
if (vTranslate == null) {
|
||||
return null
|
||||
|
||||
@@ -5,8 +5,6 @@ import android.graphics.Bitmap
|
||||
import android.graphics.Point
|
||||
import android.graphics.Rect
|
||||
import com.davemorrissey.labs.subscaleview.provider.InputProvider
|
||||
import java.lang.Exception
|
||||
import kotlin.Throws
|
||||
|
||||
/**
|
||||
* Interface for image decoding classes.
|
||||
@@ -21,7 +19,6 @@ interface Decoder {
|
||||
* @return Dimensions of the image.
|
||||
* @throws Exception if initialisation fails.
|
||||
*/
|
||||
@Throws(Exception::class)
|
||||
fun init(context: Context, provider: InputProvider): Point
|
||||
|
||||
/**
|
||||
|
||||
@@ -7,10 +7,7 @@ import android.graphics.Rect
|
||||
import com.davemorrissey.labs.subscaleview.SubsamplingScaleImageView
|
||||
import com.davemorrissey.labs.subscaleview.provider.InputProvider
|
||||
|
||||
class ImageDecoder @JvmOverloads constructor(
|
||||
private val cropBorders: Boolean,
|
||||
bitmapConfig: Bitmap.Config? = null,
|
||||
) : Decoder {
|
||||
class ImageDecoder(private val cropBorders: Boolean, bitmapConfig: Bitmap.Config? = null) : Decoder {
|
||||
init {
|
||||
val globalBitmapConfig = SubsamplingScaleImageView.preferredBitmapConfig
|
||||
}
|
||||
@@ -24,7 +21,6 @@ class ImageDecoder @JvmOverloads constructor(
|
||||
* @return Dimensions of the image.
|
||||
* @throws Exception if initialisation fails.
|
||||
*/
|
||||
@Throws(Exception::class)
|
||||
override fun init(context: Context, provider: InputProvider): Point {
|
||||
TODO()
|
||||
}
|
||||
|
||||
@@ -188,7 +188,6 @@ object EhDB {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
@Synchronized
|
||||
fun containLocalFavorites(gid: Long): Boolean {
|
||||
val dao = db.localFavoritesDao()
|
||||
|
||||
@@ -141,7 +141,6 @@ object EhTagDatabase : CoroutineScope {
|
||||
it["reclass"] = "r"
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun namespaceToPrefix(namespace: String): String? {
|
||||
return NAMESPACE_TO_PREFIX[namespace]
|
||||
}
|
||||
|
||||
@@ -73,7 +73,6 @@ object EhUrl {
|
||||
else -> API_E
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
val referer: String
|
||||
get() = when (Settings.gallerySite) {
|
||||
SITE_E -> REFERER_E
|
||||
@@ -88,7 +87,6 @@ object EhUrl {
|
||||
else -> ORIGIN_E
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
val uConfigUrl: String
|
||||
get() = when (Settings.gallerySite) {
|
||||
SITE_E -> URL_UCONFIG_E
|
||||
@@ -96,7 +94,6 @@ object EhUrl {
|
||||
else -> URL_UCONFIG_E
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
val myTagsUrl: String
|
||||
get() = when (Settings.gallerySite) {
|
||||
SITE_E -> URL_MY_TAGS_E
|
||||
@@ -129,7 +126,6 @@ object EhUrl {
|
||||
return getGalleryDetailUrl(gid, token, 0, false)
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getGalleryDetailUrl(gid: Long, token: String?, index: Int, allComment: Boolean): String {
|
||||
val builder = UrlBuilder(host + "g/" + gid + '/' + token + '/')
|
||||
if (index != 0) {
|
||||
@@ -141,13 +137,11 @@ object EhUrl {
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getGalleryMultiPageViewerUrl(gid: Long, token: String): String {
|
||||
val builder = UrlBuilder(host + "mpv/" + gid + '/' + token + '/')
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getPageUrl(gid: Long, index: Int, pToken: String): String {
|
||||
return host + "s/" + pToken + '/' + gid + '-' + (index + 1)
|
||||
}
|
||||
|
||||
@@ -79,7 +79,6 @@ object EhUtils {
|
||||
val isExHentai: Boolean
|
||||
get() = Settings.gallerySite == EhUrl.SITE_EX
|
||||
|
||||
@JvmStatic
|
||||
fun getCategory(type: String?): Int {
|
||||
for (entry in CATEGORY_STRINGS) {
|
||||
for (str in entry.first)
|
||||
@@ -122,7 +121,6 @@ object EhUtils {
|
||||
return Settings.needSignIn
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun getSuitableTitle(gi: GalleryInfo): String {
|
||||
return if (Settings.showJpnTitle) {
|
||||
if (TextUtils.isEmpty(gi.titleJpn)) gi.title else gi.titleJpn
|
||||
@@ -145,7 +143,6 @@ object EhUtils {
|
||||
return title.ifEmpty { null }
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun handleThumbUrlResolution(url: String?): String? {
|
||||
if (null == url) {
|
||||
return null
|
||||
|
||||
@@ -21,30 +21,17 @@ import kotlinx.parcelize.Parcelize
|
||||
@Parcelize
|
||||
class GalleryComment(
|
||||
// 0 for uploader comment. can't vote
|
||||
@JvmField
|
||||
var id: Long = 0,
|
||||
@JvmField
|
||||
var score: Int = 0,
|
||||
@JvmField
|
||||
var editable: Boolean = false,
|
||||
@JvmField
|
||||
var voteUpAble: Boolean = false,
|
||||
@JvmField
|
||||
var voteUpEd: Boolean = false,
|
||||
@JvmField
|
||||
var voteDownAble: Boolean = false,
|
||||
@JvmField
|
||||
var voteDownEd: Boolean = false,
|
||||
@JvmField
|
||||
var uploader: Boolean = false,
|
||||
@JvmField
|
||||
var voteState: String? = null,
|
||||
@JvmField
|
||||
var time: Long = 0,
|
||||
@JvmField
|
||||
var user: String? = null,
|
||||
@JvmField
|
||||
var comment: String? = null,
|
||||
@JvmField
|
||||
var lastEdited: Long = 0,
|
||||
) : Parcelable
|
||||
@@ -21,6 +21,5 @@ import kotlinx.parcelize.Parcelize
|
||||
@Parcelize
|
||||
class GalleryTagGroup(
|
||||
private val mTagList: ArrayList<String> = arrayListOf(),
|
||||
@JvmField
|
||||
var groupName: String? = null,
|
||||
) : Parcelable, MutableList<String> by mTagList
|
||||
@@ -65,7 +65,6 @@ object ArchiveParser {
|
||||
return result
|
||||
}
|
||||
|
||||
@Throws(NoHAtHClientException::class)
|
||||
fun parseArchiveUrl(body: String): String? {
|
||||
if (PATTERN_NEED_HATH_CLIENT.containsMatchIn(body)) throw NoHAtHClientException("No H@H client")
|
||||
return Jsoup.parse(body).selectFirst("#continue>a[href]")
|
||||
|
||||
@@ -81,7 +81,6 @@ object GalleryDetailParser {
|
||||
"<p>(And if you choose to ignore this warning, you lose all rights to complain about it in the future.)</p>"
|
||||
private const val PINING_STRING = "<p>This gallery is pining for the fjords.</p>"
|
||||
|
||||
@Throws(EhException::class)
|
||||
fun parse(body: String): GalleryDetail {
|
||||
if (body.contains(OFFENSIVE_STRING)) {
|
||||
throw OffensiveException()
|
||||
@@ -107,7 +106,6 @@ object GalleryDetailParser {
|
||||
return galleryDetail
|
||||
}
|
||||
|
||||
@Throws(ParseException::class)
|
||||
private fun parseDetail(gd: GalleryDetail, d: Document, body: String) {
|
||||
PATTERN_DETAIL.find(body)?.apply {
|
||||
gd.gid = groupValues[1].toLongOrNull() ?: -1L
|
||||
@@ -453,7 +451,6 @@ object GalleryDetailParser {
|
||||
/**
|
||||
* Parse preview pages with regular expressions
|
||||
*/
|
||||
@Throws(ParseException::class)
|
||||
fun parsePreviewPages(body: String): Int {
|
||||
return PATTERN_PREVIEW_PAGES.find(body)?.groupValues?.get(1)?.toIntOrNull()
|
||||
?: throw ParseException("Parse preview page count error", body)
|
||||
@@ -462,7 +459,6 @@ object GalleryDetailParser {
|
||||
/**
|
||||
* Parse pages with regular expressions
|
||||
*/
|
||||
@Throws(ParseException::class)
|
||||
fun parsePages(body: String): Int {
|
||||
return PATTERN_PAGES.find(body)?.groupValues?.get(1)?.toIntOrNull()
|
||||
?: throw ParseException("Parse pages error", body)
|
||||
|
||||
@@ -8,39 +8,30 @@ import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
|
||||
@Entity(tableName = "DOWNLOADS")
|
||||
class DownloadInfo() : BaseGalleryInfo() {
|
||||
@JvmField
|
||||
@ColumnInfo(name = "STATE")
|
||||
var state = 0
|
||||
|
||||
@JvmField
|
||||
@ColumnInfo(name = "LEGACY")
|
||||
var legacy = 0
|
||||
|
||||
@JvmField
|
||||
@ColumnInfo(name = "TIME")
|
||||
var time: Long = 0
|
||||
|
||||
@JvmField
|
||||
@ColumnInfo(name = "LABEL")
|
||||
var label: String? = null
|
||||
|
||||
@JvmField
|
||||
@Ignore
|
||||
var speed: Long = 0
|
||||
|
||||
@JvmField
|
||||
@Ignore
|
||||
var remaining: Long = 0
|
||||
|
||||
@JvmField
|
||||
@Ignore
|
||||
var finished = 0
|
||||
|
||||
@JvmField
|
||||
@Ignore
|
||||
var downloaded = 0
|
||||
|
||||
@JvmField
|
||||
@Ignore
|
||||
var total = 0
|
||||
|
||||
|
||||
@@ -6,15 +6,12 @@ import androidx.room.PrimaryKey
|
||||
|
||||
@Entity(tableName = "FILTER")
|
||||
data class Filter(
|
||||
@JvmField
|
||||
@ColumnInfo(name = "MODE")
|
||||
var mode: Int = 0,
|
||||
|
||||
@JvmField
|
||||
@ColumnInfo(name = "TEXT")
|
||||
var text: String? = null,
|
||||
|
||||
@JvmField
|
||||
@ColumnInfo(name = "ENABLE")
|
||||
var enable: Boolean? = null,
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
|
||||
@Entity(tableName = "HISTORY")
|
||||
class HistoryInfo() : BaseGalleryInfo() {
|
||||
@JvmField
|
||||
@ColumnInfo(name = "TIME")
|
||||
var time: Long = 0
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import com.hippo.ehviewer.client.data.GalleryInfo
|
||||
|
||||
@Entity(tableName = "LOCAL_FAVORITES")
|
||||
class LocalFavoriteInfo() : BaseGalleryInfo() {
|
||||
@JvmField
|
||||
@ColumnInfo(name = "TIME")
|
||||
var time: Long = 0
|
||||
|
||||
|
||||
@@ -336,7 +336,6 @@ object DownloadManager : OnSpiderListener {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun addDownload(downloadInfoList: List<DownloadInfo>, notify: Boolean = true) {
|
||||
for (info in downloadInfoList) {
|
||||
if (containDownloadInfo(info.gid)) {
|
||||
|
||||
@@ -542,7 +542,6 @@ class DownloadService : Service(), DownloadManager.DownloadListener {
|
||||
private var sFinishedCount = 0
|
||||
private var sDownloadedCount = 0
|
||||
|
||||
@JvmStatic
|
||||
fun clear() {
|
||||
sFailedCount = 0
|
||||
sFinishedCount = 0
|
||||
|
||||
@@ -69,7 +69,6 @@ class Image private constructor(private val src: CloseableSource) {
|
||||
|
||||
private val imageSearchMaxSize = appCtx.resources.getDimensionPixelOffset(R.dimen.image_search_max_size)
|
||||
|
||||
@JvmStatic
|
||||
val imageSearchDecoderSampleListener =
|
||||
ImageDecoder.OnHeaderDecodedListener { decoder, info, _ ->
|
||||
decoder.setTargetSampleSize(
|
||||
@@ -87,7 +86,6 @@ class Image private constructor(private val src: CloseableSource) {
|
||||
},
|
||||
)
|
||||
|
||||
@JvmStatic
|
||||
fun decode(src: CloseableSource): Image? {
|
||||
return runCatching {
|
||||
Image(src)
|
||||
|
||||
@@ -40,7 +40,6 @@ import okhttp3.Response
|
||||
import okio.Buffer
|
||||
import okio.ForwardingSink
|
||||
import okio.sink
|
||||
import java.io.IOException
|
||||
import java.util.Locale
|
||||
import kotlin.io.path.readText
|
||||
import com.hippo.ehviewer.EhApplication.Companion.imageCache as sCache
|
||||
@@ -124,7 +123,6 @@ class SpiderDen(private val mGalleryInfo: GalleryInfo) {
|
||||
return dir.createFile(perFilename(index, ext))
|
||||
}
|
||||
|
||||
@Throws(IOException::class)
|
||||
suspend fun makeHttpCallAndSaveImage(
|
||||
index: Int,
|
||||
url: String,
|
||||
|
||||
@@ -16,7 +16,7 @@ import splitties.init.appCtx
|
||||
import java.io.File
|
||||
|
||||
@Serializable
|
||||
class SpiderInfo @JvmOverloads constructor(
|
||||
class SpiderInfo(
|
||||
val gid: Long,
|
||||
|
||||
val pages: Int,
|
||||
|
||||
@@ -338,7 +338,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
?: readFromCache(galleryInfo.gid)?.takeIf { it.gid == galleryInfo.gid && it.token == galleryInfo.token }
|
||||
}
|
||||
|
||||
@Throws(ParseException::class)
|
||||
private fun readPreviews(body: String, index: Int, spiderInfo: SpiderInfo) {
|
||||
spiderInfo.previewPages = parsePreviewPages(body)
|
||||
val (previewList, pageUrlList) = parsePreviewList(body)
|
||||
@@ -436,7 +435,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
return state == STATE_FINISHED || state == STATE_FAILED
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun updatePageState(index: Int, @State state: Int, error: String? = null) {
|
||||
var oldState: Int
|
||||
synchronized(mPageStateLock) {
|
||||
@@ -503,7 +501,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
const val SPIDER_INFO_FILENAME = ".ehviewer"
|
||||
private val sQueenMap = LongSparseArray<SpiderQueen>()
|
||||
|
||||
@JvmStatic
|
||||
fun obtainSpiderQueen(galleryInfo: GalleryInfo, @Mode mode: Int): SpiderQueen {
|
||||
val gid = galleryInfo.gid
|
||||
return (sQueenMap[gid] ?: SpiderQueen(galleryInfo).also { sQueenMap[gid] = it }).apply {
|
||||
@@ -512,7 +509,6 @@ class SpiderQueen private constructor(val galleryInfo: GalleryInfo) : CoroutineS
|
||||
}
|
||||
}
|
||||
|
||||
@JvmStatic
|
||||
fun releaseSpiderQueen(queen: SpiderQueen, @Mode mode: Int) {
|
||||
queen.run {
|
||||
clearMode(mode)
|
||||
|
||||
@@ -205,6 +205,7 @@ class MainActivity : EhActivity() {
|
||||
if (parent is Openable) {
|
||||
parent.close()
|
||||
} else {
|
||||
@SuppressLint("RestrictedApi")
|
||||
val bottomSheetBehavior = NavigationUI.findBottomSheetBehavior(navigationView)
|
||||
if (bottomSheetBehavior != null) {
|
||||
bottomSheetBehavior.state = BottomSheetBehavior.STATE_HIDDEN
|
||||
@@ -235,7 +236,6 @@ class MainActivity : EhActivity() {
|
||||
}
|
||||
|
||||
@RequiresApi(Build.VERSION_CODES.S)
|
||||
@Throws(PackageManager.NameNotFoundException::class)
|
||||
private fun checkAppLinkVerify() {
|
||||
val manager = getSystemService(DomainVerificationManager::class.java)
|
||||
val userState = manager.getDomainVerificationUserState(packageName) ?: return
|
||||
@@ -432,7 +432,6 @@ class MainActivity : EhActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun showTip(@StringRes id: Int, length: Int, useToast: Boolean = false) {
|
||||
showTip(getString(id), length, useToast)
|
||||
}
|
||||
@@ -440,7 +439,6 @@ class MainActivity : EhActivity() {
|
||||
/**
|
||||
* If activity is running, show snack bar, otherwise show toast
|
||||
*/
|
||||
@JvmOverloads
|
||||
fun showTip(message: CharSequence, length: Int, useToast: Boolean = false) {
|
||||
findViewById<View>(R.id.snackbar)?.takeUnless { useToast }?.apply {
|
||||
Snackbar.make(
|
||||
|
||||
@@ -607,7 +607,6 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
private val isContentShowing: Boolean
|
||||
get() = mViewTransition.shownViewIndex == 0
|
||||
|
||||
@JvmOverloads
|
||||
fun showProgressBar(animation: Boolean = true) {
|
||||
mViewTransition.showView(1, animation)
|
||||
}
|
||||
@@ -689,7 +688,6 @@ class ContentLayout(context: Context, attrs: AttributeSet? = null) : FrameLayout
|
||||
* @param page the target page
|
||||
* @throws IndexOutOfBoundsException if page < 0 or page >= mPages
|
||||
*/
|
||||
@Throws(IndexOutOfBoundsException::class)
|
||||
fun goTo(page: Int) {
|
||||
if (page < 0 || page >= pages) {
|
||||
throw IndexOutOfBoundsException("Page count is $pages, page is $page")
|
||||
|
||||
@@ -28,7 +28,6 @@ import java.time.format.DateTimeFormatter
|
||||
import java.util.Locale
|
||||
|
||||
abstract class GalleryInfoContentHelper : ContentHelper() {
|
||||
@JvmField
|
||||
var jumpTo: String? = null
|
||||
private val listener: FavouriteStatusRouter.Listener
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ object LayoutManagerUtils {
|
||||
}
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun smoothScrollToPosition(
|
||||
layoutManager: RecyclerView.LayoutManager,
|
||||
context: Context,
|
||||
|
||||
@@ -173,7 +173,6 @@ class SearchLayout @JvmOverloads constructor(
|
||||
}
|
||||
|
||||
@SuppressLint("NonConstantResourceId")
|
||||
@Throws(EhException::class)
|
||||
fun formatListUrlBuilder(urlBuilder: ListUrlBuilder, query: String?) {
|
||||
urlBuilder.reset()
|
||||
when (mSearchMode) {
|
||||
|
||||
@@ -38,7 +38,6 @@ open class ViewTransition(vararg views: View) {
|
||||
mOnShowViewListener = listener
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun showView(shownView: Int, animation: Boolean = true): Boolean {
|
||||
val views = mViews
|
||||
val length = views.size
|
||||
|
||||
@@ -31,7 +31,6 @@ import androidx.drawerlayout.widget.DrawerLayout
|
||||
import androidx.fragment.app.Fragment
|
||||
import androidx.navigation.NavOptions
|
||||
import androidx.navigation.fragment.NavHostFragment
|
||||
import com.hippo.ehviewer.R
|
||||
import com.hippo.ehviewer.ui.MainActivity
|
||||
import rikka.core.res.resolveDrawable
|
||||
|
||||
@@ -204,7 +203,6 @@ abstract class BaseScene : Fragment() {
|
||||
get() = requireActivity().theme
|
||||
|
||||
@SuppressLint("PrivateResource")
|
||||
@JvmOverloads
|
||||
fun navigate(id: Int, args: Bundle?, singleTop: Boolean = false) {
|
||||
val options: NavOptions = NavOptions.Builder().setLaunchSingleTop(singleTop)
|
||||
.setEnterAnim(androidx.fragment.R.animator.fragment_open_enter)
|
||||
|
||||
@@ -38,7 +38,6 @@ infix fun Context.whisperClipboard(text: String?) {
|
||||
addTextToClipboard(text, true, false)
|
||||
}
|
||||
|
||||
@JvmOverloads
|
||||
fun Context.addTextToClipboard(text: CharSequence?, isSensitive: Boolean, useToast: Boolean = false) {
|
||||
clipboardManager.apply {
|
||||
setPrimaryClip(
|
||||
|
||||
@@ -29,42 +29,37 @@ import javax.net.ssl.SSLException
|
||||
object ExceptionUtils {
|
||||
fun getReadableString(e: Throwable): String {
|
||||
e.printStackTrace()
|
||||
return if (e is MalformedURLException) {
|
||||
appCtx.getString(R.string.error_invalid_url)
|
||||
} else if (e is SocketTimeoutException) {
|
||||
appCtx.getString(R.string.error_timeout)
|
||||
} else if (e is UnknownHostException) {
|
||||
appCtx.getString(R.string.error_unknown_host)
|
||||
} else if (e is StatusCodeException) {
|
||||
val sb = StringBuilder()
|
||||
sb.append(appCtx.getString(R.string.error_bad_status_code, e.responseCode))
|
||||
if (e.isIdentifiedResponseCode) {
|
||||
sb.append(", ").append(e.message)
|
||||
return when (e) {
|
||||
is MalformedURLException -> appCtx.getString(R.string.error_invalid_url)
|
||||
is SocketTimeoutException -> appCtx.getString(R.string.error_timeout)
|
||||
is UnknownHostException -> appCtx.getString(R.string.error_unknown_host)
|
||||
is StatusCodeException -> {
|
||||
val sb = StringBuilder()
|
||||
sb.append(appCtx.getString(R.string.error_bad_status_code, e.responseCode))
|
||||
if (e.isIdentifiedResponseCode) {
|
||||
sb.append(", ").append(e.message)
|
||||
}
|
||||
sb.toString()
|
||||
}
|
||||
sb.toString()
|
||||
} else if (e is ProtocolException && e.message!!.startsWith("Too many follow-up requests:")) {
|
||||
appCtx.getString(R.string.error_redirection)
|
||||
} else if (e is ProtocolException || e is SocketException || e is SSLException) {
|
||||
appCtx.getString(R.string.error_socket)
|
||||
} else if (e is EhException) {
|
||||
e.message!!
|
||||
} else {
|
||||
appCtx.getString(R.string.error_unknown)
|
||||
|
||||
is ProtocolException -> {
|
||||
if (e.message!!.startsWith("Too many follow-up requests:")) {
|
||||
appCtx.getString(R.string.error_redirection)
|
||||
} else {
|
||||
appCtx.getString(R.string.error_socket)
|
||||
}
|
||||
}
|
||||
|
||||
is SocketException, is SSLException -> appCtx.getString(R.string.error_socket)
|
||||
is EhException -> e.message!!
|
||||
else -> appCtx.getString(R.string.error_unknown)
|
||||
}
|
||||
}
|
||||
|
||||
fun throwIfFatal(t: Throwable) {
|
||||
// values here derived from https://github.com/ReactiveX/RxJava/issues/748#issuecomment-32471495
|
||||
when (t) {
|
||||
is VirtualMachineError -> {
|
||||
throw t
|
||||
}
|
||||
|
||||
is ThreadDeath -> {
|
||||
throw t
|
||||
}
|
||||
|
||||
is LinkageError -> {
|
||||
is VirtualMachineError, is ThreadDeath, is LinkageError -> {
|
||||
throw t
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user