@@ -72,17 +72,22 @@ class SplashActivity : BaseActivity() {
7272 GSON .fromJson<ArrayMap <String , String >>(it)
7373 }
7474 val urlsFromUpdateCache =
75- Flowable .concat(CacheLoader .justLru(C .Cache .ANNOUNCE_URL ), GitHub .INSTANCE .announce())
75+ Flowable .concat(
76+ CacheLoader .justLru(C .Cache .ANNOUNCE_URL ),
77+ GitHub .INSTANCE .announce()
78+ )
7679 .firstOrError().toFlowable()
7780 .map { source ->
7881 // 放入内存缓存,更新需要
7982 val r = GSON .fromJson<JsonObject >(source) ? : JsonObject ()
8083 CacheLoader .cacheLru(C .Cache .ANNOUNCE_VALUE to r)
8184 arrayMapof<String , String >().apply {
8285 val xyzLoader = r.getAsJsonObject(" xyzLoader" ) ? : JsonObject ()
83- JAVBusService .defaultXyzUrl = xyzLoader.get(" url" )?.asString?.removeSuffix(" /" ).orEmpty()
84- JAVBusService .xyzHostDomains.addAll(xyzLoader.getAsJsonArray(" legacyHost" )?.map { it.asString }
85- ? : emptyList())
86+ JAVBusService .defaultXyzUrl =
87+ xyzLoader.get(" url" )?.asString?.removeSuffix(" /" ).orEmpty()
88+ JAVBusService .xyzHostDomains.addAll(
89+ xyzLoader.getAsJsonArray(" legacyHost" )?.map { it.asString }
90+ ? : emptyList())
8691 val availableUrls = r.get(" backUp" )?.asJsonArray
8792 // 赋值一个默认的(随机)
8893 availableUrls?.let {
@@ -98,8 +103,7 @@ class SplashActivity : BaseActivity() {
98103 .flatMap {
99104 urls = it
100105 val mapFlow = GSON .fromJson<List <String >>(
101- it[DataSourceType .CENSORED .key]
102- ? : " "
106+ it[DataSourceType .CENSORED .key].orEmpty()
103107 ).map {
104108 Flowable .combineLatest(Flowable .just<String >(it),
105109 JAVBusService .INSTANCE .get(it).addUserCase(15 ).onErrorReturnItem(" " ),
@@ -110,7 +114,8 @@ class SplashActivity : BaseActivity() {
110114 .firstOrError()
111115 .doOnError { CacheLoader .acache.remove(C .Cache .ANNOUNCE_URL ) }
112116 .map {
113- val ds = DataSourceType .values().takeLast(DataSourceType .values().size - 1 ).toMutableList()
117+ val ds = DataSourceType .values().takeLast(DataSourceType .values().size - 1 )
118+ .toMutableList()
114119 Jsoup .parse(it.second).select(" .navbar-nav a" ).forEach { box ->
115120 ds.find { box.text() == it.key }?.let {
116121 ds.remove(it)
@@ -121,7 +126,7 @@ class SplashActivity : BaseActivity() {
121126 urls[DataSourceType .XYZ .key]?.let {
122127 // 欧美
123128 urls[DataSourceType .XYZ_ACTRESSES .key] =
124- " $it /${DataSourceType .XYZ_ACTRESSES .key.split(" /" ).last()} "
129+ " $it /${DataSourceType .XYZ_ACTRESSES .key.split(" /" ).last()} "
125130 urls.put(
126131 DataSourceType .XYZ_GENRE .key,
127132 " $it /${DataSourceType .XYZ_GENRE .key.split(" /" ).last()} "
@@ -132,20 +137,30 @@ class SplashActivity : BaseActivity() {
132137 // change xyz
133138 if (JAVBusService .defaultXyzUrl.isNotBlank()) {
134139 urls[DataSourceType .XYZ .key] = JAVBusService .defaultXyzUrl
135- urls[DataSourceType .XYZ_ACTRESSES .key] = " ${JAVBusService .defaultXyzUrl} /actresses"
136- urls[DataSourceType .XYZ_GENRE .key] = " ${JAVBusService .defaultXyzUrl} /genre"
140+ urls[DataSourceType .XYZ_ACTRESSES .key] =
141+ " ${JAVBusService .defaultXyzUrl} /actresses"
142+ urls[DataSourceType .XYZ_GENRE .key] =
143+ " ${JAVBusService .defaultXyzUrl} /genre"
137144 } else {
138145 val host = JAVBusService .xyzHostDomains.firstOrNull() ? : " work"
139- val baseUrlSuffix = urls[DataSourceType .XYZ .key]?.substringAfterLast(" ." ).orEmpty()
140- urls[DataSourceType .XYZ .key] = urls[DataSourceType .XYZ .key]?.replace(baseUrlSuffix, host)
146+ val baseUrlSuffix =
147+ urls[DataSourceType .XYZ .key]?.substringAfterLast(" ." ).orEmpty()
148+ urls[DataSourceType .XYZ .key] =
149+ urls[DataSourceType .XYZ .key]?.replace(baseUrlSuffix, host)
141150 urls[DataSourceType .XYZ_ACTRESSES .key] =
142- urls[DataSourceType .XYZ_ACTRESSES .key]?.replace(baseUrlSuffix, host)
151+ urls[DataSourceType .XYZ_ACTRESSES .key]?.replace(baseUrlSuffix, host)
143152 urls[DataSourceType .XYZ_GENRE .key] =
144- urls[DataSourceType .XYZ_GENRE .key]?.replace(baseUrlSuffix, host)
153+ urls[DataSourceType .XYZ_GENRE .key]?.replace(baseUrlSuffix, host)
145154 }
146155
147- CacheLoader .cacheLruAndDisk(C .Cache .BUS_URLS to urls, C .Cache .DAY * 2 ) // 缓存所有的urls
148- CacheLoader .lru.put(DataSourceType .CENSORED .key + " false" , it.second) // 默认有种的
156+ CacheLoader .cacheLruAndDisk(
157+ C .Cache .BUS_URLS to urls,
158+ C .Cache .DAY * 2
159+ ) // 缓存所有的urls
160+ CacheLoader .lru.put(
161+ DataSourceType .CENSORED .key + " false" ,
162+ it.second
163+ ) // 默认有种的
149164 KLog .d(" init urls second :$urls " )
150165 urls
151166 }.toFlowable()
0 commit comments