-
Notifications
You must be signed in to change notification settings - Fork 203
Expand file tree
/
Copy pathCustomEverydayAnimeWidgetModel.kt
More file actions
44 lines (42 loc) · 1.86 KB
/
CustomEverydayAnimeWidgetModel.kt
File metadata and controls
44 lines (42 loc) · 1.86 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package com.skyd.imomoe.model.impls.custom
import com.skyd.imomoe.bean.*
import com.skyd.imomoe.config.Api
import com.skyd.imomoe.model.util.JsoupUtil
import com.skyd.imomoe.model.interfaces.IEverydayAnimeWidgetModel
import org.jsoup.select.Elements
class CustomEverydayAnimeWidgetModel : IEverydayAnimeWidgetModel {
override fun getEverydayAnimeData(): ArrayList<List<AnimeCoverBean>> {
val list: ArrayList<List<AnimeCoverBean>> = ArrayList()
try {
val document = JsoupUtil.getDocument(Api.MAIN_URL)
val areaChildren: Elements = document.select("[class=area]")[0].children()
for (i in areaChildren.indices) {
when (areaChildren[i].className()) {
"side r" -> {
val sideRChildren = areaChildren[i].children()
out@ for (j in sideRChildren.indices) {
when (sideRChildren[j].className()) {
"bg" -> {
val bgChildren = sideRChildren[j].children()
for (k in bgChildren.indices) {
when (bgChildren[k].className()) {
"tlist" -> {
list.addAll(
CustomParseHtmlUtil.parseTlist(bgChildren[k])
)
}
}
}
break@out
}
}
}
}
}
}
} catch (e: Exception) {
e.printStackTrace()
}
return list
}
}