正在查看: St.John's v1.0.9 应用的 LearningTopicContentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 LearningTopicContentActivity.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.net.Uri;
import android.os.Bundle;
import android.util.Base64;
import android.util.Log;
import android.view.MenuItem;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
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.adapter.LearningTopicContentsAdapter;
import com.mcb.stjohnsemschool.model.LearningChapterTopicModelClass;
import com.mcb.stjohnsemschool.model.LearningContentModel;
import com.mcb.stjohnsemschool.model.LearningSubTopicModelClass;
import com.mcb.stjohnsemschool.model.LearningTopicDetailsModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.NonScrollListView;
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.Iterator;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LearningTopicContentActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener {
private static final String TAG = "com.mcb.stjohnsemschool.activity.LearningTopicContentActivity";
private Activity activity;
private int chapterId;
private Context context;
private NonScrollListView mContent;
private WebView mDesc;
private Spinner mNavItems;
private TextView mNoData;
private TransparentProgressDialog mProgressbar;
private int topicId;
private String studentEnrollmentId = "0";
private String academicYearId = "0";
private String classId = "0";
private String userId = "0";
private String orgId = "0";
private String branchId = "0";
private String subjectName = "";
private String subjectGUID = "";
private String chapterName = "";
private ArrayList<LearningChapterTopicModelClass> topics = new ArrayList<>();
private ArrayList<LearningContentModel> content = new ArrayList<>();
private ArrayList<LearningContentModel> contentDup = new ArrayList<>();
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_learning_topic_content);
setSupportActionBar(findViewById(R.id.toolbar));
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("");
this.activity = this;
Context applicationContext = getApplicationContext();
this.context = applicationContext;
SharedPreferences sharedPreferences = applicationContext.getSharedPreferences("", 0);
this.classId = sharedPreferences.getString("ClassidKey", this.classId);
this.academicYearId = sharedPreferences.getString("academicyearIdKey", this.academicYearId);
this.userId = sharedPreferences.getString("UseridKey", this.userId);
this.studentEnrollmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
this.branchId = sharedPreferences.getString("BranchIdKey", this.branchId);
this.orgId = sharedPreferences.getString("orgnizationIdKey", this.orgId);
this.mProgressbar = new TransparentProgressDialog(this.activity, R.drawable.spinner_loading_imag);
initializations();
}
private void initializations() {
Bundle extras = getIntent().getExtras();
if (extras != null) {
this.chapterId = extras.getInt("ChapterId", 0);
this.chapterName = extras.getString("ChapterName", "");
this.subjectName = extras.getString("SubjectName", "");
this.subjectGUID = extras.getString("SubjectGUID", "");
}
this.mNoData = (TextView) findViewById(R.id.txv_no_data);
this.mDesc = (WebView) findViewById(R.id.wv_topic);
this.mContent = findViewById(R.id.lst_content);
Spinner spinner = (Spinner) findViewById(R.id.nav_spinner);
this.mNavItems = spinner;
spinner.setOnItemSelectedListener(this);
this.mContent.setDividerHeight(0);
this.mNoData.setVisibility(8);
this.mContent.setVisibility(8);
WebSettings settings = this.mDesc.getSettings();
settings.setJavaScriptEnabled(true);
settings.getAllowContentAccess();
settings.setDomStorageEnabled(true);
settings.setBuiltInZoomControls(true);
settings.setDisplayZoomControls(false);
settings.setLoadWithOverviewMode(true);
settings.setUseWideViewPort(true);
settings.setDefaultFontSize(40);
settings.setDefaultTextEncodingName("utf-8");
this.mDesc.setWebViewClient(new WebViewClient() {
@Override
public boolean shouldOverrideUrlLoading(WebView webView, String str) {
try {
LearningTopicContentActivity.this.context.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
return true;
} catch (Exception e) {
e.printStackTrace();
return true;
}
}
});
getChapterTopicList();
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
super.onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
private void getChapterTopicList() {
if (Utility.hasNetworkConnection(this.context)) {
getChapterTopics();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getChapterTopics() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetChapterTopics(this.chapterId, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<LearningChapterTopicModelClass>>() {
public void onResponse(Call<ArrayList<LearningChapterTopicModelClass>> call, Response<ArrayList<LearningChapterTopicModelClass>> response) {
if (LearningTopicContentActivity.this.mProgressbar != null && LearningTopicContentActivity.this.mProgressbar.isShowing()) {
LearningTopicContentActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(LearningTopicContentActivity.this.activity);
return;
}
LearningTopicContentActivity.this.topics.clear();
LearningTopicContentActivity.this.topics = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(LearningTopicContentActivity.this.context, R.layout.spinner_item_white_text, LearningTopicContentActivity.this.topics);
arrayAdapter.setDropDownViewResource(R.layout.spinner_row_layout);
LearningTopicContentActivity.this.mNavItems.setAdapter((SpinnerAdapter) arrayAdapter);
}
public void onFailure(Call<ArrayList<LearningChapterTopicModelClass>> call, Throwable th) {
if (LearningTopicContentActivity.this.mProgressbar != null && LearningTopicContentActivity.this.mProgressbar.isShowing()) {
LearningTopicContentActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(LearningTopicContentActivity.this.activity);
}
});
}
private void getTopicContent() {
if (Utility.hasNetworkConnection(this.context)) {
getTopicWiseContent();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getTopicWiseContent() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetTopicContent(this.topicId, Integer.parseInt(this.studentEnrollmentId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<LearningTopicDetailsModel>>() {
public void onResponse(Call<ArrayList<LearningTopicDetailsModel>> call, Response<ArrayList<LearningTopicDetailsModel>> response) {
String str;
if (LearningTopicContentActivity.this.mProgressbar != null && LearningTopicContentActivity.this.mProgressbar.isShowing()) {
LearningTopicContentActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(LearningTopicContentActivity.this.activity);
return;
}
ArrayList arrayList = (ArrayList) response.body();
if (arrayList == null || arrayList.size() <= 0) {
LearningTopicContentActivity.this.mDesc.setVisibility(8);
LearningTopicContentActivity.this.mContent.setVisibility(8);
LearningTopicContentActivity.this.mNoData.setVisibility(0);
return;
}
LearningTopicDetailsModel learningTopicDetailsModel = (LearningTopicDetailsModel) arrayList.get(0);
if (learningTopicDetailsModel != null) {
LearningTopicContentActivity.this.mDesc.setVisibility(0);
LearningTopicContentActivity.this.mContent.setVisibility(0);
LearningTopicContentActivity.this.mNoData.setVisibility(8);
String topicDescription = learningTopicDetailsModel.getTopicDescription();
ArrayList subTopics = learningTopicDetailsModel.getSubTopics();
if (topicDescription != null && topicDescription.length() > 0 && !topicDescription.equalsIgnoreCase("null")) {
str = "<b>" + learningTopicDetailsModel.getSequenceNo() + " " + learningTopicDetailsModel.getTopicName() + "(" + learningTopicDetailsModel.getExerciseTime() + "min)</b><br>" + topicDescription;
} else {
str = "";
}
if (subTopics != null) {
Iterator it = subTopics.iterator();
while (it.hasNext()) {
LearningSubTopicModelClass learningSubTopicModelClass = (LearningSubTopicModelClass) it.next();
if (str.length() > 0) {
str = str + "<br><br><b>" + learningTopicDetailsModel.getSequenceNo() + "." + learningSubTopicModelClass.getSequenceNo() + " " + learningSubTopicModelClass.getTopicPart() + "</b><br>" + learningSubTopicModelClass.getDesc();
} else {
str = "<b>" + learningTopicDetailsModel.getSequenceNo() + "." + learningSubTopicModelClass.getSequenceNo() + " " + learningSubTopicModelClass.getTopicPart() + "</b><br>" + learningSubTopicModelClass.getDesc();
}
}
}
if (str.length() > 0) {
LearningTopicContentActivity.this.mDesc.setVisibility(0);
try {
LearningTopicContentActivity.this.mDesc.loadData(Base64.encodeToString(str.getBytes(C.UTF8_NAME), 0), "text/html; charset=utf-8", "base64");
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
} else {
LearningTopicContentActivity.this.mDesc.setVisibility(8);
}
LearningTopicContentActivity.this.mContent.setAdapter(new LearningTopicContentsAdapter(LearningTopicContentActivity.this.context, learningTopicDetailsModel.getData(), LearningTopicContentActivity.this.subjectGUID, LearningTopicContentActivity.this.chapterId, LearningTopicContentActivity.this.topicId));
if (!Utility.hasNetworkConnection(LearningTopicContentActivity.this.context)) {
Toast.makeText(LearningTopicContentActivity.this.context, "Check your Network Connection", 0).show();
return;
} else {
LearningTopicContentActivity learningTopicContentActivity = LearningTopicContentActivity.this;
learningTopicContentActivity.saveSubjectTopicsViewLog(learningTopicContentActivity.topicId);
return;
}
}
LearningTopicContentActivity.this.mDesc.setVisibility(8);
LearningTopicContentActivity.this.mContent.setVisibility(8);
LearningTopicContentActivity.this.mNoData.setVisibility(0);
}
public void onFailure(Call<ArrayList<LearningTopicDetailsModel>> call, Throwable th) {
if (LearningTopicContentActivity.this.mProgressbar != null && LearningTopicContentActivity.this.mProgressbar.isShowing()) {
LearningTopicContentActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(LearningTopicContentActivity.this.activity);
}
});
}
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_TOPICS", bundle);
if (this.topicId > 0) {
getTopicContent();
}
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
@Override
public void onItemSelected(AdapterView<?> adapterView, View view, int i, long j) {
this.topicId = this.topics.get(i).getTopicId();
getTopicContent();
}
public void saveSubjectTopicsViewLog(int i) {
String format = new SimpleDateFormat("MM/dd/yyyy hh:mm:ss a", Locale.US).format(new Date());
HashMap hashMap = new HashMap();
hashMap.put("StudentEnrollmentID", this.studentEnrollmentId);
hashMap.put("SubjectSyllabusID", String.valueOf(this.chapterId));
hashMap.put("TopicID", String.valueOf(i));
hashMap.put("StartDate", format);
hashMap.put("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) {
Log.d("SaveTopicsViewLog", "onResponse");
}
public void onFailure(Call<String> call, Throwable th) {
Log.d("SaveTopicsViewLog", "onFailure");
}
});
}
}