Refine rust jni parseLimit
This commit is contained in:
1 parent
b7d2e4e5da
commit
1e47170c3b
4 files changed
+30
-20
No files matched your search
@@ -36,6 +36,7 @@ import com.hippo.ehviewer.client.parser.GalleryPageApiParser
|
||||
import com.hippo.ehviewer.client.parser.GalleryPageParser
|
||||
import com.hippo.ehviewer.client.parser.GalleryTokenApiParser
|
||||
import com.hippo.ehviewer.client.parser.HomeParser
|
||||
import com.hippo.ehviewer.client.parser.Limits
|
||||
import com.hippo.ehviewer.client.parser.ProfileParser
|
||||
import com.hippo.ehviewer.client.parser.RateGalleryParser
|
||||
import com.hippo.ehviewer.client.parser.SignInParser
|
||||
@@ -301,7 +302,7 @@ object EhEngine {
|
||||
return null
|
||||
}
|
||||
|
||||
suspend fun resetImageLimits(): HomeParser.Limits? {
|
||||
suspend fun resetImageLimits(): Limits? {
|
||||
return ehRequest(EhUrl.URL_HOME) {
|
||||
formBody {
|
||||
add("act", "limits")
|
||||
|
||||
@@ -8,11 +8,7 @@ object HomeParser {
|
||||
private val PATTERN_FUNDS = Regex("Available: ([\\d,]+) Credits.*Available: ([\\d,]+) kGP", RegexOption.DOT_MATCHES_ALL)
|
||||
private const val RESET_SUCCEED = "Image limit was successfully reset."
|
||||
|
||||
fun parse(body: String): Limits {
|
||||
val value = parseLimit(body)
|
||||
if (value.isEmpty()) throw ParseException("Parse image limits error", body)
|
||||
return Limits(value[0], value[1], value[2])
|
||||
}
|
||||
fun parse(body: String) = parseLimit(body)
|
||||
|
||||
fun parseResetLimits(body: String): Limits? {
|
||||
return if (body.contains(RESET_SUCCEED)) {
|
||||
@@ -31,12 +27,12 @@ object HomeParser {
|
||||
throw ParseException("Parse funds error", body)
|
||||
}
|
||||
|
||||
@Parcelize
|
||||
data class Limits(val current: Int = 0, val maximum: Int = 0, val resetCost: Int = 0) : Parcelable
|
||||
|
||||
@Parcelize
|
||||
data class Funds(val fundsGP: Int, val fundsC: Int) : Parcelable
|
||||
class Result(val limits: Limits, val funds: Funds)
|
||||
}
|
||||
|
||||
private external fun parseLimit(body: String): IntArray
|
||||
@Parcelize
|
||||
data class Limits(val current: Int, val maximum: Int, val resetCost: Int) : Parcelable
|
||||
|
||||
private external fun parseLimit(body: String): Limits
|
||||
Reference in new issue
Block a user