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
7ca6d605
Commit
7ca6d605
authored
Oct 24, 2019
by
sikang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
upadte take photo
parent
91295b92
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
1 deletions
+64
-1
src/main/java/com/common/activity/TakePhotoActivity.java
+54
-1
src/main/res/layout/activity_take_photo.xml
+10
-0
No files found.
src/main/java/com/common/activity/TakePhotoActivity.java
View file @
7ca6d605
package
com
.
common
.
activity
;
import
android.animation.Animator
;
import
android.animation.ObjectAnimator
;
import
android.content.Intent
;
import
android.graphics.Bitmap
;
import
android.graphics.Matrix
;
import
android.support.annotation.DrawableRes
;
import
android.support.v4.app.FragmentActivity
;
import
android.text.TextUtils
;
...
...
@@ -108,11 +112,32 @@ public class TakePhotoActivity extends BaseActivity {
photoType
=
PhotoType
.
OTHERS_IMG
;
}
ImageView
screen_shot
=
findViewById
(
R
.
id
.
activity_take_photo_screen_shot
);
ObjectAnimator
animatorX
=
ObjectAnimator
.
ofFloat
(
screen_shot
,
"scaleX"
,
1
f
,
0.8f
,
0.8f
,
0.8f
,
0.8f
,
0.8f
);
ObjectAnimator
animatorY
=
ObjectAnimator
.
ofFloat
(
screen_shot
,
"scaleY"
,
1
f
,
0.7f
,
0.7f
,
0.7f
,
0.7f
,
0.7f
);
animatorX
.
addListener
(
new
ScreenShotAnimatorListener
(
screen_shot
));
animatorY
.
addListener
(
new
ScreenShotAnimatorListener
(
screen_shot
));
animatorX
.
setDuration
(
500
);
animatorY
.
setDuration
(
500
);
UIHelper
.
bindClickListener
(
new
OnNoShakeClickListener
()
{
@Override
public
void
onEventClick
(
View
v
)
{
if
(
v
.
getId
()
==
R
.
id
.
button_shoot
)
{
cameraView
.
captureImage
(
bitmap
->
{
runOnUiThread
(()
->
{
if
(
bitmap
.
getWidth
()
>
bitmap
.
getHeight
())
{
Matrix
matrix
=
new
Matrix
();
matrix
.
postRotate
(
90
f
);
Bitmap
newBmp
=
Bitmap
.
createBitmap
(
bitmap
,
0
,
0
,
bitmap
.
getWidth
(),
bitmap
.
getHeight
(),
matrix
,
true
);
screen_shot
.
setImageBitmap
(
newBmp
);
}
else
{
screen_shot
.
setImageBitmap
(
bitmap
);
}
animatorX
.
start
();
animatorY
.
start
();
});
try
{
File
image
=
FileUtils
.
getImageFile
(
getApplicationContext
(),
photoType
.
img_path
);
if
(!
image
.
exists
())
{
...
...
@@ -123,7 +148,6 @@ public class TakePhotoActivity extends BaseActivity {
if
(
file
!=
null
)
{
//压缩
file
=
Luban
.
with
(
TakePhotoActivity
.
this
).
load
(
file
).
get
().
get
(
0
);
Intent
intent
=
new
Intent
();
intent
.
putExtra
(
"image_path"
,
file
.
getAbsolutePath
());
setResult
(
RESULT_OK
,
intent
);
...
...
@@ -168,4 +192,33 @@ public class TakePhotoActivity extends BaseActivity {
public
void
onHttpSuccess
(
String
action
,
Object
result
)
{
}
private
static
class
ScreenShotAnimatorListener
implements
Animator
.
AnimatorListener
{
ImageView
screen_shot
;
ScreenShotAnimatorListener
(
ImageView
screen_shot
)
{
this
.
screen_shot
=
screen_shot
;
}
@Override
public
void
onAnimationStart
(
Animator
animation
)
{
screen_shot
.
setVisibility
(
View
.
VISIBLE
);
}
@Override
public
void
onAnimationEnd
(
Animator
animation
)
{
screen_shot
.
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onAnimationCancel
(
Animator
animation
)
{
screen_shot
.
setVisibility
(
View
.
GONE
);
}
@Override
public
void
onAnimationRepeat
(
Animator
animation
)
{
}
}
}
src/main/res/layout/activity_take_photo.xml
View file @
7ca6d605
...
...
@@ -9,6 +9,15 @@
android:layout_height=
"match_parent"
android:layout_centerInParent=
"true"
/>
<ImageView
android:id=
"@+id/activity_take_photo_screen_shot"
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
android:scaleType=
"fitXY"
android:background=
"@color/white"
android:padding=
"15dp"
android:visibility=
"gone"
/>
<LinearLayout
android:layout_width=
"match_parent"
...
...
@@ -92,4 +101,5 @@
</LinearLayout>
</RelativeLayout>
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