拍照按钮新增等待延时

nx2024
liuguijing 5 months ago committed by Matthew
parent c05b8db3b6
commit 9860bad8ad

@ -4,6 +4,8 @@ import static com.xypower.mppreview.HdrUtil.generateTimestamp;
import static java.lang.System.loadLibrary;
import android.Manifest;
import android.animation.Animator;
import android.animation.AnimatorInflater;
import android.app.Activity;
import android.content.Context;
import android.content.pm.PackageManager;
@ -51,7 +53,11 @@ import android.view.Surface;
import android.view.TextureView;
import android.view.View;
import android.view.ViewGroup;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.view.animation.LinearInterpolator;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.Toast;
import com.xypower.mppreview.bean.Contants;
@ -127,6 +133,8 @@ public class Camera2RawFragment extends Fragment {
private OrientationEventListener mOrientationListener;
private ExecutorService executorService;
private Button takepic;
private ImageView rorpic;
public static native boolean makeHdr(long exposureTime1, String path1, long exposureTime2, String path2, String outputPath);
@ -533,10 +541,16 @@ public class Camera2RawFragment extends Fragment {
}
}
};
Button takepic = view.findViewById(R.id.takepic);
takepic = view.findViewById(R.id.takepic);
rorpic = view.findViewById(R.id.rorpic);
takepic.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
takepic.setVisibility(View.INVISIBLE);
rorpic.setVisibility(View.VISIBLE);
Animation animation = AnimationUtils.loadAnimation(getContext(), R.anim.r);
animation.setInterpolator(new LinearInterpolator());
rorpic.startAnimation(animation);
takePicture();
}
});
@ -1129,7 +1143,18 @@ public class Camera2RawFragment extends Fragment {
images.clear();
Log.d("结束Hdr处理", "end");
if (b) {
showToast("HDR拍摄成功");
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
// 在主线程中执行UI更新
// ...
takepic.setVisibility(View.VISIBLE);
rorpic.clearAnimation();
rorpic.setVisibility(View.GONE);
showToast("HDR拍摄成功");
}
});
}
}

@ -63,14 +63,15 @@ public class PhotoUtil {
* @return
*/
private static File saveFileName(Context context) {
File newFolder = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
// File newFolder = context.getExternalFilesDir(Environment.DIRECTORY_PICTURES);
String outputPath = "/sdcard/DCIM";
SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
Date date = new Date(System.currentTimeMillis());
String name = format.format(date) + ".jpg";
File ji = null;
try {
ji = new File(newFolder + "/" + name);
ji = new File(outputPath + "/" + name);
ji.createNewFile();
// currentPath = ji.getAbsolutePath();
} catch (Exception e) {

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<rotate xmlns:android="http://schemas.android.com/apk/res/android"
android:duration="1500"
android:fromDegrees="0"
android:pivotX="50%"
android:pivotY="50%"
android:repeatCount="infinite"
android:toDegrees="360">
<!--fromDegrees起始旋转度数 toDegrees终始旋转度数 duration动画时长-->
<!--pivotXpivotY 写百分比是以自身为旋转点,写数值是以像素为坐标点 -->
</rotate>

@ -13,14 +13,26 @@
<Button
android:id="@+id/takepic"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_marginBottom="40dp"
android:background="@mipmap/takepic"
android:shadowColor="@null"
android:text="拍照"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent" />
<ImageView
android:visibility="invisible"
android:id="@+id/rorpic"
android:src="@mipmap/ror"
app:layout_constraintTop_toTopOf="@+id/takepic"
app:layout_constraintBottom_toBottomOf="@+id/takepic"
app:layout_constraintLeft_toLeftOf="@+id/takepic"
app:layout_constraintRight_toRightOf="@+id/takepic"
android:layout_width="45dp"
android:layout_height="45dp">
</ImageView>
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 10 KiB

After

Width:  |  Height:  |  Size: 15 KiB

@ -1,6 +1,6 @@
<resources xmlns:tools="http://schemas.android.com/tools">
<!-- Base application theme. -->
<style name="Theme.MpPreview" parent="Theme.MaterialComponents.DayNight.DarkActionBar">
<style name="Theme.MpPreview" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">
<!-- Primary brand color. -->
<item name="colorPrimary">@color/purple_500</item>
<item name="colorPrimaryVariant">@color/purple_700</item>

Loading…
Cancel
Save