Commit 7ca6d605 by sikang

upadte take photo

parent 91295b92
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", 1f, 0.8f, 0.8f, 0.8f, 0.8f, 0.8f);
ObjectAnimator animatorY = ObjectAnimator.ofFloat(screen_shot, "scaleY", 1f, 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(90f);
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) {
}
}
}
......@@ -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>
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