正在查看: St.John's v1.0.9 应用的 LearningTopicDescriptionActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 LearningTopicDescriptionActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.util.Base64;
import android.view.KeyEvent;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.webkit.JsResult;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.exoplayer2.C;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.model.LearningTopicModelClass;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LearningTopicDescriptionActivity extends AppCompatActivity {
private static final String TAG = "com.mcb.stjohnsemschool.activity.LearningTopicDescriptionActivity";
private int chapterId;
private Context context;
private ProgressDialog mProgress;
private TransparentProgressDialog mProgressbar;
private SharedPreferences mSharedPref;
private WebView mWebView;
private AppCompatActivity myActivity;
private int pos;
private SimpleDateFormat sdf;
private int topicId;
private String topicName = "";
private String subject = "";
private String subjectGUID = "";
private String subTopic = "";
private String studentEnrollmentId = "0";
private String startDate = "";
private String endDate = "";
private String topicsJson = "";
private ArrayList<LearningTopicModelClass> topics = new ArrayList<>();
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_learning_topic_description);
this.context = getApplicationContext();
this.myActivity = this;
this.mProgressbar = new TransparentProgressDialog(this.myActivity, R.drawable.spinner_loading_imag);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setDisplayShowTitleEnabled(true);
getSupportActionBar().setHomeButtonEnabled(true);
this.mProgress = ProgressDialog.show(this.myActivity, "", "Please wait for a moment...");
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a", Locale.US);
this.sdf = simpleDateFormat;
this.startDate = simpleDateFormat.format(new Date());
setUpIds();
}
private void setUpIds() {
SharedPreferences sharedPreferences = this.context.getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.studentEnrollmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
Bundle extras = getIntent().getExtras();
this.chapterId = extras.getInt("ChapterId", 0);
this.subject = extras.getString("SubjectName", "");
this.subjectGUID = extras.getString("SubjectGUID", "");
this.subTopic = extras.getString("SubTopic", "");
this.topicId = extras.getInt("TopicId", 0);
this.topicName = extras.getString("TopicName", getResources().getString(2131886124));
String string = extras.getString("Description", "");
getSupportActionBar().setTitle(this.topicName);
getSupportActionBar().setSubtitle(this.subTopic);
WebView webView = (WebView) findViewById(2131364517);
this.mWebView = webView;
webView.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView2, String str) {
return false;
}
@Override
public void onPageStarted(WebView webView2, String str, Bitmap bitmap) {
super.onPageStarted(webView2, str, bitmap);
}
@Override
public void onPageFinished(WebView webView2, String str) {
if (LearningTopicDescriptionActivity.this.mProgress.isShowing()) {
LearningTopicDescriptionActivity.this.mProgress.dismiss();
}
}
});
this.mWebView.setWebChromeClient(new WebChromeClient() {
@Override
public boolean onJsAlert(WebView webView2, String str, String str2, JsResult jsResult) {
return super.onJsAlert(webView2, str, str2, jsResult);
}
});
this.mWebView.setOnKeyListener(new View.OnKeyListener() {
@Override
public boolean onKey(View view, int i, KeyEvent keyEvent) {
if (i != 4 || !LearningTopicDescriptionActivity.this.mWebView.canGoBack()) {
return false;
}
LearningTopicDescriptionActivity.this.mWebView.goBack();
return true;
}
});
WebSettings settings = this.mWebView.getSettings();
settings.setJavaScriptEnabled(true);
settings.getAllowContentAccess();
settings.setDomStorageEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setDefaultFontSize(50);
settings.setDefaultTextEncodingName("utf-8");
try {
this.mWebView.loadData(Base64.encodeToString(string.getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
private void displayContent(LearningTopicModelClass learningTopicModelClass) {
this.topicId = learningTopicModelClass.getTopicId();
this.topicName = learningTopicModelClass.getTopicName();
getSupportActionBar().setTitle(this.topicName);
try {
this.mWebView.loadData(Base64.encodeToString(learningTopicModelClass.getDescription().getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.learning_menu, menu);
return super.onCreateOptionsMenu(menu);
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == 16908332) {
super.onBackPressed();
return true;
}
if (itemId == 2131361878) {
Intent intent = new Intent(this.context, (Class<?>) LearningTopicNoteActivity.class);
intent.putExtra("TopicId", this.topicId);
intent.putExtra("TopicName", this.topicName);
intent.putExtra("SubjectGUID", this.subjectGUID);
intent.putExtra("ChapterId", this.chapterId);
startActivity(intent);
return true;
}
return super.onOptionsItemSelected(menuItem);
}
protected void onResume() {
super.onResume();
String string = this.mSharedPref.getString("usernamekey", "");
Bundle bundle = new Bundle();
bundle.putString("user_name", string);
FirebaseAnalytics.getInstance(this).logEvent("PAGE_LEARNING_TOPIC_CONTENT", bundle);
this.endDate = "";
if (Utility.hasNetworkConnection(this.context)) {
saveSubjectTopicsViewLog();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void saveSubjectTopicsViewLog() {
HashMap hashMap = new HashMap();
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("SubjectSyllabusID", String.valueOf(this.chapterId));
hashMap.put("TopicID", String.valueOf(this.topicId));
hashMap.put("StartDate", this.startDate);
hashMap.put("endDate", this.endDate);
hashMap.put("apikey", Utility.getSchoolApiKey(this.context));
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).SaveSubjectTopicsViewLog(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (response == null || response.body() == null) {
Utility.showAlertDialog(LearningTopicDescriptionActivity.this.myActivity);
}
}
public void onFailure(Call<String> call, Throwable th) {
Utility.showAlertDialog(LearningTopicDescriptionActivity.this.myActivity);
}
});
}
}