正在查看: St.John's v1.0.9 应用的 DetailAnnouncementActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 DetailAnnouncementActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.text.Html;
import android.util.Base64;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.ViewGroup;
import android.view.ViewTreeObserver;
import android.view.WindowManager;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.LinearLayout;
import android.widget.ScrollView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.exoplayer2.C;
import com.mcb.stjohnsemschool.adapter.DetailAdapter;
import com.mcb.stjohnsemschool.model.AnnouncementAttachmentModel;
import com.mcb.stjohnsemschool.model.AnnouncementDetailModel;
import com.mcb.stjohnsemschool.model.FilePathModelClass;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.ExpandedListViewCustom;
import com.mcb.stjohnsemschool.utils.Filename;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.mcb.stjohnsemschool.utils.VideoEnabledWebChromeClient;
import com.mcb.stjohnsemschool.utils.VideoEnabledWebView;
import java.io.UnsupportedEncodingException;
import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Iterator;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class DetailAnnouncementActivity extends BaseActivity {
private String announcementId;
private String date;
private String description;
private String heading;
int lastScrollPosition;
private ExpandedListViewCustom mAttachedFiles;
private ExpandedListViewCustom mAttachedImagesVideos;
private Context mContext;
private VideoEnabledWebView mDescriptionText;
private TextView mHeadingText;
private Typeface mLatoFont;
private LinearLayout mMainLL;
private TextView mMessageDate;
private TransparentProgressDialog mProgressbar;
private ScrollView mScroll;
private SharedPreferences mSharedPref;
private AppCompatActivity myActivity;
private ArrayList<String> pdfPathsList;
private VideoEnabledWebChromeClient webChromeClient;
ArrayList<FilePathModelClass> fileList = new ArrayList<>();
ArrayList<FilePathModelClass> videoOrImgList = new ArrayList<>();
private String userId = "0";
private int themeId = 1;
private String TAG = DetailAnnouncementActivity.class.getName();
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_announcements_detail);
this.mContext = getApplicationContext();
getSupportActionBar().setTitle("Announcement");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
this.pdfPathsList = new ArrayList<>();
this.mLatoFont = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
SharedPreferences sharedPreferences = getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.userId = sharedPreferences.getString("UseridKey", this.userId);
this.myActivity = this;
setUpIds();
this.announcementId = getIntent().getExtras().getString("AnnouncementId");
this.heading = getIntent().getExtras().getString("Heading");
this.date = getIntent().getExtras().getString("Date");
this.themeId = this.mSharedPref.getInt("ThemeIdKey", this.themeId);
getAnnouncementsDetails();
if (Build.VERSION.SDK_INT >= 23) {
getMultiplePermissions();
}
}
private void setUpIds() {
this.mMainLL = (LinearLayout) findViewById(R.id.ll_main);
this.mHeadingText = (TextView) findViewById(R.id.announcements_heading_detail);
this.mDescriptionText = findViewById(R.id.announcements_description_detail);
this.mMessageDate = (TextView) findViewById(R.id.announcements_date_detail);
ScrollView scrollView = (ScrollView) findViewById(R.id.scrl);
this.mScroll = scrollView;
scrollView.getViewTreeObserver().addOnScrollChangedListener(new ViewTreeObserver.OnScrollChangedListener() {
@Override
public void onScrollChanged() {
int scrollY = DetailAnnouncementActivity.this.mScroll.getScrollY();
int i = DetailAnnouncementActivity.this.lastScrollPosition > scrollY ? DetailAnnouncementActivity.this.lastScrollPosition - scrollY : 0;
if (scrollY > DetailAnnouncementActivity.this.lastScrollPosition) {
i = scrollY - DetailAnnouncementActivity.this.lastScrollPosition;
}
if (i > 150) {
DetailAnnouncementActivity.this.lastScrollPosition = scrollY;
DetailAnnouncementActivity.this.resetVideos();
}
}
});
this.mDescriptionText.getSettings().setJavaScriptEnabled(true);
this.mDescriptionText.getSettings().setDefaultFontSize(16);
this.mDescriptionText.setHorizontalScrollBarEnabled(false);
this.mDescriptionText.setVerticalScrollBarEnabled(false);
this.mDescriptionText.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
try {
DetailAnnouncementActivity.this.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
return true;
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
});
VideoEnabledWebChromeClient videoEnabledWebChromeClient = new VideoEnabledWebChromeClient(this.mMainLL, (ViewGroup) findViewById(R.id.videoLayout), getLayoutInflater().inflate(R.layout.view_loading_video, (ViewGroup) null), this.mDescriptionText) {
public void onProgressChanged(WebView webView, int i) {
}
};
this.webChromeClient = videoEnabledWebChromeClient;
videoEnabledWebChromeClient.setOnToggledFullscreen(new VideoEnabledWebChromeClient.ToggledFullscreenCallback() {
public void toggledFullscreen(boolean z) {
if (z) {
WindowManager.LayoutParams attributes = DetailAnnouncementActivity.this.getWindow().getAttributes();
attributes.flags |= 1024;
attributes.flags |= 128;
DetailAnnouncementActivity.this.getWindow().setAttributes(attributes);
DetailAnnouncementActivity.this.getWindow().getDecorView().setSystemUiVisibility(1);
return;
}
WindowManager.LayoutParams attributes2 = DetailAnnouncementActivity.this.getWindow().getAttributes();
attributes2.flags &= -1025;
attributes2.flags &= -129;
DetailAnnouncementActivity.this.getWindow().setAttributes(attributes2);
DetailAnnouncementActivity.this.getWindow().getDecorView().setSystemUiVisibility(0);
}
});
this.mDescriptionText.setWebChromeClient(this.webChromeClient);
this.mMainLL.setVisibility(8);
this.mHeadingText.setTypeface(this.mLatoFont, 1);
this.mMessageDate.setTypeface(this.mLatoFont);
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
this.mAttachedFiles = findViewById(R.id.listview_announcements_files);
this.mAttachedImagesVideos = findViewById(R.id.listview_announcements_images_videos);
}
private void getAnnouncementsDetails() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
getAnnouncementDetailsById();
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void getAnnouncementDetailsById() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.mContext).create(ApiInterface.class)).GetAnnouncementsDetails(Integer.parseInt(this.announcementId), Integer.parseInt(this.userId), Utility.getSchoolApiKey(this.mContext)).enqueue(new Callback<AnnouncementDetailModel>() {
public void onResponse(Call<AnnouncementDetailModel> call, Response<AnnouncementDetailModel> response) {
String str;
if (DetailAnnouncementActivity.this.mProgressbar != null && DetailAnnouncementActivity.this.mProgressbar.isShowing()) {
DetailAnnouncementActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(DetailAnnouncementActivity.this.myActivity);
return;
}
DetailAnnouncementActivity.this.pdfPathsList.clear();
AnnouncementDetailModel announcementDetailModel = (AnnouncementDetailModel) response.body();
if (announcementDetailModel != null) {
DetailAnnouncementActivity.this.description = announcementDetailModel.getDescription();
DetailAnnouncementActivity.this.mHeadingText.setText(Html.fromHtml(DetailAnnouncementActivity.this.heading));
try {
DetailAnnouncementActivity.this.mDescriptionText.loadData(Base64.encodeToString(DetailAnnouncementActivity.this.description.getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
DetailAnnouncementActivity.this.mMessageDate.setText(Html.fromHtml(DetailAnnouncementActivity.this.date));
ArrayList attachments = announcementDetailModel.getAttachments();
DetailAnnouncementActivity.this.fileList.clear();
DetailAnnouncementActivity.this.videoOrImgList.clear();
if (attachments != null && attachments.size() > 0) {
Iterator it = attachments.iterator();
while (it.hasNext()) {
AnnouncementAttachmentModel announcementAttachmentModel = (AnnouncementAttachmentModel) it.next();
String filePath = announcementAttachmentModel.getFilePath();
DetailAnnouncementActivity.this.pdfPathsList.add(filePath);
if (announcementAttachmentModel.getFileName() == null) {
str = "";
} else {
str = announcementAttachmentModel.getFileName();
}
String replace = filePath.replace("\\", "/").replace(" ", "%20");
String substring = replace.substring(replace.lastIndexOf("/") + 1);
FilePathModelClass filePathModelClass = new FilePathModelClass();
filePathModelClass.setFileName(substring);
filePathModelClass.setFilePath(replace);
filePathModelClass.setDisplayFileName(str);
String extension = new Filename(replace, '/', '.').extension();
if (extension.equalsIgnoreCase("AVI") || extension.equalsIgnoreCase("MP4") || extension.equalsIgnoreCase("M4P") || extension.equalsIgnoreCase("M4V") || extension.equalsIgnoreCase("WMV") || extension.equalsIgnoreCase("MOV") || extension.equalsIgnoreCase("WEBM") || extension.equalsIgnoreCase("MPG") || extension.equalsIgnoreCase("MP2") || extension.equalsIgnoreCase("MPEG") || extension.equalsIgnoreCase("MPE") || extension.equalsIgnoreCase("MPV") || extension.equalsIgnoreCase("OGG") || extension.equalsIgnoreCase("FLV") || extension.equalsIgnoreCase("MKV") || extension.equalsIgnoreCase("png") || extension.equalsIgnoreCase("jpg") || extension.equalsIgnoreCase("jpeg") || extension.equalsIgnoreCase("heic") || extension.equalsIgnoreCase("heif")) {
DetailAnnouncementActivity.this.videoOrImgList.add(filePathModelClass);
} else {
DetailAnnouncementActivity.this.fileList.add(filePathModelClass);
}
}
}
?? r0 = DetailAnnouncementActivity.this;
DetailAnnouncementActivity.this.mAttachedFiles.setAdapter(new DetailAdapter((Context) r0, (Activity) r0, r0.fileList, "Announcements"));
?? r02 = DetailAnnouncementActivity.this;
DetailAnnouncementActivity.this.mAttachedImagesVideos.setAdapter(new DetailAdapter((Context) r02, (Activity) r02, r02.videoOrImgList, "Announcements"));
DetailAnnouncementActivity.this.mMainLL.setVisibility(0);
}
}
public void onFailure(Call<AnnouncementDetailModel> call, Throwable th) {
if (DetailAnnouncementActivity.this.mProgressbar != null && DetailAnnouncementActivity.this.mProgressbar.isShowing()) {
DetailAnnouncementActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(DetailAnnouncementActivity.this.myActivity);
}
});
}
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 onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.share_main, menu);
return true;
}
public boolean onMenuOpened(int i, Menu menu) {
if (menu != null && menu.getClass().getSimpleName().equals("MenuBuilder")) {
try {
Method declaredMethod = menu.getClass().getDeclaredMethod("setOptionalIconsVisible", Boolean.TYPE);
declaredMethod.setAccessible(true);
declaredMethod.invoke(menu, true);
} catch (NoSuchMethodException unused) {
} catch (Exception e) {
throw new RuntimeException(e);
}
}
return super.onMenuOpened(i, menu);
}
public boolean share(MenuItem menuItem) {
try {
Intent intent = new Intent("android.intent.action.SEND");
StringBuffer stringBuffer = new StringBuffer();
for (int i = 0; i < this.pdfPathsList.size(); i++) {
stringBuffer.append(this.pdfPathsList.get(i));
stringBuffer.append("<br />");
stringBuffer.append("<br />");
}
intent.putExtra("android.intent.extra.TEXT", "\n Using MyClassBoard :St Johns EM High School Parent Portal Mobile App \n" + ((Object) Html.fromHtml(this.heading)) + "\n" + ((Object) Html.fromHtml(this.date)) + "\n" + ((Object) Html.fromHtml(this.description)) + "\n" + ((Object) Html.fromHtml(stringBuffer.toString())) + "\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 Portal Mobile App");
startActivity(Intent.createChooser(intent, "Share via.."));
return true;
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
public void onPause() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
resetVideos();
super.onPause();
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public void resetVideos() {
Iterator<FilePathModelClass> it = this.videoOrImgList.iterator();
while (it.hasNext()) {
FilePathModelClass next = it.next();
if (next.getPlayerView() != null && next.getPlayerView().getPlayer() != null) {
next.getPlayerView().getPlayer().setPlayWhenReady(false);
next.getDownloadImage().setVisibility(0);
next.getImage().setVisibility(0);
next.getVideoView().setVisibility(8);
}
}
}
private void releaseVideos() {
Iterator<FilePathModelClass> it = this.videoOrImgList.iterator();
while (it.hasNext()) {
FilePathModelClass next = it.next();
if (next.getPlayerView() != null && next.getPlayerView().getPlayer() != null) {
next.getPlayerView().getPlayer().release();
next.getDownloadImage().setVisibility(0);
next.getImage().setVisibility(0);
next.getVideoView().setVisibility(8);
}
}
}
public void onBackPressed() {
int i = this.themeId;
if (i == 1) {
if (this.webChromeClient.onBackPressed()) {
return;
}
if (this.mDescriptionText.canGoBack()) {
this.mDescriptionText.goBack();
return;
} else {
super.onBackPressed();
return;
}
}
if (i == 2) {
if (!this.webChromeClient.onBackPressed()) {
Intent intent = new Intent(this.mContext, (Class<?>) NavigationActivity.class);
intent.putExtra("ToActivity", "announcements");
intent.putExtra("MenuTitle", "Announcements");
startActivity(intent);
this.myActivity.finish();
return;
}
super.onBackPressed();
return;
}
if (this.webChromeClient.onBackPressed()) {
return;
}
if (this.mDescriptionText.canGoBack()) {
this.mDescriptionText.goBack();
} else {
super.onBackPressed();
}
}
protected void onDestroy() {
releaseVideos();
super.onDestroy();
getDelegate().onDestroy();
}
}