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