diff --git a/app/src/main/java/io/legado/app/model/WebBook.kt b/app/src/main/java/io/legado/app/model/WebBook.kt index 9eff0082e..012e9ead7 100644 --- a/app/src/main/java/io/legado/app/model/WebBook.kt +++ b/app/src/main/java/io/legado/app/model/WebBook.kt @@ -180,7 +180,11 @@ class WebBook(val bookSource: BookSource) { headerMapF = bookSource.getHeaderMap() ) if (analyzeUrl.useWebView) { - analyzeUrl.getResultByWebView(bookSource.bookSourceUrl).content + analyzeUrl.getResultByWebView( + bookSource.bookSourceUrl, + jsStr = bookSource.getContentRule().webJs, + sourceRegex = bookSource.getContentRule().sourceRegex + ).content } else { analyzeUrl.getResponseAwait().body() } diff --git a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt index f32e41549..a72ef70ec 100644 --- a/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt +++ b/app/src/main/java/io/legado/app/model/analyzeRule/AnalyzeUrl.kt @@ -175,10 +175,12 @@ class AnalyzeUrl( } when (method) { RequestMethod.GET -> { - urlArray = url.split("?") - url = urlArray[0] - if (urlArray.size > 1) { - analyzeFields(urlArray[1]) + if (!useWebView) { + urlArray = url.split("?") + url = urlArray[0] + if (urlArray.size > 1) { + analyzeFields(urlArray[1]) + } } } RequestMethod.POST -> { diff --git a/app/src/main/java/io/legado/app/service/help/AudioPlay.kt b/app/src/main/java/io/legado/app/service/help/AudioPlay.kt index 10d6d6026..2ae666206 100644 --- a/app/src/main/java/io/legado/app/service/help/AudioPlay.kt +++ b/app/src/main/java/io/legado/app/service/help/AudioPlay.kt @@ -2,10 +2,24 @@ package io.legado.app.service.help import android.content.Context import android.content.Intent +import androidx.lifecycle.MutableLiveData import io.legado.app.constant.Action +import io.legado.app.data.entities.Book +import io.legado.app.model.WebBook import io.legado.app.service.AudioPlayService +import io.legado.app.ui.audio.AudioPlayViewModel object AudioPlay { + var titleData = MutableLiveData() + var coverData = MutableLiveData() + var book: Book? = null + var inBookshelf = false + var chapterSize = 0 + var callBack: AudioPlayViewModel.CallBack? = null + var durChapterIndex = 0 + var durPageIndex = 0 + var webBook: WebBook? = null + val loadingChapters = arrayListOf() fun play(context: Context, title: String?, subtitle: String, url: String, position: Int) { val intent = Intent(context, AudioPlayService::class.java) diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt index b0677197b..4214a0016 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayActivity.kt @@ -47,9 +47,8 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a override fun onActivityCreated(savedInstanceState: Bundle?) { setSupportActionBar(toolbar) - viewModel.callBack = this - viewModel.titleData.observe(this, Observer { title_bar.title = it }) - viewModel.coverData.observe(this, Observer { upCover(it) }) + AudioPlay.titleData.observe(this, Observer { title_bar.title = it }) + AudioPlay.coverData.observe(this, Observer { upCover(it) }) viewModel.initData(intent) initView() } @@ -83,7 +82,7 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a } }) iv_chapter.onClick { - viewModel.book?.let { + AudioPlay.book?.let { startActivityForResult( requestCodeChapter, Pair("bookUrl", it.bookUrl) @@ -114,27 +113,27 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a when (status) { Status.PLAY -> AudioPlay.pause(this) Status.PAUSE -> AudioPlay.resume(this) - else -> viewModel.loadContent(viewModel.durChapterIndex) + else -> viewModel.loadContent(AudioPlay.durChapterIndex) } } override fun contentLoadFinish(bookChapter: BookChapter, content: String) { AudioPlay.play( this, - viewModel.book?.name, + AudioPlay.book?.name, bookChapter.title, content, - viewModel.durPageIndex + AudioPlay.durPageIndex ) - viewModel.loadContent(viewModel.durChapterIndex + 1) + viewModel.loadContent(AudioPlay.durChapterIndex + 1) } override fun finish() { - viewModel.book?.let { - if (!viewModel.inBookshelf) { + AudioPlay.book?.let { + if (!AudioPlay.inBookshelf) { this.alert(title = getString(R.string.add_to_shelf)) { message = getString(R.string.check_add_bookshelf, it.name) - okButton { viewModel.inBookshelf = true } + okButton { AudioPlay.inBookshelf = true } noButton { viewModel.removeFromBookshelf { super.finish() } } }.show().applyTint() } else { @@ -159,8 +158,8 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a super.onActivityResult(requestCode, resultCode, data) if (resultCode == Activity.RESULT_OK) { when (requestCode) { - requestCodeChapter -> data?.getIntExtra("index", viewModel.durChapterIndex)?.let { - if (it != viewModel.durChapterIndex) { + requestCodeChapter -> data?.getIntExtra("index", AudioPlay.durChapterIndex)?.let { + if (it != AudioPlay.durChapterIndex) { viewModel.loadContent(it) } } @@ -184,7 +183,7 @@ class AudioPlayActivity : VMBaseActivity(R.layout.activity_a } } observeEventSticky(Bus.AUDIO_PROGRESS) { - viewModel.durPageIndex = it + AudioPlay.durPageIndex = it if (!adjustProgress) player_progress.progress = it tv_dur_time.text = DateFormatUtils.format(it.toLong(), "mm:ss") viewModel.saveProgress() diff --git a/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt b/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt index 191c03d1d..bb4e8884b 100644 --- a/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt +++ b/app/src/main/java/io/legado/app/ui/audio/AudioPlayViewModel.kt @@ -2,7 +2,6 @@ package io.legado.app.ui.audio import android.app.Application import android.content.Intent -import androidx.lifecycle.MutableLiveData import io.legado.app.App import io.legado.app.R import io.legado.app.base.BaseViewModel @@ -11,20 +10,20 @@ import io.legado.app.data.entities.BookChapter import io.legado.app.help.BookHelp import io.legado.app.model.WebBook import io.legado.app.service.help.AudioPlay +import io.legado.app.service.help.AudioPlay.book +import io.legado.app.service.help.AudioPlay.callBack +import io.legado.app.service.help.AudioPlay.chapterSize +import io.legado.app.service.help.AudioPlay.coverData +import io.legado.app.service.help.AudioPlay.durChapterIndex +import io.legado.app.service.help.AudioPlay.durPageIndex +import io.legado.app.service.help.AudioPlay.inBookshelf +import io.legado.app.service.help.AudioPlay.loadingChapters +import io.legado.app.service.help.AudioPlay.titleData +import io.legado.app.service.help.AudioPlay.webBook import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.withContext class AudioPlayViewModel(application: Application) : BaseViewModel(application) { - var titleData = MutableLiveData() - var coverData = MutableLiveData() - var book: Book? = null - var inBookshelf = false - private var chapterSize = 0 - var callBack: CallBack? = null - var durChapterIndex = 0 - var durPageIndex = 0 - var webBook: WebBook? = null - private val loadingChapters = arrayListOf() fun initData(intent: Intent) { execute {