正在查看: St.John's v1.0.9 应用的 LearningVideoWebViewActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 LearningVideoWebViewActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.os.AsyncTask;
import android.os.Bundle;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.LinearLayout;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
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.BufferedInputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.net.URL;
import java.net.URLConnection;
public class LearningVideoWebViewActivity extends AppCompatActivity {
private static final String TAG = "com.mcb.stjohnsemschool.activity.LearningVideoWebViewActivity";
private boolean allowDownload;
private int chapterId;
private boolean isFile;
private boolean isLearning;
private ImageView mDownload;
private TransparentProgressDialog mProgressbar;
private int resourceId;
private int topicId;
private VideoEnabledWebView webView;
private String subjectGUID = "";
private String url = "";
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_video_enabled_webview);
this.url = getIntent().getStringExtra("URL");
getIntent().getStringExtra("Title");
Bundle extras = getIntent().getExtras();
this.isLearning = extras.getBoolean("IsLearning", false);
this.allowDownload = extras.getBoolean("AllowDownload", false);
if (this.isLearning) {
this.subjectGUID = extras.getString("SubjectGUID", "");
this.chapterId = extras.getInt("ChapterId", 0);
this.topicId = extras.getInt("TopicId", 0);
this.resourceId = extras.getInt("ResourceId", 0);
this.isFile = extras.getBoolean("IsFile", false);
}
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
ImageView imageView = (ImageView) findViewById(R.id.img_download);
this.mDownload = imageView;
imageView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
LearningVideoWebViewActivity.this.download();
}
});
if (this.allowDownload) {
String str = this.url;
if (new File(Utility.getDownloadStorageDir(getApplicationContext()) + "/MyClassBoard/" + str.substring(str.lastIndexOf("/") + 1)).exists()) {
this.mDownload.setVisibility(8);
} else {
this.mDownload.setVisibility(0);
}
} else {
this.mDownload.setVisibility(8);
}
LinearLayout linearLayout = (LinearLayout) findViewById(R.id.ll_main);
VideoEnabledWebView findViewById = findViewById(2131364517);
this.webView = findViewById;
findViewById.getSettings().setLoadsImagesAutomatically(true);
this.webView.getSettings().setJavaScriptEnabled(true);
this.webView.getSettings().getAllowContentAccess();
this.webView.getSettings().setDomStorageEnabled(true);
this.webView.getSettings().setSupportMultipleWindows(true);
this.webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
this.webView.getSettings().setAllowFileAccess(true);
this.webView.getSettings().setBuiltInZoomControls(true);
this.webView.getSettings().setDisplayZoomControls(false);
this.webView.getSettings().setLoadWithOverviewMode(true);
this.webView.getSettings().setUseWideViewPort(true);
this.webView.getSettings().setSupportZoom(true);
this.webView.getSettings().setDefaultTextEncodingName("utf-8");
VideoEnabledWebChromeClient videoEnabledWebChromeClient = new VideoEnabledWebChromeClient(linearLayout, (ViewGroup) findViewById(R.id.videoLayout), getLayoutInflater().inflate(R.layout.view_loading_video, (ViewGroup) null), this.webView) {
public void onProgressChanged(WebView webView, int i) {
}
};
videoEnabledWebChromeClient.setOnToggledFullscreen(new VideoEnabledWebChromeClient.ToggledFullscreenCallback() {
public void toggledFullscreen(boolean z) {
if (z) {
WindowManager.LayoutParams attributes = LearningVideoWebViewActivity.this.getWindow().getAttributes();
attributes.flags |= 1024;
attributes.flags |= 128;
LearningVideoWebViewActivity.this.getWindow().setAttributes(attributes);
LearningVideoWebViewActivity.this.getWindow().getDecorView().setSystemUiVisibility(1);
return;
}
WindowManager.LayoutParams attributes2 = LearningVideoWebViewActivity.this.getWindow().getAttributes();
attributes2.flags &= -1025;
attributes2.flags &= -129;
LearningVideoWebViewActivity.this.getWindow().setAttributes(attributes2);
LearningVideoWebViewActivity.this.getWindow().getDecorView().setSystemUiVisibility(0);
}
});
this.webView.setWebChromeClient(videoEnabledWebChromeClient);
this.webView.loadUrl(this.url);
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public void onBackPressed() {
if (this.webView.canGoBack()) {
this.webView.goBack();
} else {
super.onBackPressed();
}
}
protected void onResume() {
super.onResume();
String string = getSharedPreferences("", 0).getString("usernamekey", "");
Bundle bundle = new Bundle();
bundle.putString("user_name", string);
FirebaseAnalytics.getInstance(this).logEvent("PAGE_LEARNING_VIDEOS", bundle);
}
protected void onDestroy() {
if (this.isLearning) {
if (this.isFile) {
Utility.saveFileViewLog(getApplicationContext(), this.subjectGUID, this.chapterId, this.topicId, this.resourceId, 1);
} else {
Utility.saveVideoViewLog(getApplicationContext(), this.subjectGUID, this.chapterId, this.topicId, this.resourceId, 1);
}
}
super.onDestroy();
}
public void download() {
if (Utility.hasNetworkConnection(getApplicationContext())) {
new DownloadFileAsync(this.url).execute(new String[0]);
} else {
Utility.showInfoDialog(this, "Please check your internet connection");
}
}
class DownloadFileAsync extends AsyncTask<String, String, String> {
private String imageUrl;
public DownloadFileAsync(String str) {
this.imageUrl = str;
}
@Override
protected void onPreExecute() {
super.onPreExecute();
if (LearningVideoWebViewActivity.this.mProgressbar == null || LearningVideoWebViewActivity.this.mProgressbar.isShowing()) {
return;
}
LearningVideoWebViewActivity.this.mProgressbar.show();
}
@Override
public String doInBackground(String... strArr) {
try {
try {
URL url = new URL(this.imageUrl);
URLConnection openConnection = url.openConnection();
openConnection.connect();
int contentLength = openConnection.getContentLength();
File file = new File(Utility.getDownloadStorageDir(LearningVideoWebViewActivity.this.getApplicationContext()) + "/MyClassBoard/");
if (!file.exists()) {
file.mkdirs();
}
String str = this.imageUrl;
String substring = str.substring(str.lastIndexOf("/") + 1);
BufferedInputStream bufferedInputStream = new BufferedInputStream(url.openStream());
FileOutputStream fileOutputStream = new FileOutputStream(file + "/" + substring);
byte[] bArr = new byte[1024];
long j = 0;
while (true) {
int read = bufferedInputStream.read(bArr);
if (read != -1) {
j += read;
long j2 = (100 * j) / contentLength;
fileOutputStream.write(bArr, 0, read);
} else {
fileOutputStream.flush();
fileOutputStream.close();
bufferedInputStream.close();
return null;
}
}
} catch (FileNotFoundException e) {
e.printStackTrace();
return null;
}
} catch (Exception e2) {
e2.printStackTrace();
return null;
}
}
@Override
public void onPostExecute(String str) {
if (LearningVideoWebViewActivity.this.mProgressbar != null && LearningVideoWebViewActivity.this.mProgressbar.isShowing()) {
LearningVideoWebViewActivity.this.mProgressbar.dismiss();
}
String str2 = this.imageUrl;
File file = new File(Utility.getDownloadStorageDir(LearningVideoWebViewActivity.this.getApplicationContext()) + "/MyClassBoard/" + str2.substring(str2.lastIndexOf("/") + 1));
if (file.exists()) {
LearningVideoWebViewActivity.this.mDownload.setVisibility(8);
} else {
LearningVideoWebViewActivity.this.mDownload.setVisibility(0);
}
Utility.showInfoDialog(LearningVideoWebViewActivity.this, "Downloaded to " + file.getAbsolutePath());
}
}
}