Merge pull request #978 from ag2s20150909/master

Paging库回退稳定版&&修复一些过时方法
This commit is contained in:
kunfei 2021-05-08 09:19:58 +08:00 committed by GitHub
commit 9353b53f80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 35 additions and 78 deletions

View File

@ -158,7 +158,7 @@ dependencies {
testImplementation "androidx.room:room-testing:$room_version"
//paging
implementation 'androidx.paging:paging-runtime-ktx:3.0.0'
implementation 'androidx.paging:paging-runtime-ktx:2.1.2'
//liveEventBus
implementation 'com.jeremyliao:live-event-bus-x:1.5.7'

View File

@ -54,6 +54,7 @@ abstract class BasePreferenceFragment : PreferenceFragmentCompat() {
}
}
f.setTargetFragment(this, 0)
f.show(parentFragmentManager, dialogFragmentTag)
}

View File

@ -51,7 +51,7 @@ object RssParserByRule {
Debug.log(sourceUrl, "└列表大小:${collections.size}")
if (!rssSource.ruleNextPage.isNullOrEmpty()) {
Debug.log(sourceUrl, "┌获取下一页链接")
if (rssSource.ruleNextPage!!.toUpperCase(Locale.getDefault()) == "PAGE") {
if (rssSource.ruleNextPage!!.uppercase(Locale.getDefault()) == "PAGE") {
nextUrl = sortUrl
} else {
nextUrl = analyzeRule.getString(rssSource.ruleNextPage)

View File

@ -141,7 +141,7 @@ class FontSelectDialog : BaseDialogFragment(),
val fontDir =
FileUtils.createFolderIfNotExist(requireContext().externalFilesDir, "font")
fontDir.listFiles { pathName ->
pathName.name.toLowerCase(Locale.getDefault()).matches(fontRegex)
pathName.name.lowercase(Locale.getDefault()).matches(fontRegex)
}?.forEach {
fontItems.add(
DocItem(
@ -161,7 +161,7 @@ class FontSelectDialog : BaseDialogFragment(),
val fontItems = arrayListOf<DocItem>()
val docItems = DocumentUtils.listFiles(appCtx, doc.uri)
docItems.forEach { item ->
if (item.name.toLowerCase(Locale.getDefault()).matches(fontRegex)) {
if (item.name.lowercase(Locale.getDefault()).matches(fontRegex)) {
fontItems.add(item)
}
}
@ -188,7 +188,7 @@ class FontSelectDialog : BaseDialogFragment(),
val fontItems = arrayListOf<DocItem>()
val file = File(path)
file.listFiles { pathName ->
pathName.name.toLowerCase(Locale.getDefault()).matches(fontRegex)
pathName.name.lowercase(Locale.getDefault()).matches(fontRegex)
}?.forEach {
fontItems.add(
DocItem(

View File

@ -525,7 +525,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
}
fun hasDateInfo(data: ByteArray?): Boolean {
return (data != null && data.size > 15 && data[13] == '-'.toByte()
return (data != null && data.size > 15 && data[13] == '-'.code.toByte()
&& indexOf(data, mSeparator) > 14)
}
@ -546,7 +546,7 @@ class ACache private constructor(cacheDir: File, max_size: Long, max_count: Int)
@Suppress("SameParameterValue")
private fun indexOf(data: ByteArray, c: Char): Int {
for (i in data.indices) {
if (data[i] == c.toByte()) {
if (data[i] == c.code.toByte()) {
return i
}
}

View File

@ -28,7 +28,6 @@ object BitmapUtils {
*/
fun decodeBitmap(path: String, width: Int, height: Int): Bitmap? {
val op = BitmapFactory.Options()
op.inPreferredConfig = Config.RGB_565
val ips = FileInputStream(path)
// inJustDecodeBounds如果设置为true,仅仅返回图片实际的宽和高,宽和高是赋值给opts.outWidth,opts.outHeight;
op.inJustDecodeBounds = true
@ -56,7 +55,6 @@ object BitmapUtils {
fun decodeBitmap(path: String): Bitmap? {
val opts = BitmapFactory.Options()
opts.inPreferredConfig = Config.RGB_565
val ips = FileInputStream(path)
opts.inJustDecodeBounds = true
BitmapFactory.decodeFileDescriptor(ips.fd,null,opts)

View File

@ -12,7 +12,7 @@ object EncoderUtils {
fun escape(src: String): String {
val tmp = StringBuilder()
for (char in src) {
val charCode = char.toInt()
val charCode = char.code
if (charCode in 48..57 || charCode in 65..90 || charCode in 97..122) {
tmp.append(char)
continue

View File

@ -26,14 +26,14 @@ object EncodingDetect {
}
val content = metaTag.attr("content")
val httpEquiv = metaTag.attr("http-equiv")
if (httpEquiv.toLowerCase(Locale.getDefault()) == "content-type") {
charsetStr = if (content.toLowerCase(Locale.getDefault()).contains("charset")) {
if (httpEquiv.lowercase(Locale.getDefault()) == "content-type") {
charsetStr = if (content.lowercase(Locale.getDefault()).contains("charset")) {
content.substring(
content.toLowerCase(Locale.getDefault())
content.lowercase(Locale.getDefault())
.indexOf("charset") + "charset=".length
)
} else {
content.substring(content.toLowerCase(Locale.getDefault()).indexOf(";") + 1)
content.substring(content.lowercase(Locale.getDefault()).indexOf(";") + 1)
}
if (!TextUtils.isEmpty(charsetStr)) {
return charsetStr

View File

@ -12,17 +12,17 @@ object NetworkUtils {
private val notNeedEncoding: BitSet by lazy {
val bitSet = BitSet(256)
for (i in 'a'.toInt()..'z'.toInt()) {
for (i in 'a'.code..'z'.code) {
bitSet.set(i)
}
for (i in 'A'.toInt()..'Z'.toInt()) {
for (i in 'A'.code..'Z'.code) {
bitSet.set(i)
}
for (i in '0'.toInt()..'9'.toInt()) {
for (i in '0'.code..'9'.code) {
bitSet.set(i)
}
for (char in "+-_.$:()!*@&#,[]") {
bitSet.set(char.toInt())
bitSet.set(char.code)
}
return@lazy bitSet
}
@ -38,7 +38,7 @@ object NetworkUtils {
var i = 0
while (i < str.length) {
val c = str[i]
if (notNeedEncoding.get(c.toInt())) {
if (notNeedEncoding.get(c.code)) {
i++
continue
}

View File

@ -114,7 +114,7 @@ object StringUtils {
@SuppressLint("DefaultLocale")
fun toFirstCapital(str: String): String {
return str.substring(0, 1).toUpperCase() + str.substring(1)
return str.substring(0, 1).uppercase(Locale.getDefault()) + str.substring(1)
}
/**
@ -123,7 +123,7 @@ object StringUtils {
fun halfToFull(input: String): String {
val c = input.toCharArray()
for (i in c.indices) {
if (c[i].toInt() == 32)
if (c[i].code == 32)
//半角空格
{
c[i] = 12288.toChar()
@ -133,9 +133,9 @@ object StringUtils {
//if (c[i] == 46) //半角点号,不转换
// continue;
if (c[i].toInt() in 33..126)
if (c[i].code in 33..126)
//其他符号都转换为全角
c[i] = (c[i].toInt() + 65248).toChar()
c[i] = (c[i].code + 65248).toChar()
}
return String(c)
}
@ -144,15 +144,15 @@ object StringUtils {
fun fullToHalf(input: String): String {
val c = input.toCharArray()
for (i in c.indices) {
if (c[i].toInt() == 12288)
if (c[i].code == 12288)
//全角空格
{
c[i] = 32.toChar()
continue
}
if (c[i].toInt() in 65281..65374)
c[i] = (c[i].toInt() - 65248).toChar()
if (c[i].code in 65281..65374)
c[i] = (c[i].code - 65248).toChar()
}
return String(c)
}
@ -255,10 +255,10 @@ object StringUtils {
var start = 0
val len = s.length
var end = len - 1
while (start < end && (s[start].toInt() <= 0x20 || s[start] == ' ')) {
while (start < end && (s[start].code <= 0x20 || s[start] == ' ')) {
++start
}
while (start < end && (s[end].toInt() <= 0x20 || s[end] == ' ')) {
while (start < end && (s[end].code <= 0x20 || s[end] == ' ')) {
--end
}
if (end < len) ++end

View File

@ -5,7 +5,8 @@
android:viewportWidth="1112"
android:viewportHeight="1024">
<path android:fillColor="#595757"
android:pathData="M385.722775 1023.999431a42.664285 42.664285 0 0 1-42.664285-42.664284V138.573312L72.851354 381.190877a42.664285 42.664285 0 1 1-56.885712-63.42757L357.279918 10.864887A42.664285 42.664285 0 0 1 428.387059 42.720886v938.614261a42.664285 42.664285 0 0 1-42.664284 42.664284zM727.037051 1023.999431a41.52657 41.52657 0 0 1-17.350142-3.697571A42.664285 42.664285 0 0 1 684.372767 981.335147v-938.614261a42.664285 42.664285 0 0 1 85.328569 0v842.761835l270.207135-242.617565a42.664285 42.664285 0 1 1 56.885713 63.427569l-341.314276 306.898421a42.664285 42.664285 0 0 1-28.442857 10.808285z"></path>
<path
android:fillColor="#595757"
android:pathData="M385.722775 1023.999431a42.664285 42.664285 0 0 1-42.664285-42.664284V138.573312L72.851354 381.190877a42.664285 42.664285 0 1 1-56.885712-63.42757L357.279918 10.864887A42.664285 42.664285 0 0 1 428.387059 42.720886v938.614261a42.664285 42.664285 0 0 1-42.664284 42.664284zM727.037051 1023.999431a41.52657 41.52657 0 0 1-17.350142-3.697571A42.664285 42.664285 0 0 1 684.372767 981.335147v-938.614261a42.664285 42.664285 0 0 1 85.328569 0v842.761835l270.207135-242.617565a42.664285 42.664285 0 1 1 56.885713 63.427569l-341.314276 306.898421a42.664285 42.664285 0 0 1-28.442857 10.808285z" />
</vector>

View File

@ -4,7 +4,7 @@ buildscript {
ext.kotlin_version = '1.5.0'
repositories {
google()
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
maven { url 'https://maven.aliyun.com/repository/public/'}
maven { url "https://s3.amazonaws.com/fabric-artifacts/public" }
maven { url "https://maven.aliyun.com/repository/gradle-plugin" }
maven { url "https://plugins.gradle.org/m2/" }
@ -19,7 +19,7 @@ buildscript {
allprojects {
repositories {
google()
maven { url "https://maven.aliyun.com/nexus/content/groups/public/" }
maven { url 'https://maven.aliyun.com/repository/public/'}
maven { url "https://jitpack.io" }
maven { url "https://maven.google.com/" }
}

View File

@ -1,26 +0,0 @@
package me.ag2s.epublib;
import android.content.Context;
import androidx.test.platform.app.InstrumentationRegistry;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
* Instrumented test, which will execute on an Android device.
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
@Test
public void useAppContext() {
// Context of the app under test.
Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
assertEquals("me.ag2s.epublib.test", appContext.getPackageName());
}
}

View File

@ -1,17 +0,0 @@
package me.ag2s.epublib;
import org.junit.Test;
import static org.junit.Assert.*;
/**
* Example local unit test, which will execute on the development machine (host).
*
* @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
*/
public class ExampleUnitTest {
@Test
public void addition_isCorrect() {
assertEquals(4, 2 + 2);
}
}

View File

@ -1,6 +1,6 @@
#Tue Oct 13 11:35:54 CST 2020
#Fri May 07 15:24:46 CST 2021
distributionBase=GRADLE_USER_HOME
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8.3-bin.zip
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.7.1-all.zip
zipStoreBase=GRADLE_USER_HOME