导航菜单

页面标题

页面副标题

St.John's v1.0.9 - ForgotPasswordActivity.java 源代码

正在查看: St.John's v1.0.9 应用的 ForgotPasswordActivity.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.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.RadioButton;
import android.widget.RadioGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import com.google.android.material.textfield.TextInputLayout;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.model.ForgotPasswordModel;
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 java.util.HashMap;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ForgotPasswordActivity extends AppCompatActivity implements View.OnClickListener {
    int bit;
    private Context context;
    private TextView mAlertText;
    private Button mBacktoLoginTV;
    private Dialog mDialogAlert;
    private TextView mDialogeAlertYes;
    private EditText mEmail;
    private TextInputLayout mEmailTIL;
    FirebaseAnalytics mFirebaseAnalytics;
    private EditText mMobile;
    private TextInputLayout mMobileTIL;
    private Typeface mMuseoSlab500;
    private TransparentProgressDialog mProgressbar;
    private Button mRequestForNewPWTV;
    private RadioGroup mSearchBy;
    private RadioButton mSearchByEmail;
    private RadioButton mSearchByMobile;
    private EditText mUsername;
    private Activity myActivity;
    String username = "";
    String mobileNo = "";
    String email = "";
    int searchBy = 0;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_forgot_password);
        this.mFirebaseAnalytics = FirebaseAnalytics.getInstance(getApplicationContext());
        getWindow().setSoftInputMode(3);
        getSupportActionBar().setDisplayShowHomeEnabled(true);
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        getSupportActionBar().setTitle("Forgot Password");
        this.myActivity = this;
        this.context = getApplicationContext();
        this.mMuseoSlab500 = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
        setUpUI();
    }

    private void setUpUI() {
        this.mRequestForNewPWTV = (Button) findViewById(R.id.request_new_pw_textview);
        this.mBacktoLoginTV = (Button) findViewById(R.id.backto_login_textview);
        this.mUsername = (EditText) findViewById(R.id.emailid_edit);
        this.mMobile = (EditText) findViewById(R.id.edt_mobile);
        this.mEmail = (EditText) findViewById(R.id.edt_email);
        this.mMobileTIL = (TextInputLayout) findViewById(R.id.til_mobile);
        this.mEmailTIL = (TextInputLayout) findViewById(R.id.til_email);
        this.mSearchBy = (RadioGroup) findViewById(R.id.rgrp_search_by);
        this.mSearchByEmail = (RadioButton) findViewById(R.id.rbtn_search_by_email);
        this.mSearchByMobile = (RadioButton) findViewById(R.id.rbtn_search_by_mobile);
        this.mSearchByEmail.isChecked();
        this.mEmailTIL.setVisibility(0);
        this.mMobileTIL.setVisibility(8);
        this.mRequestForNewPWTV.setOnClickListener(this);
        this.mBacktoLoginTV.setOnClickListener(this);
        this.mRequestForNewPWTV.setTypeface(this.mMuseoSlab500);
        this.mBacktoLoginTV.setTypeface(this.mMuseoSlab500);
        this.mUsername.setTypeface(this.mMuseoSlab500);
        this.mMobile.setTypeface(this.mMuseoSlab500);
        this.mEmail.setTypeface(this.mMuseoSlab500);
        this.mSearchByEmail.setTypeface(this.mMuseoSlab500);
        this.mSearchByMobile.setTypeface(this.mMuseoSlab500);
        this.mSearchBy.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                if (ForgotPasswordActivity.this.mSearchByEmail.isChecked()) {
                    ForgotPasswordActivity.this.searchBy = 0;
                    ForgotPasswordActivity.this.mEmailTIL.setVisibility(0);
                    ForgotPasswordActivity.this.mMobileTIL.setVisibility(8);
                } else {
                    ForgotPasswordActivity.this.searchBy = 1;
                    ForgotPasswordActivity.this.mEmailTIL.setVisibility(8);
                    ForgotPasswordActivity.this.mMobileTIL.setVisibility(0);
                }
            }
        });
        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);
    }

    @Override
    public void onClick(View view) {
        String str;
        String str2;
        if (view == this.mRequestForNewPWTV) {
            this.username = this.mUsername.getText().toString().trim();
            this.mobileNo = this.mMobile.getText().toString().trim();
            this.email = this.mEmail.getText().toString().trim();
            String str3 = this.username;
            if (str3 != null && str3.length() > 0 && !this.username.equalsIgnoreCase("null")) {
                if (this.searchBy != 0 ? !((str = this.mobileNo) == null || str.length() <= 0 || this.mobileNo.equalsIgnoreCase("null") || !Constants.isValidPhoneNum(this.mobileNo)) : !((str2 = this.email) == null || str2.length() <= 0 || this.email.equalsIgnoreCase("null") || !Constants.isValidEmail(this.email))) {
                    loadForgotPasswordData();
                } else if (this.searchBy == 0) {
                    Toast.makeText(getApplicationContext(), "Enter Valid Email", 1).show();
                } else {
                    Toast.makeText(getApplicationContext(), "Enter Valid Mobile No", 1).show();
                }
            } else {
                Toast.makeText(getApplicationContext(), "Enter Username", 1).show();
            }
        }
        if (view == this.mBacktoLoginTV) {
            setResult(565, new Intent());
            finish();
            overridePendingTransition(R.anim.left_in, R.anim.right_out);
        }
        if (view == this.mDialogeAlertYes) {
            Dialog dialog = this.mDialogAlert;
            if (dialog != null && dialog.isShowing()) {
                this.mDialogAlert.dismiss();
            }
            if (this.bit == 1) {
                finish();
            }
        }
    }

    private void loadForgotPasswordData() {
        ConnectivityManager connectivityManager = (ConnectivityManager) getSystemService("connectivity");
        if (connectivityManager.getActiveNetworkInfo() != null && connectivityManager.getActiveNetworkInfo().isAvailable() && connectivityManager.getActiveNetworkInfo().isConnected()) {
            getForgotPassword();
        } else {
            Toast.makeText(getApplicationContext(), "Check your Network Connection", 0).show();
        }
    }

    private void getForgotPassword() {
        String str;
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        if (this.searchBy == 1) {
            str = this.mobileNo;
        } else {
            str = this.email;
        }
        HashMap hashMap = new HashMap();
        hashMap.put("Usename", this.username);
        hashMap.put("MobileOrMail", str);
        hashMap.put("rbtntype", String.valueOf(this.searchBy));
        hashMap.put("apikey", "hjysgt87e-andparentid-84376-mcb-dt34986tj");
        ((ApiInterface) ApiClient.getClientWithStaticHeader(getApplicationContext()).create(ApiInterface.class)).GetForgotPassword(hashMap).enqueue(new Callback<ForgotPasswordModel>() {
            public void onResponse(Call<ForgotPasswordModel> call, Response<ForgotPasswordModel> response) {
                if (ForgotPasswordActivity.this.mProgressbar != null && ForgotPasswordActivity.this.mProgressbar.isShowing()) {
                    ForgotPasswordActivity.this.mProgressbar.dismiss();
                }
                if (response == null || response.body() == null) {
                    Utility.showAlertDialog(ForgotPasswordActivity.this.myActivity);
                    return;
                }
                Bundle bundle = new Bundle();
                bundle.putString("user_name", ForgotPasswordActivity.this.username);
                ForgotPasswordActivity.this.mFirebaseAnalytics.logEvent("EVENT_FORGOT_PASSWORD", bundle);
                ForgotPasswordModel forgotPasswordModel = (ForgotPasswordModel) response.body();
                ForgotPasswordActivity.this.bit = forgotPasswordModel.getBit();
                ForgotPasswordActivity.this.mAlertText.setText(forgotPasswordModel.getMessage());
                ForgotPasswordActivity.this.mDialogAlert.show();
            }

            public void onFailure(Call<ForgotPasswordModel> call, Throwable th) {
                if (ForgotPasswordActivity.this.mProgressbar != null && ForgotPasswordActivity.this.mProgressbar.isShowing()) {
                    ForgotPasswordActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(ForgotPasswordActivity.this.myActivity);
            }
        });
    }

    public boolean onOptionsItemSelected(MenuItem menuItem) {
        if (menuItem.getItemId() == 16908332) {
            super.onBackPressed();
            return true;
        }
        return super.onOptionsItemSelected(menuItem);
    }

    protected void onResume() {
        super.onResume();
        FirebaseAnalytics.getInstance(this).logEvent("PAGE_FORGOT_PASSWORD", null);
    }
}