Commit bd8b2a5f by sikang

update camera

parent bc4534a9
...@@ -12,6 +12,7 @@ import android.widget.ImageView; ...@@ -12,6 +12,7 @@ import android.widget.ImageView;
import com.qmuiteam.qmui.util.QMUIStatusBarHelper; import com.qmuiteam.qmui.util.QMUIStatusBarHelper;
import java.io.File; import java.io.File;
import java.io.FileOutputStream;
import tech.starwin.R; import tech.starwin.R;
...@@ -102,50 +103,41 @@ public class TakePhotoActivity extends BaseActivity { ...@@ -102,50 +103,41 @@ public class TakePhotoActivity extends BaseActivity {
public void onEventClick(View v) { public void onEventClick(View v) {
if (v.getId() == R.id.button_shoot) { if (v.getId() == R.id.button_shoot) {
cameraView.captureImage(bitmap -> { cameraView.captureImage(bitmap -> {
long pix_size = bitmap.getWidth() * bitmap.getHeight(); // long pix_size = bitmap.getWidth() * bitmap.getHeight();
float scale = 720 * 1080 / (float) pix_size; // float scale = 720 * 1080 / (float) pix_size;
BitmapUtils.scaleBitmap(bitmap, scale); // BitmapUtils.scaleBitmap(bitmap, scale);
if(TextUtils.equals(type, PhotoType.KTP.name())){ // if(TextUtils.equals(type, PhotoType.KTP.name())){
SPDataProvider.saveKTPImage(bitmap); // SPDataProvider.saveKTPImage(bitmap);
}else if(TextUtils.equals(type, PhotoType.WORK_CARD.name())){ // }else if(TextUtils.equals(type, PhotoType.WORK_CARD.name())){
SPDataProvider.saveWorkImage(bitmap); // SPDataProvider.saveWorkImage(bitmap);
// }
// setResult(RESULT_OK);
// finish();
File image = FileUtils.getImageFile(getApplicationContext(), KTP_IMAGE);
if (!image.exists()) {
image.mkdir();
} }
setResult(RESULT_OK);
finish();
//去掉SD卡权限后弃用 File file = BitmapUtils.saveBitmapToSDCard(bitmap, image, 100);
// File image = FileUtils.getImageFile(getApplicationContext(), KTP_IMAGE); if (file == null) {
// if (!image.exists()) { setResult(RESULT_CANCELED);
// image.mkdir(); finish();
// } return;
// }
// File file = BitmapUtils.saveBitmapToSDCard(bitmap, image, 100); //如果图片过大,则压缩
// if (file == null) { long size = FileUtils.getFileSize(file) / 1024;
// setResult(RESULT_CANCELED); if (FileUtils.getFileSize(file) / 1024 > 1024) {
// finish(); int quality = (int) (100 * (1024f / size));
// return; file = BitmapUtils.saveBitmapToSDCard(bitmap, image, quality);
// }
// //如果图片过大,则压缩
// long size = FileUtils.getFileSize(file) / 1024;
// if (FileUtils.getFileSize(file) / 1024 > 1024) {
// int quality = (int) (100 * (1024f / size));
// file = BitmapUtils.saveBitmapToSDCard(bitmap, image, quality);
//
// }
// Intent intent = new Intent(); }
// intent.putExtra("image_path", file.getAbsolutePath());
// setResult(RESULT_OK, intent); Intent intent = new Intent();
// finish(); intent.putExtra("image_path", file.getAbsolutePath());
setResult(RESULT_OK, intent);
finish();
// try {
// FileOutputStream outputStream = new FileOutputStream(image.getPath());
// outputStream.write(data);
// outputStream.close();
//
// } catch (java.io.IOException e) {
// e.printStackTrace();
// }
}); });
} else if (v.getId() == R.id.button_cancel) { } else if (v.getId() == R.id.button_cancel) {
setResult(RESULT_CANCELED); setResult(RESULT_CANCELED);
......
...@@ -474,22 +474,22 @@ public class UserPresenter extends BasePresenter<UserApi> { ...@@ -474,22 +474,22 @@ public class UserPresenter extends BasePresenter<UserApi> {
} }
// public void submitEmploymentInfo(String action, File workCardImage, EmploymentServerBean employmentBean) { public void submitEmploymentInfo(String action, File workCardImage, EmploymentServerBean employmentBean) {
// MultipartBody.Part part = null;
// if (workCardImage != null && workCardImage.exists()) {
// part = MultipartBodyMaker.makeSimplePart("file", workCardImage);
// }
// submitEmploymentInfo(action, part, employmentBean);
// }
public void submitEmploymentInfo(String action, Bitmap bitmap, EmploymentServerBean employmentBean) {
MultipartBody.Part part = null; MultipartBody.Part part = null;
if (bitmap != null) { if (workCardImage != null && workCardImage.exists()) {
part = MultipartBodyMaker.makeSimplePart("file", "word_card", bitmap, Bitmap.CompressFormat.JPEG); part = MultipartBodyMaker.makeSimplePart("file", workCardImage);
} }
submitEmploymentInfo(action, part, employmentBean); submitEmploymentInfo(action, part, employmentBean);
} }
// public void submitEmploymentInfo(String action, Bitmap bitmap, EmploymentServerBean employmentBean) {
// MultipartBody.Part part = null;
// if (bitmap != null) {
// part = MultipartBodyMaker.makeSimplePart("file", "word_card", bitmap, Bitmap.CompressFormat.JPEG);
// }
// submitEmploymentInfo(action, part, employmentBean);
// }
/** /**
* 提交工作信息 * 提交工作信息
*/ */
......
...@@ -62,7 +62,8 @@ public class FileUtils { ...@@ -62,7 +62,8 @@ public class FileUtils {
* 创建图片文件 * 创建图片文件
*/ */
public static File getImageFile(Context context, String fileName) { public static File getImageFile(Context context, String fileName) {
File file = new File(getAppDir(context).getAbsoluteFile() + IMAGE_CACHE); File file = new File(context.getExternalFilesDir(null).getAbsoluteFile() + IMAGE_CACHE);
// File file = new File(getAppDir(context).getAbsoluteFile() + IMAGE_CACHE);
if (!file.exists()) { if (!file.exists()) {
file.mkdirs(); file.mkdirs();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment