191 lines
7.0 KiB
Java
191 lines
7.0 KiB
Java
package com.ubt.jimu.widgets.choosePhotos;
|
|
|
|
import android.app.Activity;
|
|
import android.content.Intent;
|
|
import android.view.View;
|
|
import android.widget.CheckBox;
|
|
import android.widget.CompoundButton;
|
|
import android.widget.ImageView;
|
|
import androidx.viewpager.widget.ViewPager;
|
|
import com.bottle.hp.album.photoview.HackyViewPager;
|
|
import com.ubt.jimu.R;
|
|
import com.ubt.jimu.base.SuperActivity;
|
|
import com.ubt.jimu.utils.SPUtils;
|
|
import com.ubt.jimu.utils.TSnackbarUtils;
|
|
import com.ubt.jimu.widgets.choosePhotos.media.HPMedia;
|
|
import com.ubt.jimu.widgets.player.UbtPlayerView;
|
|
import java.util.ArrayList;
|
|
import java.util.Iterator;
|
|
import java.util.Map;
|
|
|
|
/* loaded from: classes2.dex */
|
|
public class PreviewActivity extends SuperActivity implements View.OnClickListener, ViewPager.OnPageChangeListener {
|
|
private ArrayList<HPMedia> a;
|
|
ArrayList<HPMedia> b;
|
|
private int c = 1;
|
|
CheckBox cbChoose;
|
|
private View d;
|
|
private PreviewAdapter e;
|
|
private String f;
|
|
private int g;
|
|
ImageView im_preview_back;
|
|
HackyViewPager mHackyViewPager;
|
|
|
|
@Override // com.ubt.jimu.base.SuperActivity
|
|
public void initData() {
|
|
Intent intent = getIntent();
|
|
this.b = (ArrayList) intent.getSerializableExtra("selected");
|
|
this.a = (ArrayList) SPUtils.c("data");
|
|
this.c = intent.getIntExtra("startIndex", 1);
|
|
this.g = intent.getIntExtra("selectedAmount", 10);
|
|
this.e = new PreviewAdapter(this, this.a, this.b);
|
|
this.e.a(this.a);
|
|
this.mHackyViewPager.setOffscreenPageLimit(0);
|
|
this.mHackyViewPager.setAdapter(this.e);
|
|
this.mHackyViewPager.setCurrentItem(this.c);
|
|
this.cbChoose.setChecked(this.a.get(this.c).isSelected());
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.SuperActivity
|
|
public void initEvent() {
|
|
this.im_preview_back.setOnClickListener(this);
|
|
this.mHackyViewPager.setOnPageChangeListener(this);
|
|
this.cbChoose.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { // from class: com.ubt.jimu.widgets.choosePhotos.PreviewActivity.1
|
|
@Override // android.widget.CompoundButton.OnCheckedChangeListener
|
|
public void onCheckedChanged(CompoundButton compoundButton, boolean z) {
|
|
if (z && PreviewActivity.this.b.size() >= PreviewActivity.this.g) {
|
|
TSnackbarUtils.a(PreviewActivity.this.d, PreviewActivity.this.getString(R.string.choose_more_pictures));
|
|
PreviewActivity.this.cbChoose.setChecked(false);
|
|
return;
|
|
}
|
|
HPMedia hPMedia = (HPMedia) PreviewActivity.this.a.get(PreviewActivity.this.mHackyViewPager.getCurrentItem());
|
|
if (z) {
|
|
hPMedia.setSelected(true);
|
|
Iterator<HPMedia> it = PreviewActivity.this.b.iterator();
|
|
while (it.hasNext()) {
|
|
if (it.next().getId() == hPMedia.getId()) {
|
|
return;
|
|
}
|
|
}
|
|
PreviewActivity.this.b.add(hPMedia);
|
|
return;
|
|
}
|
|
int i = 0;
|
|
while (true) {
|
|
if (i >= PreviewActivity.this.b.size()) {
|
|
break;
|
|
}
|
|
if (hPMedia.getId() == PreviewActivity.this.b.get(i).getId()) {
|
|
PreviewActivity.this.b.remove(i);
|
|
break;
|
|
}
|
|
i++;
|
|
}
|
|
hPMedia.setSelected(false);
|
|
}
|
|
});
|
|
}
|
|
|
|
@Override // com.ubt.jimu.base.SuperActivity
|
|
public View initView() {
|
|
this.d = View.inflate(this, R.layout.activity_preview_layout, null);
|
|
return this.d;
|
|
}
|
|
|
|
@Override // android.view.View.OnClickListener
|
|
public void onClick(View view) {
|
|
int id = view.getId();
|
|
if (id == R.id.btnCompleted) {
|
|
Intent intent = new Intent();
|
|
SPUtils.a("ResultDate", this.a);
|
|
intent.putExtra("selected", this.b);
|
|
setResult(105, intent);
|
|
finish();
|
|
return;
|
|
}
|
|
if (id != R.id.im_preview_back) {
|
|
return;
|
|
}
|
|
Intent intent2 = new Intent();
|
|
SPUtils.a("ResultDate", this.a);
|
|
intent2.putExtra("selected", this.b);
|
|
setResult(101, intent2);
|
|
finish();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onDestroy() {
|
|
super.onDestroy();
|
|
}
|
|
|
|
@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) {
|
|
Map<String, UbtPlayerView> a;
|
|
if (i == 0) {
|
|
this.mHackyViewPager.setCurrentItem(1);
|
|
}
|
|
if (this.mHackyViewPager == null || (a = this.e.a()) == null || a.size() == 0) {
|
|
return;
|
|
}
|
|
UbtPlayerView ubtPlayerView = a.get(i + "");
|
|
if (ubtPlayerView == null) {
|
|
return;
|
|
}
|
|
HPMedia hPMedia = this.a.get(i);
|
|
if (hPMedia.isVideo()) {
|
|
this.f = hPMedia.getPath();
|
|
ubtPlayerView.setVideoPath(this.f);
|
|
ubtPlayerView.f();
|
|
}
|
|
}
|
|
|
|
@Override // androidx.viewpager.widget.ViewPager.OnPageChangeListener
|
|
public void onPageSelected(int i) {
|
|
ArrayList<HPMedia> arrayList = this.a;
|
|
if (arrayList == null || arrayList.size() < i) {
|
|
return;
|
|
}
|
|
HPMedia hPMedia = this.a.get(i);
|
|
if (hPMedia.isSelected()) {
|
|
this.cbChoose.setChecked(true);
|
|
} else {
|
|
this.cbChoose.setChecked(false);
|
|
}
|
|
Map<String, UbtPlayerView> a = this.e.a();
|
|
if (a == null || a.size() == 0) {
|
|
return;
|
|
}
|
|
if (a.get(i + "") == null) {
|
|
return;
|
|
}
|
|
this.f = hPMedia.getPath();
|
|
}
|
|
|
|
@Override // com.ubt.jimu.BaseActivity, com.ubt.jimu.ScreenRotationManageActivity, androidx.fragment.app.FragmentActivity, android.app.Activity
|
|
protected void onPause() {
|
|
Map<String, UbtPlayerView> a;
|
|
super.onPause();
|
|
PreviewAdapter previewAdapter = this.e;
|
|
if (previewAdapter == null || (a = previewAdapter.a()) == null || a.size() <= 0) {
|
|
return;
|
|
}
|
|
Iterator<UbtPlayerView> it = a.values().iterator();
|
|
while (it.hasNext()) {
|
|
it.next().g();
|
|
}
|
|
}
|
|
|
|
public static void a(Activity activity, ArrayList<HPMedia> arrayList, ArrayList<HPMedia> arrayList2, int i, int i2) {
|
|
Intent intent = new Intent(activity, (Class<?>) PreviewActivity.class);
|
|
intent.putExtra("selected", arrayList2);
|
|
intent.putExtra("selectedAmount", i);
|
|
SPUtils.a("data", arrayList);
|
|
intent.putExtra("startIndex", i2);
|
|
activity.startActivityForResult(intent, 101);
|
|
}
|
|
}
|