正在查看: Biko v2.0.23 应用的 ImageShowActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: Biko v2.0.23 应用的 ImageShowActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package app.callpe.ui.misc;
import android.content.ContentResolver;
import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.media.MediaScannerConnection;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Looper;
import android.provider.MediaStore;
import android.view.MenuItem;
import android.view.View;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import app.callpe.common.utils.glide.GlideImageLoaderFactory;
import app.callpe.data.repository.upload.DownloadProgressHelper;
import app.callpe.databinding.ActivityImageShowBinding;
import app.callpe.db.LocalDB;
import app.callpe.ui.login.LoginActivity;
import com.bumptech.glide.Glide;
import com.ouattararomuald.CustomViewPager;
import com.ouattararomuald.slider.SliderAdapter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.OpenOption;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import timber.log.Timber;
public class ImageShowActivity extends AppCompatActivity {
private static final String TAG = "ImageShowActivity";
ActivityImageShowBinding activityImageShowBinding;
DownloadProgressHelper progressHelper;
SliderAdapter setAdapter;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
ActivityImageShowBinding inflate = ActivityImageShowBinding.inflate(getLayoutInflater());
this.activityImageShowBinding = inflate;
setContentView(inflate.getRoot());
final Intent intent = getIntent();
setUpToolbar();
if (intent.hasExtra("pics")) {
setScreen();
this.activityImageShowBinding.photoView.setVisibility(8);
this.activityImageShowBinding.imageSlider.setVisibility(0);
} else {
this.activityImageShowBinding.photoView.setVisibility(0);
Glide.with(this).load(getIntent().getStringExtra("imageUrl")).into(this.activityImageShowBinding.photoView);
}
this.activityImageShowBinding.profileBtn.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ImageShowActivity.this.m1943lambda$onCreate$0$appcallpeuimiscImageShowActivity(intent, view);
}
});
if (getIntent().getBooleanExtra("support", false)) {
this.activityImageShowBinding.download.setVisibility(0);
this.progressHelper = new DownloadProgressHelper(this, this);
}
this.activityImageShowBinding.download.setOnClickListener(new View.OnClickListener() {
@Override
public final void onClick(View view) {
ImageShowActivity.this.m1944lambda$onCreate$1$appcallpeuimiscImageShowActivity(view);
}
});
if (LoginActivity.isVitok()) {
boolean booleanExtra = getIntent().getBooleanExtra("approved", false);
if (getIntent().getBooleanExtra("profileScreen", false)) {
if (booleanExtra) {
this.activityImageShowBinding.profileBtn.setVisibility(8);
} else {
this.activityImageShowBinding.profileBtn.setVisibility(0);
}
}
}
}
void m1943lambda$onCreate$0$appcallpeuimiscImageShowActivity(Intent intent, View view) {
CustomViewPager viewPager = this.activityImageShowBinding.imageSlider.getViewPager();
if (viewPager != null) {
int currentItem = viewPager.getCurrentItem();
String stringExtra = intent.getStringExtra("pics");
if (stringExtra.isEmpty()) {
return;
}
ArrayList arrayList = new ArrayList(Arrays.asList(stringExtra.split("\\s*,\\s*")));
String str = (String) arrayList.get(currentItem);
arrayList.remove(currentItem);
arrayList.add(0, str);
Intent intent2 = new Intent();
intent2.putExtra("pics", ImageShowActivity$$ExternalSyntheticBackport0.m(",", arrayList));
setResult(-1, intent2);
finish();
}
}
void m1944lambda$onCreate$1$appcallpeuimiscImageShowActivity(View view) {
String stringExtra = getIntent().getStringExtra("imageUrl");
if (stringExtra == null) {
finish();
}
DownloadProgressHelper downloadProgressHelper = this.progressHelper;
if (downloadProgressHelper != null) {
downloadProgressHelper.setWithoutProgressDialog();
}
downloadAndSaveImage(stringExtra, this);
}
private void setScreen() {
Intent intent = getIntent();
int i = -1;
if (intent.hasExtra("position")) {
i = intent.getIntExtra("position", -1);
Timber.tag(TAG).e("onCreate: %s", new Object[]{Integer.valueOf(i)});
}
int i2 = i;
if (intent.hasExtra("pics")) {
String stringExtra = intent.getStringExtra("pics");
Timber.tag(TAG).e("onCreate: %s", new Object[]{stringExtra});
if (stringExtra == null || stringExtra.isEmpty()) {
return;
}
List asList = Arrays.asList(stringExtra.split("\\s*,\\s*"));
if (intent.hasExtra("profile") && asList.size() > 1) {
this.activityImageShowBinding.profileBtn.setVisibility(0);
}
this.activityImageShowBinding.imageSlider.setPageIndicatorVisible(asList.size() != 1);
this.setAdapter = new SliderAdapter(this, new GlideImageLoaderFactory(), asList, Collections.emptyList(), (String) null, true, false);
this.activityImageShowBinding.imageSlider.setAdapter(this.setAdapter);
moveToPosition(i2);
this.setAdapter.setImageClickListener(new SliderAdapter.ImageViewClickListener() {
public void onItemClicked(String s, int i3, String s1) {
}
public void onRotateRightClicked(String s, int i3, float v, String s1) {
if (ImageShowActivity.this.setAdapter != null) {
ImageShowActivity.this.setAdapter.notifyDataSetChanged();
ImageShowActivity.this.activityImageShowBinding.imageSlider.setAdapter(ImageShowActivity.this.setAdapter);
ImageShowActivity.this.moveToPosition(i3);
}
}
public void onRotateLeft(String s, int i3, float v, String s1) {
if (ImageShowActivity.this.setAdapter != null) {
ImageShowActivity.this.setAdapter.notifyDataSetChanged();
ImageShowActivity.this.activityImageShowBinding.imageSlider.setAdapter(ImageShowActivity.this.setAdapter);
ImageShowActivity.this.moveToPosition(i3);
}
}
});
}
}
public void moveToPosition(int position) {
CustomViewPager viewPager;
if (position == -1 || (viewPager = this.activityImageShowBinding.imageSlider.getViewPager()) == null) {
return;
}
viewPager.setCurrentItem(position);
}
private void setUpToolbar() {
try {
this.activityImageShowBinding.imageToolbar.setTitle("");
setSupportActionBar(this.activityImageShowBinding.imageToolbar);
((ActionBar) Objects.requireNonNull(getSupportActionBar())).setDisplayHomeAsUpEnabled(true);
} catch (Exception e) {
Timber.tag(TAG).e(e, "setUpToolbar: Error ", new Object[0]);
}
}
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() != 16908332) {
return true;
}
onBackPressed();
return true;
}
private void downloadAndSaveImage(final String imageUrl, final Context context) {
LocalDB.databaseWriteExecutor.execute(new Runnable() {
@Override
public final void run() {
ImageShowActivity.this.m1942x9dc5b7f8(imageUrl, context);
}
});
}
void m1942x9dc5b7f8(String str, final Context context) {
try {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
httpURLConnection.setDoInput(true);
httpURLConnection.connect();
InputStream inputStream = httpURLConnection.getInputStream();
String str2 = "img_" + System.currentTimeMillis();
if (getIntent().getStringExtra("fileName") != null) {
str2 = getIntent().getStringExtra("fileName");
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
Toast.makeText(context, "Downloading...", 0).show();
}
});
if (Build.VERSION.SDK_INT >= 29) {
File file = new File(context.getCacheDir(), str2);
FileOutputStream fileOutputStream = new FileOutputStream(file);
byte[] bArr = new byte[4096];
while (true) {
int read = inputStream.read(bArr);
if (read == -1) {
break;
} else {
fileOutputStream.write(bArr, 0, read);
}
}
fileOutputStream.flush();
fileOutputStream.close();
ContentValues contentValues = new ContentValues();
contentValues.put("_display_name", str2);
contentValues.put("mime_type", "image/jpeg");
contentValues.put("relative_path", Environment.DIRECTORY_PICTURES);
ContentResolver contentResolver = context.getContentResolver();
Uri insert = contentResolver.insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, contentValues);
if (insert != null) {
OutputStream openOutputStream = contentResolver.openOutputStream(insert);
InputStream newInputStream = Files.newInputStream(file.toPath(), new OpenOption[0]);
byte[] bArr2 = new byte[4096];
while (true) {
int read2 = newInputStream.read(bArr2);
if (read2 == -1) {
break;
} else {
openOutputStream.write(bArr2, 0, read2);
}
}
openOutputStream.close();
newInputStream.close();
}
} else {
File file2 = new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DCIM), str2);
FileOutputStream fileOutputStream2 = new FileOutputStream(file2);
byte[] bArr3 = new byte[4096];
while (true) {
int read3 = inputStream.read(bArr3);
if (read3 == -1) {
break;
} else {
fileOutputStream2.write(bArr3, 0, read3);
}
}
fileOutputStream2.flush();
fileOutputStream2.close();
MediaScannerConnection.scanFile(context, new String[]{file2.getAbsolutePath()}, null, new MediaScannerConnection.MediaScannerConnectionClient() {
@Override
public void onMediaScannerConnected() {
}
@Override
public void onScanCompleted(String path, Uri uri) {
Timber.e("scanned completed %s", new Object[]{path});
Timber.e("scanned completed uri %s", new Object[]{uri});
}
});
}
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
ImageShowActivity.this.m1940xdb207eba(context);
}
});
} catch (Exception e) {
Timber.e(e);
new Handler(Looper.getMainLooper()).post(new Runnable() {
@Override
public final void run() {
ImageShowActivity.this.m1941x3c731b59(context, e);
}
});
}
}
void m1940xdb207eba(Context context) {
DownloadProgressHelper downloadProgressHelper = this.progressHelper;
if (downloadProgressHelper != null) {
downloadProgressHelper.dismiss(this);
}
Toast.makeText(context, "Image saved in gallery.", 0).show();
}
void m1941x3c731b59(Context context, Exception exc) {
DownloadProgressHelper downloadProgressHelper = this.progressHelper;
if (downloadProgressHelper != null) {
downloadProgressHelper.dismiss(this);
}
Toast.makeText(context, "Error " + exc.getMessage(), 0).show();
}
}