正在查看: St.John's v1.0.9 应用的 WizenozeSubjectChaptersActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 WizenozeSubjectChaptersActivity.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.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.core.content.ContextCompat;
import androidx.core.view.MenuItemCompat;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.adapter.WizenozeChaptersAdapter;
import com.mcb.stjohnsemschool.model.WizenozegChapterModelClass;
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.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class WizenozeSubjectChaptersActivity extends AppCompatActivity implements WizenozeChaptersAdapter.ViewUnits, SearchView.OnQueryTextListener {
private static final String TAG = "com.mcb.stjohnsemschool.activity.WizenozeSubjectChaptersActivity";
public static Activity activity;
private Context context;
private ListView mChapters;
private FirebaseAnalytics mFirebaseAnalytics;
private TextView mNoData;
private TransparentProgressDialog mProgressbar;
private String mSubjectName;
private String serverApi;
private String subjectGUID;
private String subjectId;
private String subjectName;
private WizenozeChaptersAdapter.ViewUnits viewUnits;
private String branchId = "0";
private String studentEnrollmentId = "0";
private String academicYearId = "0";
private String chapterJson = "";
private ArrayList<WizenozegChapterModelClass> chapters = new ArrayList<>();
private ArrayList<WizenozegChapterModelClass> chaptersDup = new ArrayList<>();
public boolean onQueryTextSubmit(String str) {
return false;
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_wizenoze_subject_chapters);
this.mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
activity = this;
this.viewUnits = this;
this.context = getApplicationContext();
Bundle extras = getIntent().getExtras();
this.subjectId = extras.getString("SubjectID", this.subjectId);
this.serverApi = extras.getString("ServerApi", this.serverApi);
this.mSubjectName = extras.getString("SubjectName", this.mSubjectName);
getSupportActionBar();
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle(this.mSubjectName);
SharedPreferences sharedPreferences = this.context.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() {
this.mNoData = (TextView) findViewById(R.id.txv_no_data);
ListView listView = (ListView) findViewById(R.id.lst_wizenoze_chapters);
this.mChapters = listView;
listView.setDividerHeight(0);
this.mNoData.setVisibility(8);
this.mChapters.setVisibility(8);
getSubjectChapters();
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
super.onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
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)).getWizeNozeLibraryUnits(Integer.parseInt(this.subjectId), Integer.parseInt(this.studentEnrollmentId), this.serverApi, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<WizenozegChapterModelClass>>() {
public void onResponse(Call<ArrayList<WizenozegChapterModelClass>> call, Response<ArrayList<WizenozegChapterModelClass>> response) {
if (WizenozeSubjectChaptersActivity.this.mProgressbar != null && WizenozeSubjectChaptersActivity.this.mProgressbar.isShowing()) {
WizenozeSubjectChaptersActivity.this.mProgressbar.dismiss();
}
if (response != null && response.body() != null) {
WizenozeSubjectChaptersActivity.this.chapters.clear();
WizenozeSubjectChaptersActivity.this.chapters = (ArrayList) response.body();
WizenozeSubjectChaptersActivity.this.chaptersDup.clear();
WizenozeSubjectChaptersActivity.this.chaptersDup.addAll(WizenozeSubjectChaptersActivity.this.chapters);
WizenozeSubjectChaptersActivity.this.setDataToView();
return;
}
Utility.showAlertDialog(WizenozeSubjectChaptersActivity.activity);
}
public void onFailure(Call<ArrayList<WizenozegChapterModelClass>> call, Throwable th) {
if (WizenozeSubjectChaptersActivity.this.mProgressbar != null && WizenozeSubjectChaptersActivity.this.mProgressbar.isShowing()) {
WizenozeSubjectChaptersActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(WizenozeSubjectChaptersActivity.activity);
}
});
}
protected void onResume() {
super.onResume();
getSubjectChapters();
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
public void viewUnits(WizenozegChapterModelClass wizenozegChapterModelClass) {
Intent intent = new Intent(this.context, (Class<?>) WizenozeChildrenActivity.class);
intent.putExtra("UnitID", wizenozegChapterModelClass.getQueryID());
intent.putExtra("ServerApi", this.serverApi);
intent.putExtra("SubjectId", this.subjectId);
intent.putExtra("UnitName", wizenozegChapterModelClass.getUnitName());
startActivity(intent);
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.menu_search, menu);
SearchView actionView = MenuItemCompat.getActionView(menu.findItem(R.id.itemSearch));
EditText editText = (EditText) actionView.findViewById(2131363577);
editText.setTextColor(ContextCompat.getColor(this.context, 2131100860));
editText.setHintTextColor(ContextCompat.getColor(this.context, 2131100860));
Utility.setCursorColor(editText, getResources().getColor(2131100860));
actionView.setOnQueryTextListener(this);
return super.onCreateOptionsMenu(menu);
}
public boolean onQueryTextChange(String str) {
if (str.length() > 0) {
ArrayList<WizenozegChapterModelClass> arrayList = new ArrayList<>();
for (int i = 0; i < this.chaptersDup.size(); i++) {
WizenozegChapterModelClass wizenozegChapterModelClass = this.chaptersDup.get(i);
if ((wizenozegChapterModelClass.getUnitName() == null ? "" : wizenozegChapterModelClass.getUnitName().toLowerCase()).contains(str.toLowerCase())) {
arrayList.add(wizenozegChapterModelClass);
}
}
this.chapters = arrayList;
} else {
this.chapters.clear();
this.chapters.addAll(this.chaptersDup);
}
setDataToView();
return false;
}
public void setDataToView() {
if (this.chapters.size() > 0) {
this.mChapters.setAdapter(new WizenozeChaptersAdapter(this.context, activity, this.chapters, this.viewUnits));
this.mNoData.setVisibility(8);
this.mChapters.setVisibility(0);
return;
}
this.mNoData.setVisibility(0);
this.mChapters.setVisibility(8);
}
}