正在查看: St.John's v1.0.9 应用的 ProfileTabsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 ProfileTabsActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.viewpager.widget.ViewPager;
import com.bumptech.glide.Glide;
import com.google.android.material.tabs.TabLayout;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.DB.MyClassBoardDB;
import com.mcb.stjohnsemschool.adapter.ProfileViewPagerAdapter;
import com.mcb.stjohnsemschool.model.StudentInfoModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.settings.SettingsActivity;
import com.mcb.stjohnsemschool.utils.RoundedTransformation;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.squareup.picasso.Picasso;
import java.util.ArrayList;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ProfileTabsActivity extends AppCompatActivity {
private static final String TAG = "com.mcb.stjohnsemschool.activity.ProfileTabsActivity";
private ConnectivityManager conMgr;
Context context;
private Typeface fontMuseo;
ImageView imgIcon;
SharedPreferences.Editor mEditor;
private TransparentProgressDialog mProgressbar;
SharedPreferences mSharedPref;
private AppCompatActivity myActivity;
TabLayout tabLayout;
TextView txtBranch;
TextView txtClassText;
TextView txtName;
ViewPager viewPager;
String path = "";
String name = "";
String className = "";
String enrolmentCode = "";
String branchStr = "";
MyClassBoardDB db = null;
String userId = "";
String studentEnrolmentId = "";
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_profile_tabs);
this.context = getApplicationContext();
this.myActivity = this;
this.fontMuseo = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Profile");
setUpIDs();
}
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_PROFILE", bundle);
getStudentProfile();
}
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.settings_menu, menu);
return true;
}
private void setUpIDs() {
this.imgIcon = (ImageView) findViewById(2131362622);
this.db = new MyClassBoardDB(this.context);
SharedPreferences sharedPreferences = this.context.getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.mEditor = sharedPreferences.edit();
this.userId = this.mSharedPref.getString("UseridKey", this.userId);
this.studentEnrolmentId = this.mSharedPref.getString("studentEnrollmentIdKey", this.studentEnrolmentId);
this.txtName = (TextView) findViewById(2131363809);
this.txtClassText = (TextView) findViewById(R.id.profile_classname_text);
this.txtBranch = (TextView) findViewById(R.id.branchname);
this.txtClassText.setTypeface(this.fontMuseo);
this.txtBranch.setTypeface(this.fontMuseo);
TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);
this.tabLayout = tabLayout;
tabLayout.setTabGravity(0);
TabLayout tabLayout2 = this.tabLayout;
tabLayout2.addTab(tabLayout2.newTab().setText("Student"));
TabLayout tabLayout3 = this.tabLayout;
tabLayout3.addTab(tabLayout3.newTab().setText("Parents"));
TabLayout tabLayout4 = this.tabLayout;
tabLayout4.addTab(tabLayout4.newTab().setText("Academics"));
ViewPager findViewById = findViewById(R.id.pager);
this.viewPager = findViewById;
findViewById.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(this.tabLayout));
this.tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabSelected(TabLayout.Tab tab) {
ProfileTabsActivity.this.viewPager.setCurrentItem(tab.getPosition());
}
});
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
int itemId = menuItem.getItemId();
if (itemId == 16908332) {
super.onBackPressed();
return true;
}
if (itemId == 2131363356) {
startActivity(new Intent(getApplicationContext(), (Class<?>) StudentQRAndBarCodeActivity.class));
return true;
}
if (itemId == 2131363599) {
startActivity(new Intent(getApplicationContext(), (Class<?>) SettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(menuItem);
}
private void getStudentProfile() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
this.conMgr = connectivityManager;
if (connectivityManager.getActiveNetworkInfo() != null && this.conMgr.getActiveNetworkInfo().isAvailable() && this.conMgr.getActiveNetworkInfo().isConnected()) {
getStudentDetails();
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void getStudentDetails() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClient1(this.context).create(ApiInterface.class)).GetStudentProfile(Integer.parseInt(this.userId), Utility.getSchoolApiKey(this.context)).enqueue(new Callback<ArrayList<StudentInfoModel>>() {
public void onResponse(Call<ArrayList<StudentInfoModel>> call, Response<ArrayList<StudentInfoModel>> response) {
if (ProfileTabsActivity.this.mProgressbar != null && ProfileTabsActivity.this.mProgressbar.isShowing()) {
ProfileTabsActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(ProfileTabsActivity.this.myActivity);
return;
}
ArrayList arrayList = (ArrayList) response.body();
if (arrayList.size() > 0) {
StudentInfoModel studentInfoModel = (StudentInfoModel) arrayList.get(0);
ProfileTabsActivity.this.mEditor.putString("Name", studentInfoModel.getFullName());
ProfileTabsActivity.this.mEditor.putString("ProfilePicPath", studentInfoModel.getPhotoUpload());
ProfileTabsActivity.this.mEditor.putString("ParentEmailIdKey", studentInfoModel.getEmail());
ProfileTabsActivity.this.mEditor.putString("ParentMobileKey", studentInfoModel.getMobileNumber());
ProfileTabsActivity.this.mEditor.putString("Parent_address", studentInfoModel.getAddress());
ProfileTabsActivity.this.mEditor.putString("Father_name", studentInfoModel.getFatherName());
ProfileTabsActivity.this.mEditor.putString("Mother_name", studentInfoModel.getMotherName());
ProfileTabsActivity.this.mEditor.putString("Father_phone", studentInfoModel.getFatherPhone());
ProfileTabsActivity.this.mEditor.putString("Mother_phone", studentInfoModel.getMotherPhone());
ProfileTabsActivity.this.mEditor.putString("Father_email_id", studentInfoModel.getFatherEmailID());
ProfileTabsActivity.this.mEditor.putString("Mother_email_id", studentInfoModel.getMotherEmailID());
ProfileTabsActivity.this.mEditor.putString("Current_Nearest_Location", studentInfoModel.getCurrentNearestLocation());
ProfileTabsActivity.this.mEditor.putString("Current_Latitude", studentInfoModel.getCurrentLatitude());
ProfileTabsActivity.this.mEditor.putString("Current_Longitude", studentInfoModel.getCurrentLongitude());
ProfileTabsActivity.this.mEditor.putString("POCEmailIdKey", studentInfoModel.getPocEmail());
ProfileTabsActivity.this.mEditor.putString("POCMobileKey", studentInfoModel.getPocMobile());
ProfileTabsActivity.this.mEditor.putString("Admission_number", studentInfoModel.getStudentReferencesCode());
ProfileTabsActivity.this.mEditor.putString("Aadhar_Number", studentInfoModel.getAadhaarNumber());
ProfileTabsActivity.this.mEditor.putString("Date_of_birth", studentInfoModel.getDateOfBirth());
ProfileTabsActivity.this.mEditor.putString("Class_group", studentInfoModel.getClassGroupName());
ProfileTabsActivity.this.mEditor.putString("Blood_Group", studentInfoModel.getBloodGroup());
ProfileTabsActivity.this.mEditor.putString("Admission_Type", studentInfoModel.getReservationType());
ProfileTabsActivity.this.mEditor.putString("GRNumber", studentInfoModel.getUniqueID());
ProfileTabsActivity.this.mEditor.putString("Roll_No", studentInfoModel.getRollNo());
ProfileTabsActivity.this.mEditor.putString("Gender", studentInfoModel.getGender());
ProfileTabsActivity.this.mEditor.putString("Transport", studentInfoModel.getTransport());
ProfileTabsActivity.this.mEditor.putString("ClassTeacherDetails", studentInfoModel.getClassTeacherDetails());
ProfileTabsActivity.this.mEditor.putString("BoardName", studentInfoModel.getBoardName());
ProfileTabsActivity.this.mEditor.commit();
}
ProfileTabsActivity.this.viewPager.setAdapter(new ProfileViewPagerAdapter(ProfileTabsActivity.this.getSupportFragmentManager(), ProfileTabsActivity.this.tabLayout.getTabCount()));
ProfileTabsActivity.this.viewPager.setCurrentItem(ProfileTabsActivity.this.tabLayout.getSelectedTabPosition());
ProfileTabsActivity.this.getProfileData();
}
public void onFailure(Call<ArrayList<StudentInfoModel>> call, Throwable th) {
if (ProfileTabsActivity.this.mProgressbar != null && ProfileTabsActivity.this.mProgressbar.isShowing()) {
ProfileTabsActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(ProfileTabsActivity.this.myActivity);
}
});
}
public void getProfileData() {
String string = this.mSharedPref.getString("ProfilePicPath", "");
this.path = string;
if (string.length() > 0) {
Glide.with(this).load(this.path).circleCrop().into(this.imgIcon);
} else {
Picasso.get().load(R.drawable.nopicture).transform(new RoundedTransformation(100, 2)).resize(100, 100).centerCrop().into(this.imgIcon);
}
String string2 = this.mSharedPref.getString("Name", "");
this.name = string2;
this.txtName.setText(string2);
String string3 = this.mSharedPref.getString("branchnameKey", "");
this.branchStr = string3;
this.txtBranch.setText(string3);
this.txtClassText.setText(this.mSharedPref.getString("Class", "") + " - " + this.mSharedPref.getString("SectionNameKey", ""));
}
protected void onStop() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
this.mProgressbar.dismiss();
}
super.onStop();
}
}