jimu-decompiled/sources/com/bottle/hp/album/selector/AlbumActivity2.java
2025-05-13 19:24:51 +02:00

263 lines
8.9 KiB
Java

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();
}
}