215 lines
6.2 KiB
Java
215 lines
6.2 KiB
Java
package com.bottle.hp.album.capture.view;
|
|
|
|
import android.content.Context;
|
|
import android.graphics.Bitmap;
|
|
import android.util.AttributeSet;
|
|
import android.view.MotionEvent;
|
|
import android.view.SurfaceHolder;
|
|
import android.view.SurfaceView;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import android.widget.ProgressBar;
|
|
import android.widget.RelativeLayout;
|
|
import android.widget.TextView;
|
|
import com.bottle.hp.album.R$id;
|
|
import com.bottle.hp.album.R$layout;
|
|
import com.bottle.hp.album.R$mipmap;
|
|
import com.bottle.hp.album.R$string;
|
|
import com.bottle.hp.album.Utils;
|
|
import com.bumptech.glide.Glide;
|
|
import com.github.chrisbanes.photoview.PhotoView;
|
|
import com.ubtrobot.log.ALog;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class VideoCaptureView extends FrameLayout implements View.OnClickListener, View.OnTouchListener {
|
|
private final String a;
|
|
private SurfaceView b;
|
|
private ImageView c;
|
|
private ImageView d;
|
|
private ProgressBar e;
|
|
private ImageView f;
|
|
private ImageView g;
|
|
private PhotoView h;
|
|
private ImageView i;
|
|
private TextView j;
|
|
private RelativeLayout k;
|
|
private ImageView l;
|
|
private IVideoCaptureUIListener m;
|
|
|
|
public interface IVideoCaptureUIListener {
|
|
void B0();
|
|
|
|
void h0();
|
|
|
|
void onCancel();
|
|
|
|
void r0();
|
|
|
|
void t0();
|
|
|
|
void x0();
|
|
|
|
void y0();
|
|
}
|
|
|
|
public VideoCaptureView(Context context) {
|
|
super(context);
|
|
this.a = VideoCaptureView.class.getSimpleName();
|
|
a(context);
|
|
}
|
|
|
|
private void a(Context context) {
|
|
View inflate = View.inflate(context, R$layout.view_video_capture, this);
|
|
this.b = (SurfaceView) inflate.findViewById(R$id.surfaceView);
|
|
this.c = (ImageView) inflate.findViewById(R$id.imgBack);
|
|
this.d = (ImageView) inflate.findViewById(R$id.imgChangeCamera);
|
|
this.e = (ProgressBar) inflate.findViewById(R$id.progressBar);
|
|
this.f = (ImageView) inflate.findViewById(R$id.imgCancel);
|
|
this.g = (ImageView) inflate.findViewById(R$id.imgAccept);
|
|
this.h = (PhotoView) inflate.findViewById(R$id.imgPreview);
|
|
this.i = (ImageView) inflate.findViewById(R$id.imgStartPlay);
|
|
this.j = (TextView) inflate.findViewById(R$id.tvTips);
|
|
this.k = (RelativeLayout) inflate.findViewById(R$id.rlBottom);
|
|
this.l = (ImageView) inflate.findViewById(R$id.imgCaptureBackground);
|
|
this.c.setOnClickListener(this);
|
|
this.d.setOnClickListener(this);
|
|
this.l.setOnClickListener(this);
|
|
this.c.setOnClickListener(this);
|
|
this.f.setOnClickListener(this);
|
|
this.g.setOnClickListener(this);
|
|
this.l.setOnTouchListener(this);
|
|
this.i.setOnClickListener(this);
|
|
}
|
|
|
|
private void f() {
|
|
this.i.setVisibility(8);
|
|
}
|
|
|
|
private void g() {
|
|
this.i.setVisibility(0);
|
|
}
|
|
|
|
public void b() {
|
|
this.l.setVisibility(0);
|
|
this.e.setVisibility(8);
|
|
this.l.setImageResource(R$mipmap.capture);
|
|
this.j.setVisibility(0);
|
|
this.h.setVisibility(4);
|
|
this.i.setVisibility(8);
|
|
this.c.setVisibility(0);
|
|
this.d.setVisibility(0);
|
|
this.k.setVisibility(8);
|
|
this.e.setProgress(0);
|
|
}
|
|
|
|
public void c() {
|
|
this.j.setText("");
|
|
}
|
|
|
|
public void d() {
|
|
this.j.setVisibility(8);
|
|
this.l.setImageResource(R$mipmap.capture_videotape);
|
|
this.e.setVisibility(0);
|
|
}
|
|
|
|
public void e() {
|
|
this.j.setText(getContext().getString(R$string.please_add_video));
|
|
}
|
|
|
|
public SurfaceHolder getPreviewSurfaceHolder() {
|
|
return this.b.getHolder();
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R$id.imgBack) {
|
|
this.m.y0();
|
|
return;
|
|
}
|
|
if (id == R$id.imgChangeCamera) {
|
|
this.m.B0();
|
|
return;
|
|
}
|
|
if (id == R$id.imgCancel) {
|
|
this.m.onCancel();
|
|
} else if (id == R$id.imgAccept) {
|
|
this.m.x0();
|
|
} else if (id == R$id.imgStartPlay) {
|
|
this.m.t0();
|
|
}
|
|
}
|
|
|
|
@Override // android.view.View.OnTouchListener
|
|
public boolean onTouch(View view, MotionEvent motionEvent) {
|
|
ImageView imageView = this.l;
|
|
if (imageView == null || !imageView.equals(view) || motionEvent == null || this.m == null) {
|
|
return false;
|
|
}
|
|
int action = motionEvent.getAction();
|
|
if (action == 0) {
|
|
ALog.a(this.a).d("action down");
|
|
this.m.h0();
|
|
return true;
|
|
}
|
|
if (action != 1) {
|
|
if (action == 2) {
|
|
ALog.a(this.a).d("action move");
|
|
}
|
|
return false;
|
|
}
|
|
ALog.a(this.a).d("action up");
|
|
this.m.r0();
|
|
return true;
|
|
}
|
|
|
|
public void setUIListener(IVideoCaptureUIListener iVideoCaptureUIListener) {
|
|
this.m = iVideoCaptureUIListener;
|
|
}
|
|
|
|
public VideoCaptureView(Context context, AttributeSet attributeSet) {
|
|
super(context, attributeSet);
|
|
this.a = VideoCaptureView.class.getSimpleName();
|
|
a(context);
|
|
}
|
|
|
|
public VideoCaptureView(Context context, AttributeSet attributeSet, int i) {
|
|
super(context, attributeSet, i);
|
|
this.a = VideoCaptureView.class.getSimpleName();
|
|
a(context);
|
|
}
|
|
|
|
private void a(ImageView imageView, String str) {
|
|
Glide.e(getContext()).a(str).a(imageView);
|
|
}
|
|
|
|
public void a(String str, int i) {
|
|
this.j.setVisibility(8);
|
|
this.c.setVisibility(8);
|
|
this.d.setVisibility(8);
|
|
this.l.setVisibility(8);
|
|
this.e.setVisibility(8);
|
|
this.e.setProgress(0);
|
|
this.k.setVisibility(0);
|
|
this.h.setVisibility(0);
|
|
if (1 == i) {
|
|
Bitmap a = Utils.a(str);
|
|
this.h.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
|
this.h.setImageBitmap(a);
|
|
g();
|
|
return;
|
|
}
|
|
a(this.h, str);
|
|
f();
|
|
}
|
|
|
|
public void a(int i) {
|
|
this.e.setProgress(i);
|
|
}
|
|
|
|
public void a() {
|
|
this.j.setText(getContext().getString(R$string.tips_photo_or_video));
|
|
}
|
|
}
|