正在查看: St.John's v1.0.9 应用的 LearningSubjectChaptersActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 LearningSubjectChaptersActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.MenuItem;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.mcb.stjohnsemschool.adapter.LearningChaptersAdapter;
import com.mcb.stjohnsemschool.model.LearningChapterModelClass;
import com.mcb.stjohnsemschool.model.LearningSubjectsModelClass;
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.lang.reflect.Type;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class LearningSubjectChaptersActivity extends AppCompatActivity implements ActionBar.OnNavigationListener, LearningChaptersAdapter.ViewTopics {
private static final String TAG = "com.mcb.stjohnsemschool.activity.LearningSubjectChaptersActivity";
public static Activity activity;
private Context context;
private ListView mChapters;
private FirebaseAnalytics mFirebaseAnalytics;
private TextView mNoData;
private TransparentProgressDialog mProgressbar;
private String subjectGUID;
private String subjectName;
private LearningChaptersAdapter.ViewTopics viewTopics;
private String branchId = "0";
private String studentEnrollmentId = "0";
private String academicYearId = "0";
private String chapterJson = "";
private ArrayList<LearningSubjectsModelClass> subjects = new ArrayList<>();
private ArrayList<LearningChapterModelClass> chapters = new ArrayList<>();
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_learning_subject_chapters);
this.mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
activity = this;
this.viewTopics = this;
Context applicationContext = getApplicationContext();
this.context = applicationContext;
SharedPreferences sharedPreferences = applicationContext.getSharedPreferences("", 0);
this.studentEnrollmentId = sharedPreferences.getString("studentEnrollmentIdKey", this.studentEnrollmentId);
this.branchId = sharedPreferences.getString("BranchIdKey", this.branchId);
this.academicYearId = sharedPreferences.getString("academicyearIdKey", this.academicYearId);
this.mProgressbar = new TransparentProgressDialog(activity, R.drawable.spinner_loading_imag);
initializations();
}
private void initializations() {
Bundle extras = getIntent().getExtras();
int i = extras.getInt("SubjectPos", 0);
String string = extras.getString("SubjectsJson", "");
this.subjects.clear();
this.subjects = (ArrayList) new Gson().fromJson(string, new TypeToken<ArrayList<LearningSubjectsModelClass>>() {
}.getType());
activity.getSupportActionBar().setDisplayHomeAsUpEnabled(true);
activity.getSupportActionBar().setDisplayUseLogoEnabled(false);
activity.getSupportActionBar().setDisplayShowTitleEnabled(false);
activity.getSupportActionBar().setNavigationMode(1);
ArrayAdapter arrayAdapter = new ArrayAdapter(this.context, R.layout.navigation_drop_list, R.id.text1, this.subjects);
activity.getSupportActionBar().setListNavigationCallbacks(arrayAdapter, this);
activity.getSupportActionBar().setSelectedNavigationItem(i);
arrayAdapter.setDropDownViewResource(R.layout.spinner_row_layout);
this.mNoData = (TextView) findViewById(R.id.txv_no_data);
ListView listView = (ListView) findViewById(R.id.lst_chapters);
this.mChapters = listView;
listView.setDividerHeight(0);
this.mNoData.setVisibility(8);
this.mChapters.setVisibility(8);
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
super.onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
public boolean onNavigationItemSelected(int i, long j) {
this.subjectGUID = this.subjects.get(i).getSubjectGUID();
this.subjectName = this.subjects.get(i).getSubjectName();
getSubjectChapters();
return true;
}
public void viewTopics(LearningChapterModelClass learningChapterModelClass, int i) {
if (learningChapterModelClass.isIslockingContent()) {
new AlertDialog.Builder(this).setMessage("Access to the content of this chapter is locked.").setCancelable(true).setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i2) {
dialogInterface.cancel();
}
}).show();
return;
}
if (learningChapterModelClass.getTopicsCount() > 0) {
Intent intent = new Intent(this.context, (Class<?>) LearningTopicContentActivity.class);
intent.putExtra("SubjectName", this.subjectName);
intent.putExtra("SubjectGUID", this.subjectGUID);
intent.putExtra("ChapterName", learningChapterModelClass.getChapterName());
intent.putExtra("ChapterId", learningChapterModelClass.getChapterId());
startActivity(intent);
}
}
private void getSubjectChapters() {
if (Utility.hasNetworkConnection(this.context)) {
getChapters();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getChapters() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetSubjectChapters(this.subjectGUID, Integer.parseInt(this.branchId), Integer.parseInt(this.studentEnrollmentId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<LearningChapterModelClass>>() {
public void onResponse(Call<ArrayList<LearningChapterModelClass>> call, Response<ArrayList<LearningChapterModelClass>> response) {
if (LearningSubjectChaptersActivity.this.mProgressbar != null && LearningSubjectChaptersActivity.this.mProgressbar.isShowing()) {
LearningSubjectChaptersActivity.this.mProgressbar.dismiss();
}
if (response != null && response.body() != null) {
LearningSubjectChaptersActivity.this.chapters.clear();
LearningSubjectChaptersActivity.this.chapters = (ArrayList) response.body();
Gson gson = new Gson();
Type type = new TypeToken<ArrayList<LearningChapterModelClass>>() {
}.getType();
LearningSubjectChaptersActivity learningSubjectChaptersActivity = LearningSubjectChaptersActivity.this;
learningSubjectChaptersActivity.chapterJson = gson.toJson(learningSubjectChaptersActivity.chapters, type);
LearningSubjectChaptersActivity.this.mChapters.setAdapter(new LearningChaptersAdapter(LearningSubjectChaptersActivity.this.context, LearningSubjectChaptersActivity.activity, LearningSubjectChaptersActivity.this.chapters, LearningSubjectChaptersActivity.this.subjectName, LearningSubjectChaptersActivity.this.viewTopics));
if (LearningSubjectChaptersActivity.this.chapters.size() > 0) {
LearningSubjectChaptersActivity.this.mNoData.setVisibility(8);
LearningSubjectChaptersActivity.this.mChapters.setVisibility(0);
return;
} else {
LearningSubjectChaptersActivity.this.mNoData.setVisibility(0);
LearningSubjectChaptersActivity.this.mChapters.setVisibility(8);
return;
}
}
Utility.showAlertDialog(LearningSubjectChaptersActivity.activity);
}
public void onFailure(Call<ArrayList<LearningChapterModelClass>> call, Throwable th) {
if (LearningSubjectChaptersActivity.this.mProgressbar != null && LearningSubjectChaptersActivity.this.mProgressbar.isShowing()) {
LearningSubjectChaptersActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(LearningSubjectChaptersActivity.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_SUBJECT_CHAPTERS", bundle);
String str = this.subjectGUID;
if (str == null || str.length() <= 0) {
return;
}
getSubjectChapters();
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
}