mirror of
https://github.com/fumiama/android-base16384.git
synced 2026-06-06 10:40:30 +08:00
v2.1.1
1. 修复 生成大文件卡顿
This commit is contained in:
@@ -13,7 +13,7 @@ android {
|
||||
minSdkVersion 23
|
||||
targetSdkVersion 30
|
||||
versionCode 10
|
||||
versionName '2.1'
|
||||
versionName '2.1.1'
|
||||
resConfigs "zh", "en"
|
||||
|
||||
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -67,7 +67,10 @@ class MainActivity : Activity() {
|
||||
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
|
||||
super.onActivityResult(requestCode, resultCode, data)
|
||||
if (resultCode == RESULT_OK) when (requestCode) {
|
||||
1 -> data?.data?.let { doFromFile(it) }
|
||||
1 -> data?.data?.let {
|
||||
Toast.makeText(this, "${getString(R.string.output)}...", Toast.LENGTH_SHORT).show()
|
||||
doFromFile(it)
|
||||
}
|
||||
2 -> data?.data?.let { save2Uri(it) }
|
||||
}
|
||||
}
|
||||
@@ -105,7 +108,7 @@ class MainActivity : Activity() {
|
||||
fd?.close()
|
||||
}
|
||||
|
||||
private fun save2Uri(uri: Uri){
|
||||
private fun save2Uri(uri: Uri) = Thread{
|
||||
val outputFile = generateCacheFile("output")
|
||||
contentResolver.openOutputStream(uri)?.let {
|
||||
val fi = outputFile.inputStream()
|
||||
@@ -113,15 +116,18 @@ class MainActivity : Activity() {
|
||||
fi.close()
|
||||
it.close()
|
||||
}
|
||||
}
|
||||
runOnUiThread {
|
||||
Toast.makeText(this, "${getString(R.string.share)} ${getString(R.string.succeed)}", Toast.LENGTH_SHORT).show()
|
||||
}
|
||||
}.start()
|
||||
|
||||
private fun createFile(fileName: String, type: String = "*/*"){
|
||||
private fun createFile(fileName: String, type: String = "*/*") = Thread{
|
||||
val intent = Intent(Intent.ACTION_CREATE_DOCUMENT)
|
||||
intent.addCategory(Intent.CATEGORY_OPENABLE)
|
||||
intent.type = type
|
||||
intent.putExtra(Intent.EXTRA_TITLE, fileName)
|
||||
startActivityForResult(intent, 2)
|
||||
}
|
||||
}.start()
|
||||
|
||||
private fun pickFile() {
|
||||
val i = Intent(Intent.ACTION_GET_CONTENT)
|
||||
|
||||
Reference in New Issue
Block a user