正在查看: St.John's v1.0.9 应用的 DetailGalleryActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 DetailGalleryActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Dialog;
import android.app.Fragment;
import android.app.FragmentTransaction;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.Typeface;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.ImageView;
import android.widget.TableLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.bumptech.glide.Glide;
import com.bumptech.glide.request.RequestOptions;
import com.google.android.exoplayer2.text.ttml.TtmlNode;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mcb.stjohnsemschool.model.AttachmentModel;
import com.mcb.stjohnsemschool.model.FilePathModelClass;
import com.mcb.stjohnsemschool.quiltview.QuiltView;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.util.ArrayList;
import java.util.Iterator;
public class DetailGalleryActivity extends BaseActivity {
private Typeface fontMuseo;
private RecyclerView galImgsRv;
private String heading;
private String mAssinId;
private Context mContext;
private TextView mDescriptionText;
private TextView mEventDateText;
private TableLayout mGallery;
private TextView mHeadingText;
private ProgressDialog mProgressDialog;
private TransparentProgressDialog mProgressbar;
private AppCompatActivity myActivity;
private String name;
private QuiltView quiltView;
private final String TAG = DetailGalleryActivity.class.getName();
private final int DIALOG_DOWNLOAD_PROGRESS = 0;
private ArrayList<FilePathModelClass> mFilepthList = new ArrayList<>();
private String description = "";
public boolean onCreateOptionsMenu(Menu menu) {
return true;
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_gallery_detail);
this.mContext = getApplicationContext();
this.fontMuseo = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
setUpIds();
this.myActivity = this;
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Bundle extras = getIntent().getExtras();
this.mAssinId = extras.getString(TtmlNode.ATTR_ID);
this.heading = extras.getString("heading");
String string = extras.getString("date");
this.description = extras.getString("description");
ArrayList arrayList = (ArrayList) new Gson().fromJson(extras.getString("AttachmentsStr"), new TypeToken<ArrayList<AttachmentModel>>() {
}.getType());
this.mFilepthList.clear();
Iterator it = arrayList.iterator();
while (true) {
String str = "";
if (!it.hasNext()) {
break;
}
AttachmentModel attachmentModel = (AttachmentModel) it.next();
int attachmentType = attachmentModel.getAttachmentType();
if (attachmentType == 1) {
String replace = attachmentModel.getFilePath().replace("\\", "/").replace(" ", "%20");
str = replace.substring(replace.lastIndexOf("/") + 1);
}
FilePathModelClass filePathModelClass = new FilePathModelClass();
filePathModelClass.setFileName(str);
filePathModelClass.setDisplayFileName(attachmentModel.getFileName());
filePathModelClass.setFilePath(attachmentModel.getFilePath());
filePathModelClass.setAttachmentType(attachmentType);
this.mFilepthList.add(filePathModelClass);
}
addImagesQuilts(this.mFilepthList);
this.name = this.heading;
getSupportActionBar().setTitle(this.heading);
this.mEventDateText.setText(Html.fromHtml(string));
String str2 = this.description;
if (str2 != null && !str2.equalsIgnoreCase("null") && !this.description.equals("")) {
this.mDescriptionText.setText(Html.fromHtml(this.description));
} else {
this.mDescriptionText.setVisibility(8);
}
if (Build.VERSION.SDK_INT >= 23) {
getMultiplePermissions();
}
}
private void setUpIds() {
RecyclerView findViewById = findViewById(R.id.gal_imgs_rv);
this.galImgsRv = findViewById;
findViewById.setLayoutManager(new LinearLayoutManager(this));
this.galImgsRv.setNestedScrollingEnabled(false);
this.mEventDateText = (TextView) findViewById(R.id.event_date_detail);
this.mHeadingText = (TextView) findViewById(R.id.event_heading_detail);
this.mDescriptionText = (TextView) findViewById(R.id.event_description_detail);
this.mEventDateText.setTypeface(this.fontMuseo);
this.mHeadingText.setTypeface(this.fontMuseo);
this.mDescriptionText.setTypeface(this.fontMuseo);
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
this.mGallery = (TableLayout) findViewById(R.id.tl_gallery);
QuiltView findViewById2 = findViewById(R.id.quilt_view);
this.quiltView = findViewById2;
findViewById2.setChildPadding(5);
}
protected Dialog onCreateDialog(int i) {
if (i != 0) {
return null;
}
ProgressDialog progressDialog = new ProgressDialog(this);
this.mProgressDialog = progressDialog;
progressDialog.setMessage("Downloading file..");
this.mProgressDialog.setProgressStyle(1);
this.mProgressDialog.setCancelable(false);
this.mProgressDialog.show();
return this.mProgressDialog;
}
public boolean onKeyDown(int i, KeyEvent keyEvent) {
if (keyEvent.getKeyCode() != 4 || keyEvent.getAction() != 0) {
return false;
}
setResult(565, new Intent());
finish();
overridePendingTransition(R.anim.left_in, R.anim.right_out);
return true;
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
super.onBackPressed();
return true;
}
if (menuItem.getItemId() == 2131361887) {
try {
Intent intent = new Intent("android.intent.action.SEND");
intent.putExtra("android.intent.extra.TEXT", "\n Using MyClassboard :St Johns EM High School Parent Mobile App\n" + ((Object) Html.fromHtml(this.name)) + "\n" + ((Object) Html.fromHtml(this.description)) + "\n App available at \n " + getResources().getString(R.string.playstore_url) + getApplicationContext().getPackageName());
intent.setType("text/plain");
intent.putExtra("android.intent.extra.SUBJECT", "Using MyClassboard :St Johns EM High School Parent Mobile App");
startActivity(Intent.createChooser(intent, "Share via..."));
} catch (Exception e) {
e.printStackTrace();
}
}
return super.onOptionsItemSelected(menuItem);
}
public void addImagesQuilts(final ArrayList<FilePathModelClass> arrayList) {
int size = arrayList.size();
ArrayList arrayList2 = new ArrayList();
for (final int i = 0; i < size; i++) {
FilePathModelClass filePathModelClass = new FilePathModelClass();
ImageView imageView = new ImageView(getApplicationContext());
imageView.setTag(R.id.glide_tag, Integer.valueOf(i));
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
FilePathModelClass filePathModelClass2 = (FilePathModelClass) arrayList.get(((Integer) view.getTag(R.id.glide_tag)).intValue());
String filePath = filePathModelClass2.getFilePath();
if (filePath == null || filePath.length() <= 0 || filePath.equalsIgnoreCase("null")) {
Toast.makeText(DetailGalleryActivity.this.mContext, "Image not available", 0).show();
return;
}
if (filePathModelClass2.getAttachmentType() == 2) {
if (filePath.contains("vimeo")) {
Intent intent = new Intent(DetailGalleryActivity.this.mContext, (Class<?>) LearningVideoWebViewActivity.class);
intent.addFlags(268435456);
intent.putExtra("URL", filePath);
intent.putExtra("Title", filePathModelClass2.getDisplayFileName() == null ? filePathModelClass2.getFileName() : filePathModelClass2.getDisplayFileName());
DetailGalleryActivity.this.mContext.startActivity(intent);
return;
}
FragmentTransaction beginTransaction = DetailGalleryActivity.this.getFragmentManager().beginTransaction();
Fragment findFragmentByTag = DetailGalleryActivity.this.getFragmentManager().findFragmentByTag("dialog");
if (findFragmentByTag != null) {
beginTransaction.remove(findFragmentByTag);
}
beginTransaction.addToBackStack(null);
Intent intent2 = new Intent((Context) DetailGalleryActivity.this, (Class<?>) LearningVideoActivity.class);
intent2.putExtra("VIDEO_URL", filePath);
DetailGalleryActivity.this.startActivity(intent2);
return;
}
if (filePath.toLowerCase().endsWith(".gif") || filePath.toLowerCase().endsWith(".jpg") || filePath.toLowerCase().endsWith(".jpeg") || filePath.toLowerCase().endsWith(".png") || filePath.toLowerCase().endsWith(".heic") || filePath.toLowerCase().endsWith(".heif")) {
Intent intent3 = new Intent(DetailGalleryActivity.this.getApplicationContext(), (Class<?>) GalleryImageViewPagerActivity.class);
intent3.putParcelableArrayListExtra("array", arrayList);
intent3.putExtra("position", i);
intent3.putExtra("title", DetailGalleryActivity.this.heading);
DetailGalleryActivity.this.startActivity(intent3);
return;
}
try {
Intent intent4 = new Intent("android.intent.action.VIEW", Uri.parse(filePath));
intent4.addFlags(268435456);
DetailGalleryActivity.this.mContext.startActivity(intent4);
} catch (Exception e) {
e.printStackTrace();
}
}
});
imageView.setScaleType(ImageView.ScaleType.CENTER_CROP);
String filePath = arrayList.get(i).getFilePath();
int attachmentType = arrayList.get(i).getAttachmentType();
if (filePath == null || filePath.length() <= 0 || filePath.equalsIgnoreCase("null")) {
imageView.setImageResource(R.drawable.noimage);
} else if (attachmentType == 2) {
imageView.getOverlay().add(getResources().getDrawable(R.drawable.play));
Glide.with(this.mContext).load(Utility.getThumbnailFromYoutubeURL(filePath)).apply(new RequestOptions().placeholder(R.drawable.image_link_icon)).into(imageView);
} else if (filePath.toLowerCase().endsWith(".gif") || filePath.toLowerCase().endsWith(".jpg") || filePath.toLowerCase().endsWith(".jpeg") || filePath.toLowerCase().endsWith(".png") || filePath.toLowerCase().endsWith(".heic") || filePath.toLowerCase().endsWith(".heif")) {
Glide.with(this.mContext).load(filePath).apply(new RequestOptions().placeholder(R.drawable.loadingbar2)).into(imageView);
} else {
imageView.setImageResource(R.drawable.image_link_icon);
}
filePathModelClass.setImage(imageView);
filePathModelClass.setAttachmentType(attachmentType);
arrayList2.add(filePathModelClass);
}
this.quiltView.addPatchImages(arrayList2);
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
}