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
db00830c
Commit
db00830c
authored
Oct 09, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add luban
parent
14d11c5c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
9 deletions
+36
-9
build.gradle
+3
-0
src/main/java/com/common/activity/TakePhotoActivity.java
+33
-9
No files found.
build.gradle
View file @
db00830c
...
...
@@ -131,6 +131,9 @@ dependencies {
api
'com.squareup.retrofit2:converter-gson:2.4.0'
api
'com.squareup.retrofit2:adapter-rxjava2:2.4.0'
api
'top.zibin:Luban:1.1.8'
// firebase core
// api 'com.google.firebase:firebase-core:16.0.3'
// firebase cloud message
...
...
src/main/java/com/common/activity/TakePhotoActivity.java
View file @
db00830c
...
...
@@ -29,6 +29,8 @@ import tech.starwin.utils.context_utils.ActivityJumper;
import
tech.starwin.utils.context_utils.EasyActivityResult
;
import
tech.starwin.utils.ui_utils.QMUIHelper
;
import
tech.starwin.utils.ui_utils.UIHelper
;
import
top.zibin.luban.Luban
;
import
top.zibin.luban.OnCompressListener
;
import
com.common.widget.CameraView
;
import
com.common.widget.TopBar
;
...
...
@@ -142,17 +144,39 @@ public class TakePhotoActivity extends BaseActivity {
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
);
}
//
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
);
finish
();
Luban
.
with
(
TakePhotoActivity
.
this
)
.
load
(
file
)
.
ignoreBy
(
100
)
.
setFocusAlpha
(
false
)
.
setTargetDir
(
file
.
getParent
())
.
setCompressListener
(
new
OnCompressListener
()
{
@Override
public
void
onStart
()
{
}
@Override
public
void
onSuccess
(
File
file
)
{
intent
.
putExtra
(
"image_path"
,
file
.
getAbsolutePath
());
setResult
(
RESULT_OK
,
intent
);
finish
();
}
@Override
public
void
onError
(
Throwable
e
)
{
setResult
(
RESULT_CANCELED
);
finish
();
}
}).
launch
();
});
}
else
if
(
v
.
getId
()
==
R
.
id
.
button_cancel
)
{
...
...
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