正在查看: St.John's v1.0.9 应用的 ForgotUsernameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
正在查看: St.John's v1.0.9 应用的 ForgotUsernameActivity.java JAVA 源代码文件
本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。
package com.mcb.stjohnsemschool.activity;
import android.app.Activity;
import android.app.Dialog;
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.MenuItem;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import com.google.android.material.textfield.TextInputLayout;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.model.ForgotUsernameDetailsModel;
import com.mcb.stjohnsemschool.model.ForgotUsernameModel;
import com.mcb.stjohnsemschool.services.ApiClient;
import com.mcb.stjohnsemschool.services.ApiInterface;
import com.mcb.stjohnsemschool.utils.Constants;
import com.mcb.stjohnsemschool.utils.TransparentProgressDialog;
import com.mcb.stjohnsemschool.utils.Utility;
import com.wdullaer.materialdatetimepicker.date.DatePickerDialog;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
public class ForgotUsernameActivity extends AppCompatActivity implements View.OnClickListener, DatePickerDialog.OnDateSetListener {
private Activity activity;
private Context context;
private DatePickerDialog dateOfBirthDialog;
private String dob;
private String email;
private TextView mAlertText;
private Button mBackToLogin;
private Button mCheckDetails;
private Dialog mDialogAlert;
private TextView mDialogeAlertYes;
SharedPreferences.Editor mEditor;
private EditText mFatherMotherEmail;
private TextInputLayout mFatherMotherEmailTIL;
private EditText mFatherMotherMobile;
private FirebaseAnalytics mFirebaseAnalytics;
private Typeface mMuseoSlab500;
private TransparentProgressDialog mProgressbar;
private Button mSend;
SharedPreferences mSharedPref;
private EditText mStudentDOB;
private String mobileNo;
private int userId;
private String regMail = "";
private Calendar myCalendar = Calendar.getInstance();
private boolean isSuccess = false;
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.activity_forgot_username);
this.mFirebaseAnalytics = FirebaseAnalytics.getInstance(this);
getWindow().setSoftInputMode(3);
getSupportActionBar().setDisplayShowHomeEnabled(true);
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
getSupportActionBar().setTitle("Forgot Username");
this.activity = this;
Context applicationContext = getApplicationContext();
this.context = applicationContext;
SharedPreferences sharedPreferences = applicationContext.getSharedPreferences("", 0);
this.mSharedPref = sharedPreferences;
this.mEditor = sharedPreferences.edit();
this.mMuseoSlab500 = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
setUpUI();
}
private void setUpUI() {
this.mSend = (Button) findViewById(R.id.btn_send_username);
this.mCheckDetails = (Button) findViewById(R.id.btn_check_details);
this.mBackToLogin = (Button) findViewById(R.id.btn_back_to_login);
this.mFatherMotherMobile = (EditText) findViewById(R.id.edt_father_mother_mobile);
this.mStudentDOB = (EditText) findViewById(R.id.edt_student_dob);
this.mFatherMotherEmail = (EditText) findViewById(R.id.edt_father_mother_email);
this.mFatherMotherEmailTIL = (TextInputLayout) findViewById(R.id.til_father_mother_email);
this.mSend.setOnClickListener(this);
this.mCheckDetails.setOnClickListener(this);
this.mBackToLogin.setOnClickListener(this);
this.mStudentDOB.setOnClickListener(this);
this.mSend.setTypeface(this.mMuseoSlab500);
this.mBackToLogin.setTypeface(this.mMuseoSlab500);
this.mFatherMotherMobile.setTypeface(this.mMuseoSlab500);
this.mStudentDOB.setTypeface(this.mMuseoSlab500);
this.mFatherMotherEmail.setTypeface(this.mMuseoSlab500);
this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
Dialog dialog = new Dialog(this, R.style.Theme_Dialog);
this.mDialogAlert = dialog;
WindowManager.LayoutParams attributes = dialog.getWindow().getAttributes();
attributes.dimAmount = 5.0f;
this.mDialogAlert.getWindow().setAttributes(attributes);
this.mDialogAlert.getWindow().addFlags(2);
this.mDialogAlert.setContentView(R.layout.dialog_alert);
this.mDialogAlert.setCanceledOnTouchOutside(true);
this.mAlertText = (TextView) this.mDialogAlert.findViewById(R.id.alert_text);
TextView textView = (TextView) this.mDialogAlert.findViewById(R.id.ok_alert_dialog);
this.mDialogeAlertYes = textView;
textView.setOnClickListener(this);
this.mFatherMotherEmailTIL.setVisibility(8);
this.mSend.setVisibility(8);
this.mCheckDetails.setVisibility(0);
}
@Override
public void onClick(View view) {
String str;
String str2;
String str3;
if (view == this.mSend) {
this.mobileNo = this.mFatherMotherMobile.getText().toString().trim();
this.dob = this.mStudentDOB.getText().toString().trim();
this.email = this.mFatherMotherEmail.getText().toString().trim();
String str4 = this.mobileNo;
if (str4 != null && str4.length() > 0 && !this.mobileNo.equalsIgnoreCase("null") && (str2 = this.dob) != null && str2.length() > 0 && !this.dob.equalsIgnoreCase("null") && (str3 = this.email) != null && str3.length() > 0 && !this.email.equalsIgnoreCase("null")) {
if (Constants.isValidPhoneNum(this.mobileNo)) {
if (Constants.isValidEmail(this.email)) {
sentEmailForUserData();
return;
} else {
Toast.makeText(getApplicationContext(), "Enter Valid Email", 1).show();
return;
}
}
Toast.makeText(getApplicationContext(), "Enter Valid Mobile No", 1).show();
return;
}
String str5 = this.mobileNo;
if (str5 == null || str5.length() == 0 || this.mobileNo.equalsIgnoreCase("null")) {
Toast.makeText(getApplicationContext(), "Enter Father/Mother Mobile No", 1).show();
return;
}
String str6 = this.dob;
if (str6 == null || str6.length() == 0 || this.dob.equalsIgnoreCase("null")) {
Toast.makeText(getApplicationContext(), "Enter Student DOB", 1).show();
return;
}
String str7 = this.email;
if (str7 == null || str7.length() == 0 || this.email.equalsIgnoreCase("null")) {
Toast.makeText(getApplicationContext(), "Enter Father/Mother Email", 1).show();
return;
}
return;
}
if (view == this.mCheckDetails) {
this.mobileNo = this.mFatherMotherMobile.getText().toString().trim();
this.dob = this.mStudentDOB.getText().toString().trim();
String str8 = this.mobileNo;
if (str8 != null && str8.length() > 0 && !this.mobileNo.equalsIgnoreCase("null") && (str = this.dob) != null && str.length() > 0 && !this.dob.equalsIgnoreCase("null")) {
if (Constants.isValidPhoneNum(this.mobileNo)) {
checkDetailsResult();
return;
} else {
Toast.makeText(getApplicationContext(), "Enter Valid Mobile No", 1).show();
return;
}
}
String str9 = this.mobileNo;
if (str9 == null || str9.length() == 0 || this.mobileNo.equalsIgnoreCase("null")) {
Toast.makeText(getApplicationContext(), "Enter Father/Mother Mobile No", 1).show();
return;
}
String str10 = this.dob;
if (str10 == null || str10.length() == 0 || this.dob.equalsIgnoreCase("null")) {
Toast.makeText(getApplicationContext(), "Enter Student DOB", 1).show();
return;
}
return;
}
if (view == this.mBackToLogin) {
setResult(565, new Intent());
finish();
overridePendingTransition(R.anim.left_in, R.anim.right_out);
} else {
if (view == this.mDialogeAlertYes) {
Dialog dialog = this.mDialogAlert;
if (dialog != null && dialog.isShowing()) {
this.mDialogAlert.dismiss();
}
if (this.isSuccess) {
finish();
return;
}
return;
}
if (view == this.mStudentDOB) {
showDOBDialog();
}
}
}
private void showDOBDialog() {
this.dateOfBirthDialog = DatePickerDialog.newInstance(this, this.myCalendar.get(1), this.myCalendar.get(2), this.myCalendar.get(5));
Calendar calendar = Calendar.getInstance();
calendar.set(1, calendar.get(1) - 1);
this.dateOfBirthDialog.setMaxDate(calendar);
this.dateOfBirthDialog.setThemeDark(false);
this.dateOfBirthDialog.setAccentColor(ContextCompat.getColor(this.context, R.color.ColorPrimary));
this.dateOfBirthDialog.show(getFragmentManager(), "Datepickerdialog");
}
public void onDateSet(DatePickerDialog datePickerDialog, int i, int i2, int i3) {
if (datePickerDialog == this.dateOfBirthDialog) {
this.myCalendar.set(1, i);
this.myCalendar.set(2, i2);
this.myCalendar.set(5, i3);
updateDOBLabel();
}
}
private void updateDOBLabel() {
this.mStudentDOB.setText(new SimpleDateFormat("dd MMM yyyy", Locale.US).format(this.myCalendar.getTime()));
}
private void checkDetailsResult() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
checkForgotUserCredentials();
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void checkForgotUserCredentials() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
((ApiInterface) ApiClient.getClientWithStaticHeader(this.context).create(ApiInterface.class)).CheckForgotUserCredentials(this.mobileNo, new SimpleDateFormat("MM/dd/yyyy", Locale.US).format(Long.valueOf(new Date(this.dob).getTime())), "hjysgt87e-andparentid-84376-mcb-dt34986tj").enqueue(new Callback<ForgotUsernameModel>() {
public void onResponse(Call<ForgotUsernameModel> call, Response<ForgotUsernameModel> response) {
if (ForgotUsernameActivity.this.mProgressbar != null && ForgotUsernameActivity.this.mProgressbar.isShowing()) {
ForgotUsernameActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(ForgotUsernameActivity.this.activity);
return;
}
ForgotUsernameModel forgotUsernameModel = (ForgotUsernameModel) response.body();
if (forgotUsernameModel != null) {
if (forgotUsernameModel.getBit() != 1) {
ForgotUsernameActivity.this.isSuccess = false;
ForgotUsernameActivity.this.mAlertText.setText("Invalid details");
ForgotUsernameActivity.this.mDialogAlert.show();
return;
}
ArrayList details = forgotUsernameModel.getDetails();
if (details == null || details.size() <= 0) {
ForgotUsernameActivity.this.isSuccess = false;
ForgotUsernameActivity.this.mAlertText.setText("Invalid details");
ForgotUsernameActivity.this.mDialogAlert.show();
return;
}
ForgotUsernameDetailsModel forgotUsernameDetailsModel = (ForgotUsernameDetailsModel) details.get(0);
String fatherEmailId = forgotUsernameDetailsModel.getFatherEmailId();
String motherEmailId = forgotUsernameDetailsModel.getMotherEmailId();
ForgotUsernameActivity.this.userId = forgotUsernameDetailsModel.getUserId();
if (fatherEmailId != null && fatherEmailId.length() > 0 && !fatherEmailId.equalsIgnoreCase("null")) {
ForgotUsernameActivity.this.mFatherMotherEmail.setText(fatherEmailId);
ForgotUsernameActivity.this.mFatherMotherEmailTIL.setVisibility(0);
ForgotUsernameActivity.this.mSend.setVisibility(0);
ForgotUsernameActivity.this.mCheckDetails.setVisibility(8);
ForgotUsernameActivity.this.regMail = fatherEmailId;
return;
}
if (motherEmailId == null || motherEmailId.length() <= 0 || motherEmailId.equalsIgnoreCase("null")) {
ForgotUsernameActivity.this.isSuccess = false;
ForgotUsernameActivity.this.mAlertText.setText("Father/Mother email not registered");
ForgotUsernameActivity.this.mDialogAlert.show();
} else {
ForgotUsernameActivity.this.mFatherMotherEmail.setText(motherEmailId);
ForgotUsernameActivity.this.mFatherMotherEmailTIL.setVisibility(0);
ForgotUsernameActivity.this.mSend.setVisibility(0);
ForgotUsernameActivity.this.mCheckDetails.setVisibility(8);
ForgotUsernameActivity.this.regMail = motherEmailId;
}
}
}
public void onFailure(Call<ForgotUsernameModel> call, Throwable th) {
if (ForgotUsernameActivity.this.mProgressbar != null && ForgotUsernameActivity.this.mProgressbar.isShowing()) {
ForgotUsernameActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(ForgotUsernameActivity.this.activity);
}
});
}
private void sentEmailForUserData() {
ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
sendUsernameToEmail();
} else {
Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
}
}
private void sendUsernameToEmail() {
TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
this.mProgressbar.show();
}
HashMap hashMap = new HashMap();
hashMap.put("Email", this.regMail);
hashMap.put("Userid", String.valueOf(this.userId));
hashMap.put("apikey", "hjysgt87e-andparentid-84376-mcb-dt34986tj");
((ApiInterface) ApiClient.getClientWithStaticHeader(getApplicationContext()).create(ApiInterface.class)).SentEmailForUserData(hashMap).enqueue(new Callback<String>() {
public void onResponse(Call<String> call, Response<String> response) {
if (ForgotUsernameActivity.this.mProgressbar != null && ForgotUsernameActivity.this.mProgressbar.isShowing()) {
ForgotUsernameActivity.this.mProgressbar.dismiss();
}
if (response == null || response.body() == null) {
Utility.showAlertDialog(ForgotUsernameActivity.this.activity);
return;
}
String str = (String) response.body();
ForgotUsernameActivity.this.isSuccess = true;
ForgotUsernameActivity.this.mAlertText.setText(str);
ForgotUsernameActivity.this.mDialogAlert.show();
}
public void onFailure(Call<String> call, Throwable th) {
if (ForgotUsernameActivity.this.mProgressbar != null && ForgotUsernameActivity.this.mProgressbar.isShowing()) {
ForgotUsernameActivity.this.mProgressbar.dismiss();
}
Utility.showAlertDialog(ForgotUsernameActivity.this.activity);
}
});
}
public boolean onOptionsItemSelected(MenuItem menuItem) {
if (menuItem.getItemId() == 16908332) {
super.onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}
protected void onResume() {
super.onResume();
this.mFirebaseAnalytics.setCurrentScreen(this, "PAGE_FORGOT_USERNAME", null);
}
}