Skip to content

Commit

Permalink
Happymh: use hashmap instead
Browse files Browse the repository at this point in the history
LruCache is stub in the inspector
  • Loading branch information
AwkwardPeak7 committed Dec 25, 2024
1 parent d93695a commit f15e50a
Showing 1 changed file with 3 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package eu.kanade.tachiyomi.extension.zh.happymh

import android.app.Application
import android.util.LruCache
import android.widget.Toast
import androidx.preference.EditTextPreference
import androidx.preference.PreferenceScreen
Expand Down Expand Up @@ -44,7 +43,7 @@ class Happymh : HttpSource(), ConfigurableSource {

override val baseUrl: String = "https://m.happymh.com"
private val json: Json by injectLazy()
private val chapterUrlToCode = LruCache<String, String>(10000)
private val chapterUrlToCode = hashMapOf<String, String>()

private val preferences = Injekt.get<Application>().getSharedPreferences("source_$id", 0x0000)

Expand Down Expand Up @@ -210,7 +209,7 @@ class Happymh : HttpSource(), ConfigurableSource {
override fun chapterListParse(response: Response) = throw UnsupportedOperationException()

override fun getChapterUrl(chapter: SChapter): String {
return baseUrl + (chapterUrlToCode.get(chapter.url)?.let { "/mangaread/$it" } ?: chapter.url)
return baseUrl + (chapterUrlToCode[chapter.url]?.let { "/mangaread/$it" } ?: chapter.url)
}

// Pages
Expand All @@ -232,7 +231,7 @@ class Happymh : HttpSource(), ConfigurableSource {
page += 1
}
}
return code?.also { chapterUrlToCode.put(chapter.url, it) }
return code?.also { chapterUrlToCode[chapter.url] = it }
}

override fun pageListRequest(chapter: SChapter): Request {
Expand Down

0 comments on commit f15e50a

Please sign in to comment.