142 lines
4.7 KiB
Java
142 lines
4.7 KiB
Java
package com.bottle.hp.album.capture;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.media.MediaPlayer;
|
|
import android.net.Uri;
|
|
import android.os.Bundle;
|
|
import android.util.Log;
|
|
import android.view.KeyEvent;
|
|
import android.view.View;
|
|
import android.widget.FrameLayout;
|
|
import android.widget.ImageView;
|
|
import com.bottle.hp.album.BaseActivity;
|
|
import com.bottle.hp.album.R$id;
|
|
import com.bottle.hp.album.R$layout;
|
|
import com.bottle.hp.album.Utils;
|
|
import com.bottle.hp.album.capture.VideoPlayFragment;
|
|
import com.ubtrobot.log.ALog;
|
|
import java.io.File;
|
|
|
|
/* loaded from: classes.dex */
|
|
public class VideoPreviewActivity extends BaseActivity implements View.OnClickListener, VideoPlayFragment.IPlayListener {
|
|
private static final String i = VideoPreviewActivity.class.getSimpleName();
|
|
private VideoPlayFragment c;
|
|
private FrameLayout d;
|
|
private ImageView e;
|
|
private ImageView f;
|
|
private String g;
|
|
private boolean h = true;
|
|
|
|
private void c(int i2, String str) {
|
|
Intent intent = new Intent();
|
|
intent.putExtra("url", str);
|
|
setResult(i2, intent);
|
|
this.c.a();
|
|
finish();
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
|
public void b(String str) {
|
|
long j;
|
|
Log.e(i, str);
|
|
File file = new File(this.g);
|
|
try {
|
|
j = Utils.a(file);
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
Log.e(i, e.getMessage());
|
|
j = 0;
|
|
}
|
|
if (!file.exists() || j == 0) {
|
|
this.f.setEnabled(false);
|
|
}
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
|
public void m0() {
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
if (R$id.imgCancel == view.getId()) {
|
|
c(0, this.g);
|
|
} else if (R$id.imgAccept == view.getId()) {
|
|
c(-1, this.g);
|
|
} else {
|
|
ALog.a(i).d("click");
|
|
}
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, androidx.core.app.ComponentActivity, android.app.Activity
|
|
protected void onCreate(Bundle bundle) {
|
|
super.onCreate(bundle);
|
|
setContentView(R$layout.activity_video_preview);
|
|
this.d = (FrameLayout) findViewById(R$id.flVideoViewContainer);
|
|
this.e = (ImageView) findViewById(R$id.imgCancel);
|
|
this.f = (ImageView) findViewById(R$id.imgAccept);
|
|
this.e.setOnClickListener(this);
|
|
this.f.setOnClickListener(this);
|
|
this.g = getIntent().getStringExtra("url");
|
|
this.c = VideoPlayFragment.a(Uri.parse(this.g), true, true);
|
|
getFragmentManager().beginTransaction().replace(R$id.flVideoViewContainer, this.c).commit();
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
|
public void onFinished() {
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
|
public boolean onInfo(MediaPlayer mediaPlayer, int i2, int i3) {
|
|
return false;
|
|
}
|
|
|
|
@Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
|
|
public boolean onKeyDown(int i2, KeyEvent keyEvent) {
|
|
if (i2 != 4) {
|
|
return super.onKeyDown(i2, keyEvent);
|
|
}
|
|
c(0, this.g);
|
|
return true;
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
public void onPause() {
|
|
super.onPause();
|
|
VideoPlayFragment videoPlayFragment = this.c;
|
|
if (videoPlayFragment != null) {
|
|
videoPlayFragment.a();
|
|
}
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
|
public void onProgress(int i2, int i3, int i4) {
|
|
Log.e(i, "progress:" + i4);
|
|
}
|
|
|
|
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
public void onResume() {
|
|
super.onResume();
|
|
if (this.h) {
|
|
this.h = false;
|
|
} else {
|
|
this.d.post(new Runnable() { // from class: com.bottle.hp.album.capture.VideoPreviewActivity.1
|
|
@Override // java.lang.Runnable
|
|
public void run() {
|
|
VideoPreviewActivity.this.c.c();
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
|
public void v0() {
|
|
}
|
|
|
|
public static void a(Activity activity, int i2, String str) {
|
|
Intent intent = new Intent(activity, (Class<?>) VideoPreviewActivity.class);
|
|
intent.putExtra("url", str);
|
|
activity.startActivityForResult(intent, i2);
|
|
}
|
|
}
|