| | |
| | | import com.ypx.imagepicker.builder.MultiPickerBuilder |
| | | import kotlinx.android.synthetic.main.dialog_phone.view.* |
| | | import org.jetbrains.anko.toast |
| | | import top.zibin.luban.Luban |
| | | import java.io.* |
| | | |
| | | |
| | |
| | | Thread( |
| | | Runnable |
| | | { |
| | | var copyFile = "" |
| | | if (filePath.endsWith("png") || filePath.endsWith("jpg")) { |
| | | getCameraPhotoOrientation(filePath) |
| | | try { |
| | | copyFile = compressImage(filePath) |
| | | } catch (e: java.lang.Exception) { |
| | | e.printStackTrace() |
| | | } |
| | | if (copyFile.isNullOrEmpty()) { |
| | | runOnUiThread { |
| | | showNum-- |
| | | dismissDialog() |
| | | toast("文件已损坏,无法上传") |
| | | } |
| | | return@Runnable |
| | | } |
| | | // val bitmap = getBitmapFormUri(this,uri) |
| | | // val bit = rotateBitmap(bitmap, rotate) |
| | | // val b = saveBmpToPath(bit, filePath) |
| | | // if (!b) { |
| | | // Handler(mainLooper).post { |
| | | // toast("旋转图片错误") |
| | | // } |
| | | // } |
| | | } |
| | | val file = File(copyFile.ifEmpty { filePath }); |
| | | val resourceUrl = uploadManager.uploadHWSync(file); |
| | | val copyFile = |
| | | Luban.with(this).load(filePath).setTargetDir(filesDir.absolutePath).get() |
| | | .first() |
| | | Log.d(TAG, "savePhone: copyFile:$copyFile") |
| | | val resourceUrl = uploadManager.uploadHWSync(copyFile); |
| | | runOnUiThread { |
| | | showNum-- |
| | | Log.d("showNum==", "showNum==========" + showNum.toString()) |
| | |
| | | if (showNum <= 0) |
| | | dismissDialog() |
| | | resourceUrl?.also { |
| | | getPhoneUrl(it, type, copyFile) |
| | | getPhoneUrl(it, type, copyFile.absolutePath) |
| | | getPhoneUrl(it, type) |
| | | } |
| | | } |