Initial commit
This commit is contained in:
413
sources/com/bottle/hp/album/selector/AlbumActivity.java
Normal file
413
sources/com/bottle/hp/album/selector/AlbumActivity.java
Normal file
@@ -0,0 +1,413 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import android.app.Activity;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.Message;
|
||||
import android.text.TextUtils;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.AdapterView;
|
||||
import android.widget.Button;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.ListAdapter;
|
||||
import androidx.core.content.ContextCompat;
|
||||
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.R$string;
|
||||
import com.bottle.hp.album.capture.VideoCaptureActivity;
|
||||
import com.bottle.hp.album.media.HPImage;
|
||||
import com.bottle.hp.album.media.HPMedia;
|
||||
import com.bottle.hp.album.media.HPVideo;
|
||||
import com.bottle.hp.album.selector.AlbumAdapter;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import com.ubt.jimu.base.entities.Constant;
|
||||
import com.ubtech.permission.JimuPermissionRequest;
|
||||
import com.ubtech.permission.PermissionRequestListener;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AlbumActivity extends BaseActivity implements AdapterView.OnItemClickListener, View.OnClickListener {
|
||||
public static List<HPMedia> m = new ArrayList();
|
||||
public static List<HPMedia> n = new ArrayList();
|
||||
private GridView c;
|
||||
private AlbumAdapter d;
|
||||
private List<HPMedia> e = new ArrayList();
|
||||
private ArrayList<HPMedia> f = new ArrayList<>();
|
||||
private int g = 5;
|
||||
private int h;
|
||||
private ImageView i;
|
||||
private Button j;
|
||||
private String k;
|
||||
private Handler l;
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void F0() {
|
||||
this.e.add(E0());
|
||||
this.e.addAll(n);
|
||||
this.e.addAll(m);
|
||||
Collections.sort(this.e, new HPMediaComparator());
|
||||
this.d = new AlbumAdapter(this, this.e, new AlbumAdapter.IAlbumAdapterUIListener() { // from class: com.bottle.hp.album.selector.AlbumActivity.5
|
||||
@Override // com.bottle.hp.album.selector.AlbumAdapter.IAlbumAdapterUIListener
|
||||
public void a(CompoundButton compoundButton, boolean z, HPMedia hPMedia) {
|
||||
if (!z) {
|
||||
hPMedia.setSelected(false);
|
||||
Iterator it = AlbumActivity.this.f.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
HPMedia hPMedia2 = (HPMedia) it.next();
|
||||
if (hPMedia2.getId() == hPMedia.getId()) {
|
||||
AlbumActivity.this.f.remove(hPMedia2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (AlbumActivity.this.f.size() > 0) {
|
||||
AlbumActivity.this.j.setText(AlbumActivity.this.k + "(" + AlbumActivity.this.f.size() + "/" + AlbumActivity.this.h + ")");
|
||||
} else {
|
||||
AlbumActivity.this.j.setText(AlbumActivity.this.k);
|
||||
AlbumActivity.this.j.setEnabled(false);
|
||||
}
|
||||
} else if (AlbumActivity.this.f.size() >= AlbumActivity.this.h) {
|
||||
AlbumActivity.this.a(AlbumActivity.this.getString(R$string.number_limit), 0);
|
||||
compoundButton.setSelected(false);
|
||||
} else {
|
||||
hPMedia.setSelected(true);
|
||||
AlbumActivity.this.f.add(hPMedia);
|
||||
AlbumActivity.this.j.setText(AlbumActivity.this.k + "(" + AlbumActivity.this.f.size() + "/" + AlbumActivity.this.h + ")");
|
||||
if (!AlbumActivity.this.j.isEnabled()) {
|
||||
AlbumActivity.this.j.setEnabled(true);
|
||||
}
|
||||
}
|
||||
AlbumActivity.this.d.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
this.c.setAdapter((ListAdapter) this.d);
|
||||
ArrayList<HPMedia> arrayList = this.f;
|
||||
if (arrayList == null || arrayList.size() <= 0) {
|
||||
return;
|
||||
}
|
||||
this.j.setText(this.k + "(" + this.f.size() + "/" + this.h + ")");
|
||||
this.j.setEnabled(true);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void initData() {
|
||||
ArrayList arrayList = (ArrayList) getIntent().getSerializableExtra("input_selected");
|
||||
if (arrayList != null && arrayList.size() > 0) {
|
||||
this.f.addAll(arrayList);
|
||||
}
|
||||
new Thread(new Runnable() { // from class: com.bottle.hp.album.selector.AlbumActivity.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
if (AlbumActivity.this.g == 1) {
|
||||
AlbumActivity.m.addAll(HPImage.getImages(AlbumActivity.this));
|
||||
} else if (AlbumActivity.this.g == 2) {
|
||||
AlbumActivity.n.addAll(HPVideo.getVideos(AlbumActivity.this));
|
||||
} else {
|
||||
AlbumActivity.m.addAll(HPImage.getImages(AlbumActivity.this));
|
||||
AlbumActivity.n.addAll(HPVideo.getVideos(AlbumActivity.this));
|
||||
}
|
||||
AlbumActivity.this.l.sendEmptyMessage(Constant.Publish.REQUEST_CODE_PICK_FILE);
|
||||
ArrayList arrayList2 = new ArrayList();
|
||||
Iterator it = AlbumActivity.this.f.iterator();
|
||||
while (it.hasNext()) {
|
||||
HPMedia hPMedia = (HPMedia) it.next();
|
||||
for (HPMedia hPMedia2 : AlbumActivity.m) {
|
||||
if (hPMedia.getId() == hPMedia2.getId() || hPMedia.getPath().equals(hPMedia2.getPath())) {
|
||||
hPMedia2.setSelected(true);
|
||||
arrayList2.add(hPMedia2);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
AlbumActivity.this.f.clear();
|
||||
AlbumActivity.this.f.addAll(arrayList2);
|
||||
final ArrayList arrayList3 = new ArrayList();
|
||||
for (HPMedia hPMedia3 : AlbumActivity.n) {
|
||||
if (((HPVideo) hPMedia3).getDuration() < 500) {
|
||||
arrayList3.add(hPMedia3);
|
||||
} else {
|
||||
HPVideo.getVideoThumnail(AlbumActivity.this, hPMedia3);
|
||||
}
|
||||
}
|
||||
AlbumActivity.this.l.post(new Runnable() { // from class: com.bottle.hp.album.selector.AlbumActivity.3.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
AlbumActivity.n.removeAll(arrayList3);
|
||||
AlbumActivity.this.e.removeAll(arrayList3);
|
||||
AlbumActivity.this.d.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
this.k = getString(R$string.done);
|
||||
this.i = (ImageView) findViewById(R$id.imgBack);
|
||||
this.i.setOnClickListener(this);
|
||||
this.j = (Button) findViewById(R$id.btnCompleted);
|
||||
this.j.setOnClickListener(this);
|
||||
this.c = (GridView) findViewById(R$id.gridView);
|
||||
this.c.setOnItemClickListener(this);
|
||||
this.h = getIntent().getIntExtra(FileDownloadModel.TOTAL, 5);
|
||||
this.g = getIntent().getIntExtra("type", 5);
|
||||
}
|
||||
|
||||
public HPMedia E0() {
|
||||
HPMedia hPMedia = new HPMedia();
|
||||
hPMedia.setId(Integer.MAX_VALUE);
|
||||
hPMedia.setModifyDate("2147483647");
|
||||
return hPMedia;
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
public void onActivityResult(int i, int i2, Intent intent) {
|
||||
if (i == 101) {
|
||||
a(i2, intent);
|
||||
} else if (i == 102) {
|
||||
b(i2, intent);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R$id.imgBack) {
|
||||
e(false);
|
||||
} else if (id == R$id.btnCompleted) {
|
||||
e(true);
|
||||
}
|
||||
}
|
||||
|
||||
@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);
|
||||
this.l = new Handler() { // from class: com.bottle.hp.album.selector.AlbumActivity.1
|
||||
@Override // android.os.Handler
|
||||
public void handleMessage(Message message) {
|
||||
int i = message.what;
|
||||
if (i == 201) {
|
||||
AlbumActivity.this.a(message);
|
||||
} else if (i == 202) {
|
||||
AlbumActivity.this.F0();
|
||||
}
|
||||
}
|
||||
};
|
||||
setContentView(R$layout.activity_album);
|
||||
initView();
|
||||
if (Build.VERSION.SDK_INT < 23 || ContextCompat.a(this, "android.permission.READ_EXTERNAL_STORAGE") == 0) {
|
||||
initData();
|
||||
} else {
|
||||
JimuPermissionRequest.c(this, new PermissionRequestListener() { // from class: com.bottle.hp.album.selector.AlbumActivity.2
|
||||
@Override // com.ubtech.permission.PermissionRequestListener
|
||||
public void onDenied() {
|
||||
AlbumActivity.this.finish();
|
||||
}
|
||||
|
||||
@Override // com.ubtech.permission.PermissionRequestListener
|
||||
public void onGranted() {
|
||||
AlbumActivity.this.initData();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
public void onDestroy() {
|
||||
this.l.removeCallbacksAndMessages(null);
|
||||
this.l = null;
|
||||
m.clear();
|
||||
n.clear();
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@Override // android.widget.AdapterView.OnItemClickListener
|
||||
public void onItemClick(AdapterView<?> adapterView, View view, int i, long j) {
|
||||
if (i != 0) {
|
||||
HPMedia hPMedia = this.e.get(i);
|
||||
if (hPMedia.getMediaType() == 0) {
|
||||
AlbumActivity2.a(this, 101, this.h, a(hPMedia, m), 0, this.f);
|
||||
return;
|
||||
} else if (this.f.size() > 0) {
|
||||
b(R$string.tips_type_limit, 0);
|
||||
return;
|
||||
} else {
|
||||
if (((HPVideo) hPMedia).getDuration() > 20500) {
|
||||
return;
|
||||
}
|
||||
AlbumActivity2.a(this, 101, this.h, a(hPMedia, n), 1, this.f);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (this.f.size() == this.h) {
|
||||
a(getString(R$string.number_limit), 0);
|
||||
return;
|
||||
}
|
||||
if (Build.VERSION.SDK_INT < 23) {
|
||||
int i2 = this.g;
|
||||
if (i2 == 5) {
|
||||
i2 = this.f.size() == 0 ? 5 : 1;
|
||||
}
|
||||
VideoCaptureActivity.a(this, 102, i2);
|
||||
return;
|
||||
}
|
||||
if (ContextCompat.a(this, "android.permission.CAMERA") != 0) {
|
||||
JimuPermissionRequest.a((Context) this, new PermissionRequestListener() { // from class: com.bottle.hp.album.selector.AlbumActivity.4
|
||||
@Override // com.ubtech.permission.PermissionRequestListener
|
||||
public void onDenied() {
|
||||
}
|
||||
|
||||
@Override // com.ubtech.permission.PermissionRequestListener
|
||||
public void onGranted() {
|
||||
AlbumActivity albumActivity = AlbumActivity.this;
|
||||
int i3 = 5;
|
||||
if (albumActivity.g != 5) {
|
||||
i3 = AlbumActivity.this.g;
|
||||
} else if (AlbumActivity.this.f.size() != 0) {
|
||||
i3 = 1;
|
||||
}
|
||||
VideoCaptureActivity.a(albumActivity, 102, i3);
|
||||
}
|
||||
});
|
||||
return;
|
||||
}
|
||||
int i3 = this.g;
|
||||
if (i3 == 5) {
|
||||
i3 = this.f.size() == 0 ? 5 : 1;
|
||||
}
|
||||
VideoCaptureActivity.a(this, 102, i3);
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
if (i != 4) {
|
||||
return super.onKeyDown(i, keyEvent);
|
||||
}
|
||||
e(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void b(int i, Intent intent) {
|
||||
if (i == 0) {
|
||||
return;
|
||||
}
|
||||
String stringExtra = intent.getStringExtra("data");
|
||||
if (!TextUtils.isEmpty(stringExtra) && new File(stringExtra).exists()) {
|
||||
int intExtra = intent.getIntExtra("data_type", -1);
|
||||
if (1 == intExtra) {
|
||||
HPVideo searchVideoByName = HPVideo.searchVideoByName(this, stringExtra);
|
||||
if (searchVideoByName == null) {
|
||||
searchVideoByName = new HPVideo();
|
||||
searchVideoByName.setPath(stringExtra);
|
||||
searchVideoByName.setMediaType(intExtra);
|
||||
searchVideoByName.setSize(new File(stringExtra).length());
|
||||
searchVideoByName.setDuration(HPVideo.getVideoDuration(stringExtra));
|
||||
}
|
||||
HPVideo.getVideoThumnail(this, searchVideoByName);
|
||||
this.f.clear();
|
||||
this.f.add(searchVideoByName);
|
||||
} else {
|
||||
HPMedia searchImageByName = HPImage.searchImageByName(this, stringExtra);
|
||||
if (searchImageByName == null) {
|
||||
searchImageByName = new HPImage();
|
||||
searchImageByName.setId(0);
|
||||
searchImageByName.setPath(stringExtra);
|
||||
searchImageByName.setPreview(stringExtra);
|
||||
}
|
||||
this.f.add(searchImageByName);
|
||||
}
|
||||
e(true);
|
||||
}
|
||||
}
|
||||
|
||||
private void e(boolean z) {
|
||||
Intent intent = new Intent();
|
||||
if (z) {
|
||||
intent.putExtra("result_data", this.f);
|
||||
setResult(-1, intent);
|
||||
} else {
|
||||
setResult(0, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
|
||||
public static void a(Activity activity, int i, int i2, ArrayList<HPMedia> arrayList, int i3) {
|
||||
Intent intent = new Intent(activity, (Class<?>) AlbumActivity.class);
|
||||
intent.putExtra(FileDownloadModel.TOTAL, i2);
|
||||
intent.putExtra("input_selected", arrayList);
|
||||
intent.putExtra("type", i3);
|
||||
activity.startActivityForResult(intent, i);
|
||||
}
|
||||
|
||||
private void a(int i, Intent intent) {
|
||||
int indexOf;
|
||||
if (i == 0) {
|
||||
return;
|
||||
}
|
||||
List list = (List) intent.getSerializableExtra("selected");
|
||||
int intExtra = intent.getIntExtra("current", 0);
|
||||
int intExtra2 = intent.getIntExtra("type", -1);
|
||||
boolean booleanExtra = intent.getBooleanExtra("done", false);
|
||||
if (list == null) {
|
||||
list = new ArrayList();
|
||||
this.j.setEnabled(false);
|
||||
} else if (list.size() > 0) {
|
||||
this.j.setEnabled(true);
|
||||
} else {
|
||||
this.j.setEnabled(false);
|
||||
}
|
||||
this.f.clear();
|
||||
this.f.addAll(list);
|
||||
if (intExtra2 == 1) {
|
||||
if (list.size() > 0) {
|
||||
e(true);
|
||||
return;
|
||||
} else {
|
||||
indexOf = this.e.indexOf(n.get(intExtra));
|
||||
}
|
||||
} else {
|
||||
indexOf = this.e.indexOf(m.get(intExtra));
|
||||
}
|
||||
if (booleanExtra) {
|
||||
e(true);
|
||||
return;
|
||||
}
|
||||
Message message = new Message();
|
||||
message.what = 201;
|
||||
message.arg1 = indexOf;
|
||||
this.l.sendMessage(message);
|
||||
}
|
||||
|
||||
/* JADX INFO: Access modifiers changed from: private */
|
||||
public void a(Message message) {
|
||||
this.d.notifyDataSetChanged();
|
||||
this.c.smoothScrollToPosition(message.arg1);
|
||||
if (this.f.size() > 0) {
|
||||
this.j.setText(this.k + "(" + this.f.size() + "/" + this.h + ")");
|
||||
return;
|
||||
}
|
||||
this.j.setText(this.k);
|
||||
}
|
||||
|
||||
private int a(HPMedia hPMedia, List<HPMedia> list) {
|
||||
for (int i = 0; i < list.size(); i++) {
|
||||
if (hPMedia.getId() == list.get(i).getId()) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
}
|
262
sources/com/bottle/hp/album/selector/AlbumActivity2.java
Normal file
262
sources/com/bottle/hp/album/selector/AlbumActivity2.java
Normal file
@@ -0,0 +1,262 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
import android.app.Activity;
|
||||
import android.content.Intent;
|
||||
import android.os.Bundle;
|
||||
import android.view.KeyEvent;
|
||||
import android.view.View;
|
||||
import android.widget.Button;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
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.R$string;
|
||||
import com.bottle.hp.album.Utils;
|
||||
import com.bottle.hp.album.capture.VideoPreviewActivity;
|
||||
import com.bottle.hp.album.media.HPMedia;
|
||||
import com.bottle.hp.album.media.HPVideo;
|
||||
import com.bottle.hp.album.photoview.HackyViewPager;
|
||||
import com.bottle.hp.album.selector.AlbumAdapter2;
|
||||
import com.liulishuo.filedownloader.model.FileDownloadModel;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AlbumActivity2 extends BaseActivity implements View.OnClickListener, ViewPager.OnPageChangeListener, AlbumAdapter2.IPhotoViewUIListener {
|
||||
private RelativeLayout c;
|
||||
private ImageView d;
|
||||
private TextView e;
|
||||
private Button f;
|
||||
private CheckBox g;
|
||||
private HackyViewPager h;
|
||||
private AlbumAdapter2 i;
|
||||
private ImageView j;
|
||||
private List<HPMedia> k;
|
||||
private List<HPMedia> l;
|
||||
private int m;
|
||||
private int n;
|
||||
private int o;
|
||||
private String p;
|
||||
private ObjectAnimator q;
|
||||
private ObjectAnimator r;
|
||||
|
||||
private void E0() {
|
||||
HPMedia hPMedia = this.k.get(this.h.getCurrentItem());
|
||||
if (this.l.size() >= this.m && !hPMedia.isSelected()) {
|
||||
this.g.setChecked(false);
|
||||
a(String.format(getString(R$string.number_limit), this.m + ""), 0);
|
||||
return;
|
||||
}
|
||||
if (this.g.isChecked()) {
|
||||
this.l.add(hPMedia);
|
||||
hPMedia.setSelected(true);
|
||||
} else {
|
||||
Iterator<HPMedia> it = this.l.iterator();
|
||||
while (true) {
|
||||
if (!it.hasNext()) {
|
||||
break;
|
||||
}
|
||||
HPMedia next = it.next();
|
||||
if (hPMedia.getId() == next.getId()) {
|
||||
this.l.remove(next);
|
||||
break;
|
||||
}
|
||||
}
|
||||
hPMedia.setSelected(false);
|
||||
}
|
||||
if (this.l.size() <= 0) {
|
||||
this.f.setEnabled(false);
|
||||
this.f.setText(this.p);
|
||||
return;
|
||||
}
|
||||
this.f.setEnabled(true);
|
||||
this.f.setText(this.p + "(" + this.l.size() + "/" + this.m + ")");
|
||||
}
|
||||
|
||||
public static void a(Activity activity, int i, int i2, int i3, int i4, ArrayList<HPMedia> arrayList) {
|
||||
Intent intent = new Intent(activity, (Class<?>) AlbumActivity2.class);
|
||||
intent.putExtra(FileDownloadModel.TOTAL, i2);
|
||||
intent.putExtra("mediaType", i4);
|
||||
intent.putExtra("selected", arrayList);
|
||||
intent.putExtra("current", i3);
|
||||
activity.startActivityForResult(intent, i);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
this.p = "";
|
||||
Intent intent = getIntent();
|
||||
this.m = intent.getIntExtra(FileDownloadModel.TOTAL, 0);
|
||||
this.n = intent.getIntExtra("mediaType", -1);
|
||||
this.o = intent.getIntExtra("current", 0);
|
||||
this.k = new ArrayList();
|
||||
if (this.n == 1) {
|
||||
List<HPMedia> list = AlbumActivity.n;
|
||||
if (list != null) {
|
||||
this.k.addAll(list);
|
||||
}
|
||||
} else {
|
||||
List<HPMedia> list2 = AlbumActivity.m;
|
||||
if (list2 != null) {
|
||||
this.k.addAll(list2);
|
||||
}
|
||||
}
|
||||
this.l = (List) intent.getSerializableExtra("selected");
|
||||
this.i = new AlbumAdapter2(this, this.k, this.l, this.n, this);
|
||||
this.h.setAdapter(this.i);
|
||||
this.h.setCurrentItem(this.o);
|
||||
if (this.k.get(this.o).isSelected()) {
|
||||
this.g.setChecked(true);
|
||||
} else {
|
||||
this.g.setChecked(false);
|
||||
}
|
||||
this.e.setText((this.o + 1) + "/" + this.k.size());
|
||||
List<HPMedia> list3 = this.l;
|
||||
if (list3 == null || list3.size() <= 0) {
|
||||
this.f.setEnabled(false);
|
||||
this.l = new ArrayList();
|
||||
this.f.setText(this.p);
|
||||
} else {
|
||||
this.f.setEnabled(true);
|
||||
this.f.setText(this.p + "(" + this.l.size() + "/" + this.m + ")");
|
||||
}
|
||||
if (this.n == 1) {
|
||||
this.g.setVisibility(8);
|
||||
this.f.setVisibility(8);
|
||||
this.j.setVisibility(0);
|
||||
} else {
|
||||
this.g.setVisibility(0);
|
||||
this.f.setVisibility(0);
|
||||
this.j.setVisibility(8);
|
||||
}
|
||||
this.q = ObjectAnimator.ofFloat(this.c, "translationY", -Utils.a(this, 48.0f), 0.0f);
|
||||
this.q.setDuration(200L);
|
||||
this.r = ObjectAnimator.ofFloat(this.c, "translationY", 0.0f, -Utils.a(this, 48.0f));
|
||||
this.r.setDuration(200L);
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
this.c = (RelativeLayout) findViewById(R$id.rlActionBar);
|
||||
this.d = (ImageView) findViewById(R$id.imgBack);
|
||||
this.e = (TextView) findViewById(R$id.tvCurrent);
|
||||
this.f = (Button) findViewById(R$id.btnCompleted);
|
||||
this.g = (CheckBox) findViewById(R$id.cbChoose);
|
||||
this.h = (HackyViewPager) findViewById(R$id.hackyViewPager);
|
||||
this.j = (ImageView) findViewById(R$id.imgSelectVideo);
|
||||
this.f.setOnClickListener(this);
|
||||
this.g.setOnClickListener(this);
|
||||
this.d.setOnClickListener(this);
|
||||
this.h.setOnPageChangeListener(this);
|
||||
this.j.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.selector.AlbumAdapter2.IPhotoViewUIListener
|
||||
public void a(HPMedia hPMedia) {
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.selector.AlbumAdapter2.IPhotoViewUIListener
|
||||
public void b(HPMedia hPMedia) {
|
||||
VideoPreviewActivity.a(this, 101, hPMedia.getPath());
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
public void onActivityResult(int i, int i2, Intent intent) {
|
||||
super.onActivityResult(i, i2, intent);
|
||||
if (i == 101 && i2 == -1) {
|
||||
a(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R$id.imgBack) {
|
||||
a(true, false);
|
||||
return;
|
||||
}
|
||||
if (id == R$id.btnCompleted) {
|
||||
return;
|
||||
}
|
||||
if (id == R$id.cbChoose) {
|
||||
E0();
|
||||
return;
|
||||
}
|
||||
if (id == R$id.imgSelectVideo) {
|
||||
HPMedia hPMedia = this.k.get(this.h.getCurrentItem());
|
||||
HPVideo hPVideo = hPMedia instanceof HPVideo ? (HPVideo) hPMedia : null;
|
||||
if (hPVideo == null || hPVideo.getDuration() <= 20499) {
|
||||
a(true, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@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_album2);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
if (i != 4) {
|
||||
return super.onKeyDown(i, keyEvent);
|
||||
}
|
||||
a(true, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageScrolled(int i, float f, int i2) {
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageSelected(int i) {
|
||||
HPMedia hPMedia = this.k.get(i);
|
||||
if (hPMedia.isSelected()) {
|
||||
this.g.setChecked(true);
|
||||
} else {
|
||||
this.g.setChecked(false);
|
||||
}
|
||||
this.e.setText((i + 1) + "/" + this.k.size());
|
||||
if (hPMedia instanceof HPVideo) {
|
||||
if (((HPVideo) hPMedia).getDuration() > 20499) {
|
||||
this.j.setEnabled(false);
|
||||
} else {
|
||||
this.j.setEnabled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
private void a(boolean z, boolean z2) {
|
||||
if (this.n == 1 && z2) {
|
||||
this.l.add(this.k.get(this.h.getCurrentItem()));
|
||||
}
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("selected", (ArrayList) this.l);
|
||||
intent.putExtra("current", this.h.getCurrentItem());
|
||||
intent.putExtra("type", this.n);
|
||||
intent.putExtra("done", z2);
|
||||
if (z) {
|
||||
setResult(-1, intent);
|
||||
} else {
|
||||
setResult(0, intent);
|
||||
}
|
||||
finish();
|
||||
}
|
||||
}
|
149
sources/com/bottle/hp/album/selector/AlbumAdapter.java
Normal file
149
sources/com/bottle/hp/album/selector/AlbumAdapter.java
Normal file
@@ -0,0 +1,149 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.media.MediaPlayer;
|
||||
import android.net.Uri;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.CheckBox;
|
||||
import android.widget.CompoundButton;
|
||||
import android.widget.ImageView;
|
||||
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.Utils;
|
||||
import com.bottle.hp.album.media.HPMedia;
|
||||
import com.bottle.hp.album.media.HPVideo;
|
||||
import com.bumptech.glide.Glide;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AlbumAdapter extends BaseAdapter {
|
||||
private List<HPMedia> a;
|
||||
private Context b;
|
||||
private IAlbumAdapterUIListener c;
|
||||
|
||||
public interface IAlbumAdapterUIListener {
|
||||
void a(CompoundButton compoundButton, boolean z, HPMedia hPMedia);
|
||||
}
|
||||
|
||||
private class ViewHolder {
|
||||
public ImageView a;
|
||||
public CheckBox b;
|
||||
public RelativeLayout c;
|
||||
public TextView d;
|
||||
public TextView e;
|
||||
public ImageView f;
|
||||
|
||||
private ViewHolder(AlbumAdapter albumAdapter) {
|
||||
}
|
||||
}
|
||||
|
||||
public AlbumAdapter(Context context, List<HPMedia> list, IAlbumAdapterUIListener iAlbumAdapterUIListener) {
|
||||
this.b = context;
|
||||
this.a = list;
|
||||
this.c = iAlbumAdapterUIListener;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public int getCount() {
|
||||
return this.a.size();
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public Object getItem(int i) {
|
||||
return this.a.get(i);
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
public long getItemId(int i) {
|
||||
return i;
|
||||
}
|
||||
|
||||
@Override // android.widget.Adapter
|
||||
@SuppressLint({"InflateParams"})
|
||||
public View getView(int i, View view, ViewGroup viewGroup) {
|
||||
View view2;
|
||||
final ViewHolder viewHolder;
|
||||
if (view == null) {
|
||||
viewHolder = new ViewHolder();
|
||||
view2 = LayoutInflater.from(this.b).inflate(R$layout.adapter_album, (ViewGroup) null);
|
||||
viewHolder.a = (ImageView) view2.findViewById(R$id.adapter_gallery_item_img_snapshoot);
|
||||
viewHolder.b = (CheckBox) view2.findViewById(R$id.adapter_gallery_item_cb_selected);
|
||||
viewHolder.c = (RelativeLayout) view2.findViewById(R$id.llVideo);
|
||||
viewHolder.d = (TextView) view2.findViewById(R$id.tvDuration);
|
||||
viewHolder.e = (TextView) view2.findViewById(R$id.tvCapture);
|
||||
viewHolder.f = (ImageView) view2.findViewById(R$id.imgMask);
|
||||
view2.setTag(viewHolder);
|
||||
} else {
|
||||
view2 = view;
|
||||
viewHolder = (ViewHolder) view.getTag();
|
||||
}
|
||||
if (i == 0) {
|
||||
viewHolder.f.setVisibility(8);
|
||||
viewHolder.c.setVisibility(8);
|
||||
viewHolder.b.setVisibility(8);
|
||||
viewHolder.e.setVisibility(8);
|
||||
viewHolder.a.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
|
||||
viewHolder.a.setImageResource(R$mipmap.camera);
|
||||
return view2;
|
||||
}
|
||||
viewHolder.b.setVisibility(0);
|
||||
viewHolder.e.setVisibility(8);
|
||||
final HPMedia hPMedia = this.a.get(i);
|
||||
if (1 == hPMedia.getMediaType()) {
|
||||
HPVideo hPVideo = (HPVideo) hPMedia;
|
||||
viewHolder.b.setVisibility(8);
|
||||
viewHolder.c.setVisibility(0);
|
||||
if (hPVideo.getDuration() <= 0) {
|
||||
hPVideo.setDuration(MediaPlayer.create(this.b, Uri.parse(hPVideo.getPath())) != null ? r4.getDuration() : 0L);
|
||||
}
|
||||
viewHolder.d.setText(Utils.a(hPVideo.getDuration() + 500));
|
||||
if (hPVideo.getDuration() > 20499) {
|
||||
viewHolder.f.setVisibility(0);
|
||||
} else {
|
||||
viewHolder.f.setVisibility(8);
|
||||
}
|
||||
} else {
|
||||
viewHolder.f.setVisibility(8);
|
||||
viewHolder.b.setVisibility(0);
|
||||
viewHolder.c.setVisibility(8);
|
||||
}
|
||||
if (hPMedia.getMediaType() == 0) {
|
||||
Glide.e(this.b).a(hPMedia.getPreview()).a(viewHolder.a);
|
||||
} else if (TextUtils.isEmpty(hPMedia.getPreview())) {
|
||||
Bitmap a = Utils.a(this.b.getContentResolver(), hPMedia.getPath(), 3);
|
||||
viewHolder.a.setScaleType(ImageView.ScaleType.CENTER_CROP);
|
||||
if (a != null) {
|
||||
viewHolder.a.setImageBitmap(a);
|
||||
} else {
|
||||
viewHolder.a.setImageResource(R$mipmap.load_failed);
|
||||
}
|
||||
} else {
|
||||
Glide.e(this.b).a(hPMedia.getPreview()).a(viewHolder.a);
|
||||
}
|
||||
viewHolder.b.setOnClickListener(new View.OnClickListener() { // from class: com.bottle.hp.album.selector.AlbumAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view3) {
|
||||
if (AlbumAdapter.this.c != null) {
|
||||
IAlbumAdapterUIListener iAlbumAdapterUIListener = AlbumAdapter.this.c;
|
||||
CheckBox checkBox = viewHolder.b;
|
||||
iAlbumAdapterUIListener.a(checkBox, checkBox.isChecked(), hPMedia);
|
||||
}
|
||||
}
|
||||
});
|
||||
if (hPMedia.isSelected()) {
|
||||
viewHolder.b.setChecked(true);
|
||||
} else {
|
||||
viewHolder.b.setChecked(false);
|
||||
}
|
||||
return view2;
|
||||
}
|
||||
}
|
94
sources/com/bottle/hp/album/selector/AlbumAdapter2.java
Normal file
94
sources/com/bottle/hp/album/selector/AlbumAdapter2.java
Normal file
@@ -0,0 +1,94 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.media.ThumbnailUtils;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
import com.bottle.hp.album.R$id;
|
||||
import com.bottle.hp.album.R$layout;
|
||||
import com.bottle.hp.album.media.HPMedia;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class AlbumAdapter2 extends PagerAdapter {
|
||||
private List<HPMedia> a;
|
||||
private IPhotoViewUIListener b;
|
||||
private Context c;
|
||||
|
||||
public interface IPhotoViewUIListener {
|
||||
void a(HPMedia hPMedia);
|
||||
|
||||
void b(HPMedia hPMedia);
|
||||
}
|
||||
|
||||
public AlbumAdapter2(Context context, List<HPMedia> list, List<HPMedia> list2, int i, IPhotoViewUIListener iPhotoViewUIListener) {
|
||||
list = list == null ? new ArrayList<>() : list;
|
||||
if (list2 == null) {
|
||||
new ArrayList();
|
||||
}
|
||||
this.b = iPhotoViewUIListener;
|
||||
this.a = list;
|
||||
this.c = context;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
|
||||
viewGroup.removeView((View) obj);
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public int getCount() {
|
||||
return this.a.size();
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public boolean isViewFromObject(View view, Object obj) {
|
||||
return view == obj;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public View instantiateItem(ViewGroup viewGroup, int i) {
|
||||
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R$layout.adapter_album2, (ViewGroup) null);
|
||||
PhotoView photoView = (PhotoView) inflate.findViewById(R$id.photoView);
|
||||
photoView.setMaximumScale(8.0f);
|
||||
ImageView imageView = (ImageView) inflate.findViewById(R$id.imgPlay);
|
||||
final HPMedia hPMedia = this.a.get(i);
|
||||
if (hPMedia.getMediaType() == 0) {
|
||||
Glide.e(this.c).a(hPMedia.getPreview()).a((ImageView) photoView);
|
||||
imageView.setVisibility(8);
|
||||
} else {
|
||||
if (TextUtils.isEmpty(hPMedia.getPreview())) {
|
||||
photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
photoView.setImageBitmap(ThumbnailUtils.createVideoThumbnail(hPMedia.getPath(), 1));
|
||||
} else {
|
||||
Glide.e(this.c).a(hPMedia.getPreview()).a((ImageView) photoView);
|
||||
}
|
||||
imageView.setVisibility(0);
|
||||
}
|
||||
photoView.setOnClickListener(new View.OnClickListener() { // from class: com.bottle.hp.album.selector.AlbumAdapter2.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (AlbumAdapter2.this.b != null) {
|
||||
AlbumAdapter2.this.b.a(hPMedia);
|
||||
}
|
||||
}
|
||||
});
|
||||
imageView.setOnClickListener(new View.OnClickListener() { // from class: com.bottle.hp.album.selector.AlbumAdapter2.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (AlbumAdapter2.this.b != null) {
|
||||
AlbumAdapter2.this.b.b(hPMedia);
|
||||
}
|
||||
}
|
||||
});
|
||||
viewGroup.addView(inflate, -1, -1);
|
||||
return inflate;
|
||||
}
|
||||
}
|
54
sources/com/bottle/hp/album/selector/HPMediaComparator.java
Normal file
54
sources/com/bottle/hp/album/selector/HPMediaComparator.java
Normal file
@@ -0,0 +1,54 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import com.bottle.hp.album.Utils;
|
||||
import com.bottle.hp.album.media.HPMedia;
|
||||
import java.util.Comparator;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class HPMediaComparator implements Comparator<HPMedia> {
|
||||
@Override // java.util.Comparator
|
||||
/* renamed from: a, reason: merged with bridge method [inline-methods] */
|
||||
public int compare(HPMedia hPMedia, HPMedia hPMedia2) {
|
||||
String str;
|
||||
if (hPMedia == null && hPMedia2 == null) {
|
||||
return 0;
|
||||
}
|
||||
if (hPMedia == null) {
|
||||
return 1;
|
||||
}
|
||||
if (hPMedia2 == null) {
|
||||
return -1;
|
||||
}
|
||||
String str2 = null;
|
||||
try {
|
||||
str = hPMedia.getModifyDate();
|
||||
} catch (Exception unused) {
|
||||
str = null;
|
||||
}
|
||||
try {
|
||||
str2 = hPMedia2.getModifyDate();
|
||||
} catch (Exception unused2) {
|
||||
}
|
||||
if (str == null) {
|
||||
return 1;
|
||||
}
|
||||
if (str2 == null) {
|
||||
return -1;
|
||||
}
|
||||
if (str.equals(str2)) {
|
||||
return 0;
|
||||
}
|
||||
if (!Utils.b(str) || !Utils.b(str2)) {
|
||||
if (Utils.b(str) || Utils.b(str2)) {
|
||||
return !Utils.b(str) ? 1 : -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
long parseLong = Long.parseLong(hPMedia.getModifyDate());
|
||||
long parseLong2 = Long.parseLong(hPMedia2.getModifyDate());
|
||||
if (parseLong == parseLong2) {
|
||||
return 0;
|
||||
}
|
||||
return parseLong > parseLong2 ? -1 : 1;
|
||||
}
|
||||
}
|
216
sources/com/bottle/hp/album/selector/PhotoEditorActivity.java
Normal file
216
sources/com/bottle/hp/album/selector/PhotoEditorActivity.java
Normal file
@@ -0,0 +1,216 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import android.animation.ObjectAnimator;
|
||||
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.ImageView;
|
||||
import android.widget.RelativeLayout;
|
||||
import android.widget.TextView;
|
||||
import androidx.appcompat.app.AppCompatActivity;
|
||||
import androidx.viewpager.widget.ViewPager;
|
||||
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.bottle.hp.album.media.HPMedia;
|
||||
import com.bottle.hp.album.photoview.HackyViewPager;
|
||||
import com.bottle.hp.album.selector.PhotoEditorAdapter;
|
||||
import com.ubtrobot.log.ALog;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PhotoEditorActivity extends AppCompatActivity implements View.OnClickListener, PhotoEditorAdapter.IPhotoViewUIListener, ViewPager.OnPageChangeListener, VideoPlayFragment.IPlayListener {
|
||||
private final String a = PhotoEditorActivity.class.getSimpleName();
|
||||
private HackyViewPager b;
|
||||
private RelativeLayout c;
|
||||
private ImageView d;
|
||||
private TextView e;
|
||||
private ImageView f;
|
||||
private RelativeLayout g;
|
||||
private PhotoEditorAdapter h;
|
||||
private List<HPMedia> i;
|
||||
private VideoPlayFragment j;
|
||||
private ObjectAnimator k;
|
||||
private ObjectAnimator l;
|
||||
|
||||
private void D0() {
|
||||
Intent intent = new Intent();
|
||||
intent.putExtra("result_data", (ArrayList) this.i);
|
||||
setResult(-1, intent);
|
||||
finish();
|
||||
}
|
||||
|
||||
private void E0() {
|
||||
int currentItem = this.b.getCurrentItem();
|
||||
this.i.remove(currentItem);
|
||||
if (this.i.size() == 0) {
|
||||
this.h.notifyDataSetChanged();
|
||||
D0();
|
||||
return;
|
||||
}
|
||||
if (currentItem >= this.i.size() - 1) {
|
||||
currentItem = this.i.size() - 1;
|
||||
}
|
||||
this.e.setText((currentItem + 1) + "/" + this.i.size());
|
||||
this.h = new PhotoEditorAdapter(this, this.i, this);
|
||||
this.b.setAdapter(this.h);
|
||||
this.h.notifyDataSetChanged();
|
||||
this.b.setCurrentItem(currentItem);
|
||||
}
|
||||
|
||||
private void initData() {
|
||||
Intent intent = getIntent();
|
||||
this.i = (List) intent.getSerializableExtra("medias");
|
||||
final int intExtra = intent.getIntExtra("current", 0);
|
||||
this.h = new PhotoEditorAdapter(this, this.i, this);
|
||||
this.b.setAdapter(this.h);
|
||||
this.b.postDelayed(new Runnable() { // from class: com.bottle.hp.album.selector.PhotoEditorActivity.1
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
PhotoEditorActivity.this.b.setCurrentItem(intExtra);
|
||||
}
|
||||
}, 20L);
|
||||
this.e.setText((intExtra + 1) + "/" + this.i.size());
|
||||
this.k = ObjectAnimator.ofFloat(this.c, "translationY", (float) (-Utils.a(this, 48.0f)), 0.0f);
|
||||
this.k.setDuration(200L);
|
||||
this.l = ObjectAnimator.ofFloat(this.c, "translationY", 0.0f, (float) (-Utils.a(this, 48.0f)));
|
||||
this.l.setDuration(200L);
|
||||
this.j = VideoPlayFragment.a(null, false, true);
|
||||
getFragmentManager().beginTransaction().replace(R$id.rlVideoViewContainer, this.j).commit();
|
||||
}
|
||||
|
||||
private void initView() {
|
||||
this.b = (HackyViewPager) findViewById(R$id.hackyViewPager);
|
||||
this.c = (RelativeLayout) findViewById(R$id.rlActionBar);
|
||||
this.d = (ImageView) findViewById(R$id.imgBack);
|
||||
this.e = (TextView) findViewById(R$id.tvCurrent);
|
||||
this.f = (ImageView) findViewById(R$id.imgDelete);
|
||||
this.g = (RelativeLayout) findViewById(R$id.rlVideoViewContainer);
|
||||
this.d.setOnClickListener(this);
|
||||
this.f.setOnClickListener(this);
|
||||
this.b.setOnPageChangeListener(this);
|
||||
this.g.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
||||
public void m0() {
|
||||
this.c.setVisibility(0);
|
||||
this.k.start();
|
||||
}
|
||||
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
int id = view.getId();
|
||||
if (id == R$id.imgBack) {
|
||||
D0();
|
||||
} else if (id == R$id.imgDelete) {
|
||||
E0();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // 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_photo_editor);
|
||||
initView();
|
||||
initData();
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
||||
public void onFinished() {
|
||||
this.b.setVisibility(0);
|
||||
this.g.setVisibility(8);
|
||||
this.c.setVisibility(0);
|
||||
this.k.start();
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
||||
public boolean onInfo(MediaPlayer mediaPlayer, int i, int i2) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override // androidx.appcompat.app.AppCompatActivity, android.app.Activity, android.view.KeyEvent.Callback
|
||||
public boolean onKeyDown(int i, KeyEvent keyEvent) {
|
||||
if (i != 4) {
|
||||
return super.onKeyDown(i, keyEvent);
|
||||
}
|
||||
D0();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageScrollStateChanged(int i) {
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageScrolled(int i, float f, int i2) {
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
||||
public void onPageSelected(int i) {
|
||||
this.e.setText((i + 1) + "/" + this.i.size());
|
||||
}
|
||||
|
||||
@Override // androidx.fragment.app.FragmentActivity, android.app.Activity
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
VideoPlayFragment videoPlayFragment = this.j;
|
||||
if (videoPlayFragment != null) {
|
||||
videoPlayFragment.a();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
||||
public void onProgress(int i, int i2, int i3) {
|
||||
ALog.a(this.a).d("progress:" + i3);
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
||||
public void v0() {
|
||||
this.b.setVisibility(8);
|
||||
this.g.setVisibility(0);
|
||||
this.c.postDelayed(new Runnable() { // from class: com.bottle.hp.album.selector.PhotoEditorActivity.3
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
PhotoEditorActivity.this.c.setVisibility(8);
|
||||
}
|
||||
}, 200L);
|
||||
this.l.start();
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.selector.PhotoEditorAdapter.IPhotoViewUIListener
|
||||
public void a(HPMedia hPMedia) {
|
||||
if (this.c.getVisibility() == 0) {
|
||||
this.c.postDelayed(new Runnable() { // from class: com.bottle.hp.album.selector.PhotoEditorActivity.2
|
||||
@Override // java.lang.Runnable
|
||||
public void run() {
|
||||
PhotoEditorActivity.this.c.setVisibility(8);
|
||||
}
|
||||
}, 200L);
|
||||
this.l.start();
|
||||
} else {
|
||||
this.c.setVisibility(0);
|
||||
this.k.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.selector.PhotoEditorAdapter.IPhotoViewUIListener
|
||||
public void b(HPMedia hPMedia) {
|
||||
this.g.setVisibility(0);
|
||||
this.b.setVisibility(8);
|
||||
this.j.a(Uri.fromFile(new File(hPMedia.getPath())));
|
||||
this.j.b();
|
||||
}
|
||||
|
||||
@Override // com.bottle.hp.album.capture.VideoPlayFragment.IPlayListener
|
||||
public void b(String str) {
|
||||
Log.e(this.a, str);
|
||||
}
|
||||
}
|
93
sources/com/bottle/hp/album/selector/PhotoEditorAdapter.java
Normal file
93
sources/com/bottle/hp/album/selector/PhotoEditorAdapter.java
Normal file
@@ -0,0 +1,93 @@
|
||||
package com.bottle.hp.album.selector;
|
||||
|
||||
import android.content.Context;
|
||||
import android.graphics.Bitmap;
|
||||
import android.text.TextUtils;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.ImageView;
|
||||
import androidx.viewpager.widget.PagerAdapter;
|
||||
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.media.HPMedia;
|
||||
import com.bumptech.glide.Glide;
|
||||
import com.github.chrisbanes.photoview.PhotoView;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/* loaded from: classes.dex */
|
||||
public class PhotoEditorAdapter extends PagerAdapter {
|
||||
private List<HPMedia> a;
|
||||
private IPhotoViewUIListener b;
|
||||
private Context c;
|
||||
|
||||
public interface IPhotoViewUIListener {
|
||||
void a(HPMedia hPMedia);
|
||||
|
||||
void b(HPMedia hPMedia);
|
||||
}
|
||||
|
||||
public PhotoEditorAdapter(Context context, List<HPMedia> list, IPhotoViewUIListener iPhotoViewUIListener) {
|
||||
this.c = context;
|
||||
list = list == null ? new ArrayList<>() : list;
|
||||
this.b = iPhotoViewUIListener;
|
||||
this.a = list;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public void destroyItem(ViewGroup viewGroup, int i, Object obj) {
|
||||
viewGroup.removeView((View) obj);
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public int getCount() {
|
||||
return this.a.size();
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public boolean isViewFromObject(View view, Object obj) {
|
||||
return view == obj;
|
||||
}
|
||||
|
||||
@Override // androidx.viewpager.widget.PagerAdapter
|
||||
public View instantiateItem(ViewGroup viewGroup, int i) {
|
||||
View inflate = LayoutInflater.from(viewGroup.getContext()).inflate(R$layout.adapter_photo_eidtor, (ViewGroup) null);
|
||||
PhotoView photoView = (PhotoView) inflate.findViewById(R$id.photoView);
|
||||
ImageView imageView = (ImageView) inflate.findViewById(R$id.imgPlay);
|
||||
photoView.setMaximumScale(8.0f);
|
||||
final HPMedia hPMedia = this.a.get(i);
|
||||
if (1 == hPMedia.getMediaType()) {
|
||||
imageView.setVisibility(0);
|
||||
if (TextUtils.isEmpty(hPMedia.getPreview())) {
|
||||
Bitmap a = Utils.a(this.c.getContentResolver(), hPMedia.getPath(), 1);
|
||||
photoView.setScaleType(ImageView.ScaleType.FIT_CENTER);
|
||||
photoView.setImageBitmap(a);
|
||||
} else {
|
||||
Glide.e(this.c).a(hPMedia.getPreview()).a((ImageView) photoView);
|
||||
}
|
||||
} else {
|
||||
imageView.setVisibility(8);
|
||||
Glide.e(this.c).a(hPMedia.getPreview()).a((ImageView) photoView);
|
||||
}
|
||||
photoView.setOnClickListener(new View.OnClickListener() { // from class: com.bottle.hp.album.selector.PhotoEditorAdapter.1
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (PhotoEditorAdapter.this.b != null) {
|
||||
PhotoEditorAdapter.this.b.a(hPMedia);
|
||||
}
|
||||
}
|
||||
});
|
||||
imageView.setOnClickListener(new View.OnClickListener() { // from class: com.bottle.hp.album.selector.PhotoEditorAdapter.2
|
||||
@Override // android.view.View.OnClickListener
|
||||
public void onClick(View view) {
|
||||
if (PhotoEditorAdapter.this.b != null) {
|
||||
PhotoEditorAdapter.this.b.b(hPMedia);
|
||||
}
|
||||
}
|
||||
});
|
||||
viewGroup.addView(inflate, -1, -1);
|
||||
return inflate;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user