正在查看: 用信花 v1.1.3 应用的 PictureMultiCuttingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: 用信花 v1.1.3 应用的 PictureMultiCuttingActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.yalantis.ucrop;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.text.TextUtils;
import android.view.View;
import android.view.animation.AnimationUtils;
import android.widget.FrameLayout;
import android.widget.RelativeLayout;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import androidx.recyclerview.widget.SimpleItemAnimator;
import com.luck.picture.lib.R;
import com.luck.picture.lib.config.PictureMimeType;
import com.luck.picture.lib.entity.LocalMedia;
import com.luck.picture.lib.tools.DateUtils;
import com.luck.picture.lib.tools.PictureFileUtils;
import com.luck.picture.lib.tools.ScreenUtils;
import com.luck.picture.lib.tools.SdkVersionUtils;
import com.yalantis.ucrop.PicturePhotoGalleryAdapter;
import com.yalantis.ucrop.UCrop;
import java.io.File;
import java.util.ArrayList;
import java.util.Objects;
public class PictureMultiCuttingActivity extends UCropActivity {
private static final int MIN_NUM = 1;
private int cutIndex;
private boolean isAnimation;
private boolean isCamera;
private boolean isWithVideoImage;
private final ArrayList<LocalMedia> list = new ArrayList<>();
private PicturePhotoGalleryAdapter mAdapter;
private RecyclerView mRecyclerView;
private int oldCutIndex;
private String renameCropFilename;
private void addPhotoRecyclerView() {
boolean booleanExtra = getIntent().getBooleanExtra(UCrop.Options.EXTRA_SKIP_MULTIPLE_CROP, true);
RecyclerView recyclerView = new RecyclerView(this);
this.mRecyclerView = recyclerView;
int i = R.id.id_recycler;
recyclerView.setId(i);
this.mRecyclerView.setBackgroundColor(ContextCompat.getColor(this, R.color.ucrop_color_widget_background));
this.mRecyclerView.setLayoutParams(new RelativeLayout.LayoutParams(-1, ScreenUtils.dip2px(this, 80.0f)));
LinearLayoutManager linearLayoutManager = new LinearLayoutManager(this);
linearLayoutManager.setOrientation(0);
if (this.isAnimation) {
this.mRecyclerView.setLayoutAnimation(AnimationUtils.loadLayoutAnimation(getApplicationContext(), R.anim.ucrop_layout_animation_fall_down));
}
this.mRecyclerView.setLayoutManager(linearLayoutManager);
SimpleItemAnimator itemAnimator = this.mRecyclerView.getItemAnimator();
Objects.requireNonNull(itemAnimator);
itemAnimator.setSupportsChangeAnimations(false);
resetCutDataStatus();
this.list.get(this.cutIndex).setCut(true);
PicturePhotoGalleryAdapter picturePhotoGalleryAdapter = new PicturePhotoGalleryAdapter(this.list);
this.mAdapter = picturePhotoGalleryAdapter;
this.mRecyclerView.setAdapter(picturePhotoGalleryAdapter);
if (booleanExtra) {
this.mAdapter.setOnItemClickListener(new PicturePhotoGalleryAdapter.OnItemClickListener() {
@Override
public void onItemClick(int i3, View view) {
if (PictureMimeType.isHasVideo(((LocalMedia) PictureMultiCuttingActivity.this.list.get(i3)).getMimeType()) || PictureMultiCuttingActivity.this.cutIndex == i3) {
return;
}
PictureMultiCuttingActivity.this.resetLastCropStatus();
PictureMultiCuttingActivity.this.cutIndex = i3;
PictureMultiCuttingActivity pictureMultiCuttingActivity = PictureMultiCuttingActivity.this;
pictureMultiCuttingActivity.oldCutIndex = pictureMultiCuttingActivity.cutIndex;
PictureMultiCuttingActivity.this.resetCutData();
}
});
}
this.uCropPhotoBox.addView(this.mRecyclerView);
changeLayoutParams(this.mShowBottomControls);
((RelativeLayout.LayoutParams) ((FrameLayout) findViewById(R.id.ucrop_frame)).getLayoutParams()).addRule(2, i);
((RelativeLayout.LayoutParams) this.mRecyclerView.getLayoutParams()).addRule(2, R.id.controls_wrapper);
}
private void changeLayoutParams(boolean z) {
if (this.mRecyclerView.getLayoutParams() == null) {
return;
}
if (z) {
((RelativeLayout.LayoutParams) this.mRecyclerView.getLayoutParams()).addRule(12, 0);
((RelativeLayout.LayoutParams) this.mRecyclerView.getLayoutParams()).addRule(2, R.id.wrapper_controls);
} else {
((RelativeLayout.LayoutParams) this.mRecyclerView.getLayoutParams()).addRule(12);
((RelativeLayout.LayoutParams) this.mRecyclerView.getLayoutParams()).addRule(2, 0);
}
}
private void getIndex(int i) {
for (int i3 = 0; i3 < i; i3++) {
LocalMedia localMedia = this.list.get(i3);
if (localMedia != null && PictureMimeType.isHasImage(localMedia.getMimeType())) {
this.cutIndex = i3;
return;
}
}
}
private void initLoadCutData() {
ArrayList<LocalMedia> arrayList = this.list;
if (arrayList == null || arrayList.size() == 0) {
onBackPressed();
return;
}
int size = this.list.size();
if (this.isWithVideoImage) {
getIndex(size);
}
}
private void refreshPhotoRecyclerData() {
resetCutDataStatus();
this.list.get(this.cutIndex).setCut(true);
this.mAdapter.notifyItemChanged(this.cutIndex);
this.uCropPhotoBox.addView(this.mRecyclerView);
changeLayoutParams(this.mShowBottomControls);
((RelativeLayout.LayoutParams) ((FrameLayout) findViewById(R.id.ucrop_frame)).getLayoutParams()).addRule(2, R.id.id_recycler);
((RelativeLayout.LayoutParams) this.mRecyclerView.getLayoutParams()).addRule(2, R.id.controls_wrapper);
}
private void resetCutDataStatus() {
int size = this.list.size();
for (int i = 0; i < size; i++) {
this.list.get(i).setCut(false);
}
}
public void resetLastCropStatus() {
int i;
int size = this.list.size();
if (size <= 1 || size <= (i = this.oldCutIndex)) {
return;
}
this.list.get(i).setCut(false);
this.mAdapter.notifyItemChanged(this.cutIndex);
}
@Override
public void onCreate(Bundle bundle) {
super.onCreate(bundle);
Intent intent = getIntent();
this.renameCropFilename = intent.getStringExtra(UCrop.Options.EXTRA_RENAME_CROP_FILENAME);
this.isCamera = intent.getBooleanExtra(UCrop.Options.EXTRA_CAMERA, false);
this.isWithVideoImage = intent.getBooleanExtra(UCrop.Options.EXTRA_WITH_VIDEO_IMAGE, false);
ArrayList parcelableArrayListExtra = getIntent().getParcelableArrayListExtra(UCrop.Options.EXTRA_CUT_CROP);
this.isAnimation = getIntent().getBooleanExtra(UCrop.Options.EXTRA_MULTIPLE_RECYCLERANIMATION, true);
if (parcelableArrayListExtra == null || parcelableArrayListExtra.size() == 0) {
onBackPressed();
return;
}
this.list.addAll(parcelableArrayListExtra);
if (this.list.size() > 1) {
initLoadCutData();
addPhotoRecyclerView();
}
}
public void onDestroy() {
PicturePhotoGalleryAdapter picturePhotoGalleryAdapter = this.mAdapter;
if (picturePhotoGalleryAdapter != null) {
picturePhotoGalleryAdapter.setOnItemClickListener(null);
}
super.onDestroy();
}
public void resetCutData() {
String rename;
this.uCropPhotoBox.removeView(this.mRecyclerView);
View view = this.mBlockingView;
if (view != null) {
this.uCropPhotoBox.removeView(view);
}
setContentView(R.layout.ucrop_activity_photobox);
this.uCropPhotoBox = (RelativeLayout) findViewById(R.id.ucrop_photobox);
addBlockingView();
Intent intent = getIntent();
Bundle extras = intent.getExtras();
if (extras == null) {
extras = new Bundle();
}
LocalMedia localMedia = this.list.get(this.cutIndex);
String path = localMedia.getPath();
boolean isHasHttp = PictureMimeType.isHasHttp(path);
String lastImgType = PictureMimeType.getLastImgType(PictureMimeType.isContent(path) ? PictureFileUtils.getPath(this, Uri.parse(path)) : path);
Uri fromFile = localMedia.isToSandboxPath() ? Uri.fromFile(new File(localMedia.getAndroidQToPath())) : (isHasHttp || PictureMimeType.isContent(path)) ? Uri.parse(path) : Uri.fromFile(new File(path));
extras.putInt(UCrop.Options.EXTRA_INPUT_IMAGE_WIDTH, localMedia.getWidth());
extras.putInt(UCrop.Options.EXTRA_INPUT_IMAGE_HEIGHT, localMedia.getHeight());
extras.putParcelable(UCrop.EXTRA_INPUT_URI, fromFile);
File externalFilesDir = Environment.getExternalStorageState().equals("mounted") ? getExternalFilesDir(Environment.DIRECTORY_PICTURES) : getCacheDir();
if (TextUtils.isEmpty(this.renameCropFilename)) {
rename = DateUtils.getCreateFileName("IMG_CROP_") + lastImgType;
} else {
rename = this.isCamera ? this.renameCropFilename : PictureFileUtils.rename(this.renameCropFilename);
}
extras.putParcelable(UCrop.EXTRA_OUTPUT_URI, Uri.fromFile(new File(externalFilesDir, rename)));
intent.putExtras(extras);
setupViews(intent);
refreshPhotoRecyclerData();
setImageData(intent);
setInitialState();
double dip2px = this.cutIndex * ScreenUtils.dip2px(this, 60.0f);
int i = this.mScreenWidth;
if (dip2px > i * 0.8d) {
this.mRecyclerView.scrollBy(ScreenUtils.dip2px(this, 60.0f), 0);
} else if (dip2px < i * 0.4d) {
this.mRecyclerView.scrollBy(ScreenUtils.dip2px(this, -60.0f), 0);
}
}
@Override
public void setResultUri(Uri uri, float f, int i, int i3, int i10, int i11) {
try {
int size = this.list.size();
int i12 = this.cutIndex;
if (size < i12) {
onBackPressed();
return;
}
LocalMedia localMedia = this.list.get(i12);
localMedia.setCutPath(uri.getPath());
localMedia.setCut(true);
localMedia.setCropResultAspectRatio(f);
localMedia.setCropOffsetX(i);
localMedia.setCropOffsetY(i3);
localMedia.setCropImageWidth(i10);
localMedia.setCropImageHeight(i11);
localMedia.setAndroidQToPath(SdkVersionUtils.checkedAndroid_Q() ? localMedia.getCutPath() : localMedia.getAndroidQToPath());
resetLastCropStatus();
int i13 = this.cutIndex + 1;
this.cutIndex = i13;
if (this.isWithVideoImage && i13 < this.list.size() && PictureMimeType.isHasVideo(this.list.get(this.cutIndex).getMimeType())) {
while (this.cutIndex < this.list.size() && !PictureMimeType.isHasImage(this.list.get(this.cutIndex).getMimeType())) {
this.cutIndex++;
}
}
int i14 = this.cutIndex;
this.oldCutIndex = i14;
if (i14 < this.list.size()) {
resetCutData();
return;
}
for (int i15 = 0; i15 < this.list.size(); i15++) {
LocalMedia localMedia2 = this.list.get(i15);
localMedia2.setCut(!TextUtils.isEmpty(localMedia2.getCutPath()));
}
setResult(-1, new Intent().putExtra(UCrop.Options.EXTRA_OUTPUT_URI_LIST, this.list));
onBackPressed();
} catch (Exception e) {
e.printStackTrace();
}
}
}