正在查看: St.John's v1.0.9 应用的 LearningSubjectContentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 LearningSubjectContentActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.EditText;
import android.widget.ListView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.appcompat.widget.SearchView;
import androidx.core.view.MenuItemCompat;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.adapter.LearningSubjectFilesAdapter;
import com.mcb.stjohnsemschool.adapter.LearningSubjectLinksAdapter;
import com.mcb.stjohnsemschool.adapter.LearningSubjectVideosAdapter;
import com.mcb.stjohnsemschool.model.LearningContentModel;
import com.mcb.stjohnsemschool.model.LearningSubjectWiseContentModelClass;
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 LearningSubjectContentActivity extends AppCompatActivity implements AdapterView.OnItemSelectedListener, SearchView.OnQueryTextListener {
private static final String TAG = "com.mcb.stjohnsemschool.activity.LearningSubjectContentActivity";
private Activity activity;
private Context context;
private ListView mContent;
private Spinner mNavItems;
private TextView mNoData;
private TransparentProgressDialog mProgressbar;
private SearchView searchView;
private int subjectId;
private int type;
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 subjectGUID = "";
private ArrayList<LearningSubjectWiseContentModelClass> subjects = new ArrayList<>();
private ArrayList<LearningContentModel> content = new ArrayList<>();
private ArrayList<LearningContentModel> contentDup = new ArrayList<>();
@Override
public void onNothingSelected(AdapterView<?> adapterView) {
}
public boolean onQueryTextSubmit(String str) {
return false;
}
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_learning_subject_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();
getSubjects();
}
private void initializations() {
Bundle extras = getIntent().getExtras();
if (extras != null) {
this.type = extras.getInt("Type", 0);
}
this.mNoData = (TextView) findViewById(R.id.txv_no_data);
this.mContent = (ListView) 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);
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
super.onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
private void getSubjects() {
if (Utility.hasNetworkConnection(this.context)) {
getLearningContentSubjects();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getLearningContentSubjects() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetLearningContentSubjects(Integer.parseInt(this.orgId), Integer.parseInt(this.branchId), Integer.parseInt(this.academicYearId), Integer.parseInt(this.classId), Integer.parseInt(this.studentEnrollmentId), this.type, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<LearningSubjectWiseContentModelClass>>() {
public void onResponse(Call<ArrayList<LearningSubjectWiseContentModelClass>> call, Response<ArrayList<LearningSubjectWiseContentModelClass>> response) {
if (LearningSubjectContentActivity.this.mProgressbar != null && LearningSubjectContentActivity.this.mProgressbar.isShowing()) {
LearningSubjectContentActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(LearningSubjectContentActivity.this.activity);
return;
}
LearningSubjectContentActivity.this.subjects.clear();
LearningSubjectContentActivity.this.subjects = (ArrayList) response.body();
ArrayAdapter arrayAdapter = new ArrayAdapter(LearningSubjectContentActivity.this.context, R.layout.spinner_item_white_text, LearningSubjectContentActivity.this.subjects);
arrayAdapter.setDropDownViewResource(R.layout.spinner_row_layout);
LearningSubjectContentActivity.this.mNavItems.setAdapter((SpinnerAdapter) arrayAdapter);
}
public void onFailure(Call<ArrayList<LearningSubjectWiseContentModelClass>> call, Throwable th) {
if (LearningSubjectContentActivity.this.mProgressbar != null && LearningSubjectContentActivity.this.mProgressbar.isShowing()) {
LearningSubjectContentActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(LearningSubjectContentActivity.this.activity);
}
});
}
private void getSubjectContent() {
if (Utility.hasNetworkConnection(this.context)) {
getLearningContentBySubject();
} else {
Toast.makeText(this.context, "Check your Network Connection", 0).show();
}
}
private void getLearningContentBySubject() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetLearningContentBySubject(Integer.parseInt(this.orgId), Integer.parseInt(this.branchId), Integer.parseInt(this.academicYearId), Integer.parseInt(this.classId), Integer.parseInt(this.studentEnrollmentId), this.type, this.subjectId, Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<LearningContentModel>>() {
public void onResponse(Call<ArrayList<LearningContentModel>> call, Response<ArrayList<LearningContentModel>> response) {
if (LearningSubjectContentActivity.this.mProgressbar != null && LearningSubjectContentActivity.this.mProgressbar.isShowing()) {
LearningSubjectContentActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(LearningSubjectContentActivity.this.activity);
return;
}
LearningSubjectContentActivity.this.content = (ArrayList) response.body();
LearningSubjectContentActivity.this.contentDup.clear();
if (LearningSubjectContentActivity.this.content != null) {
LearningSubjectContentActivity.this.contentDup.addAll(LearningSubjectContentActivity.this.content);
}
LearningSubjectContentActivity.this.addDataToUI();
}
public void onFailure(Call<ArrayList<LearningContentModel>> call, Throwable th) {
if (LearningSubjectContentActivity.this.mProgressbar != null && LearningSubjectContentActivity.this.mProgressbar.isShowing()) {
LearningSubjectContentActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(LearningSubjectContentActivity.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_SUBJECT_CHAPTERS", bundle);
SearchView searchView = this.searchView;
if (searchView != null) {
searchView.setQuery("", false);
this.searchView.clearFocus();
this.searchView.onActionViewCollapsed();
}
if (this.subjectId > 0) {
getSubjectContent();
}
}
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) {
LearningSubjectWiseContentModelClass learningSubjectWiseContentModelClass = this.subjects.get(i);
this.subjectId = learningSubjectWiseContentModelClass.getSubjectId();
this.subjectGUID = learningSubjectWiseContentModelClass.getSubjectGUID();
getSubjectContent();
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.search_menu, menu);
MenuItem findItem = menu.findItem(R.id.action_search);
findItem.setVisible(true);
SearchView actionView = MenuItemCompat.getActionView(findItem);
this.searchView = actionView;
EditText editText = (EditText) actionView.findViewById(2131363577);
editText.setTextColor(Utility.getColor(getApplicationContext(), 2131100860));
editText.setHintTextColor(Utility.getColor(getApplicationContext(), 2131100860));
Utility.setCursorColor(editText, getResources().getColor(2131100860));
this.searchView.setOnQueryTextListener(this);
return true;
}
public boolean onQueryTextChange(String str) {
if (str.length() > 0) {
ArrayList arrayList = new ArrayList();
for (int i = 0; i < this.contentDup.size(); i++) {
LearningContentModel learningContentModel = this.contentDup.get(i);
String fileName = learningContentModel.getFileName() == null ? "" : learningContentModel.getFileName();
String chapter = learningContentModel.getChapter() == null ? "" : learningContentModel.getChapter();
String topic = learningContentModel.getTopic() != null ? learningContentModel.getTopic() : "";
if (chapter.toLowerCase().contains(str.toLowerCase()) || topic.toLowerCase().contains(str.toLowerCase()) || fileName.toLowerCase().contains(str.toLowerCase())) {
arrayList.add(learningContentModel);
}
}
this.content.clear();
this.content.addAll(arrayList);
} else {
this.content.clear();
this.content.addAll(this.contentDup);
}
addDataToUI();
return false;
}
public void addDataToUI() {
ArrayList<LearningContentModel> arrayList = this.content;
if (arrayList != null && arrayList.size() > 0) {
this.mContent.setVisibility(0);
this.mNoData.setVisibility(8);
int i = this.type;
if (i == 1) {
this.mContent.setAdapter(new LearningSubjectVideosAdapter(this.context, this.content, this.subjectGUID));
return;
} else if (i == 2) {
this.mContent.setAdapter(new LearningSubjectLinksAdapter(this.context, this.content, this.subjectGUID));
return;
} else {
if (i == 3 || i == 6) {
this.mContent.setAdapter(new LearningSubjectFilesAdapter(this.context, this.content, this.subjectGUID, this.type));
return;
}
return;
}
}
this.mContent.setVisibility(8);
this.mNoData.setVisibility(0);
}
}