fix(android): Use the BUFFER_SIZE constant

This commit is contained in:
PapaTutuWawa 2023-09-20 19:26:34 +02:00
parent 53b6b65e70
commit c14b3a7f58

View File

@ -10,6 +10,7 @@ import android.provider.MediaStore.Images
import android.util.Log import android.util.Log
import io.flutter.plugin.common.PluginRegistry.ActivityResultListener import io.flutter.plugin.common.PluginRegistry.ActivityResultListener
import org.moxxy.moxxy_native.AsyncRequestTracker import org.moxxy.moxxy_native.AsyncRequestTracker
import org.moxxy.moxxy_native.BUFFER_SIZE
import org.moxxy.moxxy_native.PICK_FILES_REQUEST import org.moxxy.moxxy_native.PICK_FILES_REQUEST
import org.moxxy.moxxy_native.PICK_FILE_REQUEST import org.moxxy.moxxy_native.PICK_FILE_REQUEST
import org.moxxy.moxxy_native.PICK_FILE_WITH_DATA_REQUEST import org.moxxy.moxxy_native.PICK_FILE_WITH_DATA_REQUEST
@ -63,7 +64,7 @@ class PickerResultListener(private val context: Context) : ActivityResultListene
if (Build.VERSION.SDK_INT >= 33) { if (Build.VERSION.SDK_INT >= 33) {
android.os.FileUtils.copy(input, output) android.os.FileUtils.copy(input, output)
} else { } else {
val buffer = ByteArray(4096) val buffer = ByteArray(BUFFER_SIZE)
while (input.read(buffer).also {} != -1) { while (input.read(buffer).also {} != -1) {
output.write(buffer) output.write(buffer)
} }
@ -106,7 +107,7 @@ class PickerResultListener(private val context: Context) : ActivityResultListene
} }
val returnBuffer = mutableListOf<Byte>() val returnBuffer = mutableListOf<Byte>()
val readBuffer = ByteArray(4096) val readBuffer = ByteArray(BUFFER_SIZE)
try { try {
val inputStream = context.contentResolver.openInputStream(data!!.data!!)!! val inputStream = context.contentResolver.openInputStream(data!!.data!!)!!
while (inputStream.read(readBuffer).also {} != -1) { while (inputStream.read(readBuffer).also {} != -1) {