Prepare to drop UrlBuilder
This commit is contained in:
1 parent
fd05d03bca
commit
eb18e74884
4 files changed
+10
-7
No files matched your search
@@ -17,6 +17,7 @@ package com.hippo.ehviewer.client
|
||||
|
||||
import com.hippo.ehviewer.Settings
|
||||
import com.hippo.ehviewer.network.UrlBuilder
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
|
||||
object EhUrl {
|
||||
const val SITE_E = 0
|
||||
@@ -127,7 +128,7 @@ object EhUrl {
|
||||
}
|
||||
|
||||
fun getGalleryDetailUrl(gid: Long, token: String?, index: Int, allComment: Boolean): String {
|
||||
val builder = UrlBuilder(host + "g/" + gid + '/' + token + '/')
|
||||
val builder = UrlBuilder((host + "g/" + gid + '/' + token + '/').toHttpUrl().newBuilder())
|
||||
if (index != 0) {
|
||||
builder.addQuery("p", index)
|
||||
}
|
||||
@@ -138,7 +139,7 @@ object EhUrl {
|
||||
}
|
||||
|
||||
fun getGalleryMultiPageViewerUrl(gid: Long, token: String): String {
|
||||
val builder = UrlBuilder(host + "mpv/" + gid + '/' + token + '/')
|
||||
val builder = UrlBuilder((host + "mpv/" + gid + '/' + token + '/').toHttpUrl().newBuilder())
|
||||
return builder.build()
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import com.hippo.ehviewer.client.EhUrl
|
||||
import com.hippo.ehviewer.network.UrlBuilder
|
||||
import com.hippo.ehviewer.util.encodeUTF8
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
|
||||
@Parcelize
|
||||
class FavListUrlBuilder(
|
||||
@@ -35,7 +36,7 @@ class FavListUrlBuilder(
|
||||
}
|
||||
|
||||
fun build(): String {
|
||||
val ub = UrlBuilder(EhUrl.favoritesUrl)
|
||||
val ub = UrlBuilder(EhUrl.favoritesUrl.toHttpUrl().newBuilder())
|
||||
if (isValidFavCat(favCat)) {
|
||||
ub.addQuery("favcat", favCat.toString())
|
||||
} else if (favCat == FAV_CAT_ALL) {
|
||||
|
||||
@@ -25,6 +25,7 @@ import com.hippo.ehviewer.ui.legacy.AdvanceSearchTable
|
||||
import com.hippo.ehviewer.util.encodeUTF8
|
||||
import com.hippo.ehviewer.yorozuya.toIntOrDefault
|
||||
import kotlinx.parcelize.Parcelize
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import java.io.UnsupportedEncodingException
|
||||
import java.net.URLDecoder
|
||||
|
||||
@@ -276,7 +277,7 @@ data class ListUrlBuilder(
|
||||
} else {
|
||||
EhUrl.watchedUrl
|
||||
}
|
||||
val ub = UrlBuilder(url)
|
||||
val ub = UrlBuilder(url.toHttpUrl().newBuilder())
|
||||
if (this.category != EhUtils.NONE) {
|
||||
ub.addQuery("f_cats", category.inv() and EhUtils.ALL_CATEGORY)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.hippo.ehviewer.network
|
||||
|
||||
import okhttp3.HttpUrl.Companion.toHttpUrl
|
||||
import okhttp3.HttpUrl
|
||||
|
||||
class UrlBuilder(mRootUrl: String) {
|
||||
private val url = mRootUrl.toHttpUrl().newBuilder()
|
||||
@JvmInline
|
||||
value class UrlBuilder(val url: HttpUrl.Builder) {
|
||||
fun addQuery(key: String, value: Any) {
|
||||
url.addEncodedQueryParameter(key, value.toString())
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user