Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
L
lib_base
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sikang
lib_base
Commits
bd8b2a5f
Commit
bd8b2a5f
authored
Apr 22, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update camera
parent
bc4534a9
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
52 deletions
+45
-52
src/main/java/com/common/activity/TakePhotoActivity.java
+32
-40
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
+11
-11
src/main/java/tech/starwin/utils/FileUtils.java
+2
-1
No files found.
src/main/java/com/common/activity/TakePhotoActivity.java
View file @
bd8b2a5f
...
@@ -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
();
//去掉SD卡权限后弃用
// File image = FileUtils.getImageFile(getApplicationContext(), KTP_IMAGE);
// if (!image.exists()) {
// image.mkdir();
// }
// }
//
// setResult(RESULT_OK);
// File file = BitmapUtils.saveBitmapToSDCard(bitmap, image, 100);
// if (file == null) {
// setResult(RESULT_CANCELED);
// finish();
// finish();
// return;
// }
// //如果图片过大,则压缩
// 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();
File
image
=
FileUtils
.
getImageFile
(
getApplicationContext
(),
KTP_IMAGE
);
// intent.putExtra("image_path", file.getAbsolutePath());
if
(!
image
.
exists
())
{
// setResult(RESULT_OK, intent);
image
.
mkdir
();
// finish();
}
File
file
=
BitmapUtils
.
saveBitmapToSDCard
(
bitmap
,
image
,
100
);
if
(
file
==
null
)
{
setResult
(
RESULT_CANCELED
);
finish
();
return
;
}
//如果图片过大,则压缩
long
size
=
FileUtils
.
getFileSize
(
file
)
/
1024
;
if
(
FileUtils
.
getFileSize
(
file
)
/
1024
>
1024
)
{
int
quality
=
(
int
)
(
100
*
(
1024
f
/
size
));
file
=
BitmapUtils
.
saveBitmapToSDCard
(
bitmap
,
image
,
quality
);
}
Intent
intent
=
new
Intent
();
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
);
...
...
src/main/java/tech/starwin/mvp/presenter/UserPresenter.java
View file @
bd8b2a5f
...
@@ -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);
// }
/**
/**
* 提交工作信息
* 提交工作信息
*/
*/
...
...
src/main/java/tech/starwin/utils/FileUtils.java
View file @
bd8b2a5f
...
@@ -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
();
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment