Skip to content

Commit

Permalink
[fix]更改自定义数据源例示代码,有新版本Jar包;更改theme.xml名为theme_skin.xml;修复获取更新时间早8小时的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
SkyD666 committed Sep 13, 2021
1 parent 0ff75ac commit 466000c
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 10 deletions.
5 changes: 2 additions & 3 deletions app/src/main/java/com/skyd/imomoe/model/DataSourceManager.kt
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,10 @@ package com.skyd.imomoe.model
import android.util.Log
import android.util.LruCache
import com.skyd.imomoe.App
import com.skyd.imomoe.R
import com.skyd.imomoe.BuildConfig
import com.skyd.imomoe.model.interfaces.IConst
import com.skyd.imomoe.model.interfaces.IRouteProcessor
import com.skyd.imomoe.model.interfaces.IUtil
import com.skyd.imomoe.util.Util.showToastOnIOThread
import com.skyd.imomoe.util.editor
import com.skyd.imomoe.util.sharedPreferences
import dalvik.system.DexClassLoader
Expand Down Expand Up @@ -91,7 +90,7 @@ object DataSourceManager {
val jarFile = File(getJarPath())
if (!jarFile.exists() || !jarFile.isFile) {
Log.e("DataSourceManager", "useCustomDataSource but jar doesn't exist")
return null
if (!BuildConfig.DEBUG) return null
}
val optimizedDirectory =
File(App.context.getExternalFilesDir(null).toString() + "/DataSourceDex")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class AppUpdateHelper private constructor() {
try {
val format =
SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.getDefault())
format.timeZone = TimeZone.getTimeZone("UTC")
val date = format.parse(updatedAt)
val s: String = if (date != null) {
SimpleDateFormat("yyyy-MM-dd HH:mm", Locale.getDefault()).format(date)
Expand Down
9 changes: 9 additions & 0 deletions app/src/main/res/values-night/colors.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="widget_everyday_anime_header_background_color">#000000</color>
<color name="widget_everyday_anime_body_background_color">#000000</color>
<color name="widget_everyday_anime_refresh_color">#B5B5B5</color>
<color name="widget_everyday_anime_title_color">#B5B5B5</color>
<color name="widget_everyday_anime_item_text_color">#B5B5B5</color>

</resources>
File renamed without changes.
2 changes: 1 addition & 1 deletion doc/customdatasource/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ kotlinx.**

数据源:https://www.yhdmp.net

详细代码和Jar包见下方链接内容。注:此Jar包可直接放入手机相应文件夹(步骤7)供APP使用。
详细代码和Jar包见下方链接内容。注:此Jar包可直接放入手机相应文件夹(步骤7)供APP使用。**请自行在此仓库检查Jar包更新**

[自定义数据源示例代码和Jar包](sample/custom)

Expand Down
4 changes: 2 additions & 2 deletions doc/customdatasource/sample/custom/CustomConst.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ class CustomConst : IConst {

override fun MAIN_URL(): String = "https://www.yhdmp.net"

override fun versionName(): String = "1.0.0"
override fun versionName(): String = "1.0.1"

override fun versionCode(): Int = 1
override fun versionCode(): Int = 2

override fun about(): String {
return "数据来源:${MAIN_URL()}"
Expand Down
Binary file modified doc/customdatasource/sample/custom/CustomDataSource.jar
Binary file not shown.
26 changes: 22 additions & 4 deletions doc/customdatasource/sample/custom/CustomPlayModel.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import kotlinx.coroutines.suspendCancellableCoroutine
import org.jsoup.Jsoup
import org.jsoup.select.Elements
import java.lang.ref.SoftReference
import java.net.URLDecoder
import kotlin.coroutines.resume
import kotlin.coroutines.resumeWithException

Expand Down Expand Up @@ -61,7 +62,7 @@ class CustomPlayModel : IPlayModel {
GettingUtil.instance.activity(activity)
.url(url).start(object : GettingCallback {
override fun onGettingSuccess(webView: View?, html: String) {
GettingUtil.instance.release()
GettingUtil.instance.release()
val document = Jsoup.parse(html)
val children: Elements = document.body().children()
for (i in children.indices) {
Expand All @@ -70,7 +71,22 @@ class CustomPlayModel : IPlayModel {
var iframeSrc = children[i]
.select("[class=bofang]")
.select("iframe")[0].attr("src")
if (iframeSrc.startsWith("/")) iframeSrc =
if (iframeSrc.startsWith("/yxsf/player/ckx1")) {
val videoUrl = URLDecoder.decode(
iframeSrc.substringAfter("url=")
.substringBefore("&"), "UTF-8"
)
animeEpisodeDataBean.videoUrl = videoUrl
resultVideoUrl = true
if (resultData) cancellableContinuation.resume(
Triple(
playBeanDataList,
episodesList,
playBean
)
)
continue
} else if (iframeSrc.startsWith("/")) iframeSrc =
MAIN_URL + iframeSrc
getVideoUrl(iframeSrc, object : GettingCallback {
override fun onGettingSuccess(
Expand Down Expand Up @@ -230,7 +246,7 @@ class CustomPlayModel : IPlayModel {
GettingUtil.instance.activity(activity)
.url(url).start(object : GettingCallback {
override fun onGettingSuccess(webView: View?, html: String) {
GettingUtil.instance.release()
GettingUtil.instance.release()
val document = Jsoup.parse(html)
val children: Elements = document.body().children()
for (i in children.indices) {
Expand Down Expand Up @@ -348,7 +364,9 @@ class CustomPlayModel : IPlayModel {
webView: View?, url: String?, errorCode: Int
) {
GettingUtil.instance.release()
cancellableContinuation.resumeWithException(Exception("onGettingError,url:$url,errorCode:$errorCode"))
cancellableContinuation.resumeWithException(
Exception("onGettingError,url:$url,errorCode:$errorCode")
)
}

})
Expand Down

0 comments on commit 466000c

Please sign in to comment.