导航菜单

页面标题

页面副标题

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

正在查看: St.John's v1.0.9 应用的 SelectPaymentGateWayActivity.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package com.mcb.stjohnsemschool.activity;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.graphics.Typeface;
import android.net.ConnectivityManager;
import android.os.Bundle;
import android.text.SpannableString;
import android.text.style.UnderlineSpan;
import android.view.ContextThemeWrapper;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.RadioButton;
import android.widget.RadioGroup;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import androidx.appcompat.app.AppCompatActivity;
import com.google.firebase.analytics.FirebaseAnalytics;
import com.mcb.stjohnsemschool.DB.MyClassBoardDB;
import com.mcb.stjohnsemschool.model.GatewayModelClass;
import com.mcb.stjohnsemschool.model.JsonModelClass;
import com.mcb.stjohnsemschool.model.PayOnlineValidateTimeModel;
import com.mcb.stjohnsemschool.model.SavingResponseModel;
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.text.DecimalFormat;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.HashMap;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class SelectPaymentGateWayActivity extends AppCompatActivity implements View.OnClickListener {
    private static final String TAG = "com.mcb.stjohnsemschool.activity.SelectPaymentGateWayActivity";
    public static Activity mActivityObj;
    TextView amount;
    String array;
    String branchId;
    TextView branchName;
    TextView className;
    private ConnectivityManager conMgr;
    private SpannableString content;
    TextView enrollmentCode;
    int feeAccountID;
    RadioGroup gatewayGroup;
    String gatewayName;
    String jsonarray;
    String mAcademicYearId;
    String mBranch;
    Button mCancel;
    String mClass;
    String mClassId;
    SharedPreferences.Editor mEditor;
    String mEnrollmentCode;
    TextView mHeader;
    LinearLayout mInclusiveTaxesLL;
    private Typeface mLatoFont;
    String mName;
    TextView mPayOnlineAlertText;
    Dialog mPayOnlineDialog;
    Button mProceedAnyway;
    private TransparentProgressDialog mProgressbar;
    String mSection;
    SharedPreferences mSharedPref;
    TextView mShowNodataText;
    String mStudentEnrollmentID;
    TextView mTransactionId;
    LinearLayout mTransactionIdLL;
    String mUserId;
    String organisationId;
    String payingAmount;
    Button paynow;
    String studentEnrollmentCode;
    TextView studentName;
    TableLayout tl_feedetails;
    String transactionId;
    String username;
    private String payOnLineUrl = "";
    MyClassBoardDB db = null;
    int gateWayID = 0;
    String opconcessionStr = "";
    ArrayList<GatewayModelClass> mGatewayList = new ArrayList<>();
    DecimalFormat df = new DecimalFormat("###.##");
    ArrayList<JsonModelClass> mList = new ArrayList<>();
    private boolean isAvailOffer = false;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.activity_gateways);
        mActivityObj = this;
        this.mLatoFont = Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf");
        getSupportActionBar().setTitle("Online Payment");
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);
        mActivityObj = this;
        SharedPreferences sharedPreferences = getSharedPreferences("", 0);
        this.mSharedPref = sharedPreferences;
        this.mEditor = sharedPreferences.edit();
        this.mUserId = this.mSharedPref.getString("UseridKey", this.mUserId);
        this.mClassId = this.mSharedPref.getString("ClassidKey", this.mClassId);
        this.mStudentEnrollmentID = this.mSharedPref.getString("studentEnrollmentIdKey", this.mStudentEnrollmentID);
        this.studentEnrollmentCode = this.mSharedPref.getString("EnrollmentCode", this.studentEnrollmentCode);
        this.mAcademicYearId = this.mSharedPref.getString("academicyearIdKey", this.mAcademicYearId);
        this.branchId = this.mSharedPref.getString("BranchIdKey", this.branchId);
        this.organisationId = this.mSharedPref.getString("orgnizationIdKey", this.organisationId);
        this.mBranch = this.mSharedPref.getString("branchnameKey", this.mBranch);
        this.mEnrollmentCode = this.mSharedPref.getString("EnrollmentCode", this.mEnrollmentCode);
        this.mName = this.mSharedPref.getString("Name", this.mName);
        this.mClass = this.mSharedPref.getString("AcademicClassName", this.mClass);
        this.mSection = this.mSharedPref.getString("AcademicSection", this.mSection);
        this.payOnLineUrl = getResources().getString(R.string.payonline_url) + "/OnlinePayment_App.aspx?postData=";
        this.mAcademicYearId = getIntent().getExtras().getString("AcademicYearId", "0");
        if (getIntent().hasExtra("transactionId")) {
            this.transactionId = getIntent().getExtras().getString("transactionId", "");
        }
        this.payingAmount = getIntent().getExtras().getString("payingAmount", this.payingAmount);
        this.jsonarray = getIntent().getExtras().getString("jsonarray", this.jsonarray);
        this.array = getIntent().getExtras().getString("array", this.array);
        this.isAvailOffer = getIntent().getExtras().getBoolean("AvailOffer");
        try {
            this.feeAccountID = new JSONArray(this.jsonarray).getJSONObject(0).getInt("FeeAccountID");
        } catch (JSONException e) {
            e.printStackTrace();
        }
        setUps();
        GetPaymentGateways();
    }

    private void setUps() {
        String str = "TaxName";
        Dialog dialog = new Dialog(this);
        this.mPayOnlineDialog = dialog;
        dialog.requestWindowFeature(1);
        this.mPayOnlineDialog.setContentView(R.layout.dialog_payonline);
        this.mPayOnlineDialog.setCancelable(false);
        this.mPayOnlineAlertText = (TextView) this.mPayOnlineDialog.findViewById(R.id.txv_text);
        this.mCancel = (Button) this.mPayOnlineDialog.findViewById(R.id.btn_cancel);
        this.mProceedAnyway = (Button) this.mPayOnlineDialog.findViewById(R.id.btn_proceed_anyway);
        this.mPayOnlineAlertText.setTypeface(this.mLatoFont);
        this.mCancel.setTypeface(this.mLatoFont, 1);
        this.mProceedAnyway.setTypeface(this.mLatoFont, 1);
        this.mCancel.setOnClickListener(this);
        this.mProceedAnyway.setOnClickListener(this);
        TextView textView = (TextView) findViewById(R.id.alert_message_text);
        this.mShowNodataText = textView;
        textView.setText("Currently Online payment facility is not available.Please pay at school.");
        this.mShowNodataText.setVisibility(8);
        this.mShowNodataText.setTypeface(this.mLatoFont);
        this.tl_feedetails = (TableLayout) findViewById(R.id.tl_feedetails);
        this.paynow = (Button) findViewById(R.id.proceed_pay_tv);
        this.mProgressbar = new TransparentProgressDialog(this, R.drawable.spinner_loading_imag);
        this.branchName = (TextView) findViewById(R.id.branch);
        this.studentName = (TextView) findViewById(R.id.studentname);
        this.className = (TextView) findViewById(R.id.classname);
        this.enrollmentCode = (TextView) findViewById(R.id.enrollmentcode);
        this.amount = (TextView) findViewById(R.id.amount);
        this.gatewayGroup = (RadioGroup) findViewById(R.id.paymenttype);
        this.mTransactionId = (TextView) findViewById(R.id.txv_transaction_id);
        this.mTransactionIdLL = (LinearLayout) findViewById(R.id.ll_transaction_id);
        this.mInclusiveTaxesLL = (LinearLayout) findViewById(R.id.ll_inclusive_taxes);
        try {
            this.tl_feedetails.removeAllViews();
            JSONArray jSONArray = new JSONArray(this.array);
            this.mList.clear();
            StringBuilder sb = new StringBuilder();
            int i = 0;
            while (i < jSONArray.length()) {
                JSONObject jSONObject = jSONArray.getJSONObject(i);
                int i2 = jSONObject.getInt("FeeInstallmentID");
                String string = jSONObject.getString("InstallmentName");
                String string2 = jSONObject.getString("FeeType");
                String string3 = jSONObject.getString("Balance");
                double d = jSONObject.getDouble("GST");
                String str2 = "";
                if (jSONObject.has(str)) {
                    str2 = jSONObject.getString(str);
                }
                String str3 = str;
                JsonModelClass jsonModelClass = new JsonModelClass();
                jsonModelClass.setFeeInstallmentID(i2);
                jsonModelClass.setInstallmentName(string);
                jsonModelClass.setFeeType(string2);
                jsonModelClass.setBalance(string3);
                jsonModelClass.setGstAmount(d);
                jsonModelClass.setTaxName(str2);
                this.mList.add(jsonModelClass);
                if (jSONObject.has("Concession")) {
                    sb.append(jSONObject.getInt("FeeInstallmentID"));
                    sb.append("-");
                    sb.append(jSONObject.getString("Concession"));
                    sb.append("$");
                }
                i++;
                str = str3;
            }
            if (sb.length() > 0) {
                this.opconcessionStr = sb.deleteCharAt(sb.length() - 1).toString();
            }
            Collections.sort(this.mList, new Comparator<JsonModelClass>() {
                @Override
                public int compare(JsonModelClass jsonModelClass2, JsonModelClass jsonModelClass3) {
                    return jsonModelClass2.getFeeInstallmentID() - jsonModelClass3.getFeeInstallmentID();
                }
            });
            for (int i3 = 0; i3 < this.mList.size(); i3++) {
                JsonModelClass jsonModelClass2 = this.mList.get(i3);
                String feeType = jsonModelClass2.getFeeType();
                String installmentName = jsonModelClass2.getInstallmentName();
                String balance = jsonModelClass2.getBalance();
                double gstAmount = jsonModelClass2.getGstAmount();
                String taxName = jsonModelClass2.getTaxName();
                float parseFloat = Float.parseFloat(balance);
                TableRow tableRow = new TableRow(this);
                StringBuilder sb2 = new StringBuilder();
                sb2.append(feeType);
                sb2.append("-");
                sb2.append(installmentName);
                sb2.append(" :");
                double d2 = parseFloat;
                sb2.append(this.df.format(d2));
                String sb3 = sb2.toString();
                if (gstAmount > 0.0d) {
                    StringBuilder sb4 = new StringBuilder();
                    sb4.append(feeType);
                    sb4.append("-");
                    sb4.append(installmentName);
                    sb4.append(" :");
                    sb4.append(this.df.format(d2));
                    sb4.append("+");
                    if (!Utility.isStringHasValue(taxName)) {
                        taxName = "GST";
                    }
                    sb4.append(taxName);
                    sb4.append("(");
                    sb4.append(this.df.format(gstAmount));
                    sb4.append(")=");
                    sb4.append(this.df.format(d2 + gstAmount));
                    sb3 = sb4.toString();
                }
                TextView elementTextView = getElementTextView(sb3, 1.0f);
                elementTextView.setTextColor(getResources().getColor(R.color.ColorPrimary));
                tableRow.addView(elementTextView);
                this.tl_feedetails.addView(tableRow);
            }
        } catch (JSONException e) {
            e.printStackTrace();
        }
        SpannableString spannableString = new SpannableString("Note");
        this.content = spannableString;
        spannableString.setSpan(new UnderlineSpan(), 0, this.content.length(), 0);
        float parseFloat2 = Float.parseFloat(this.payingAmount.toString());
        this.branchName.setText(this.mBranch);
        this.studentName.setText(": " + this.mName);
        this.enrollmentCode.setText(": " + this.mEnrollmentCode);
        this.className.setText(": " + this.mClass + "-" + this.mSection);
        TextView textView2 = this.amount;
        StringBuilder sb5 = new StringBuilder(": ");
        sb5.append(this.df.format((double) parseFloat2));
        textView2.setText(sb5.toString());
        String str4 = this.transactionId;
        if (str4 != null && str4.length() > 0) {
            this.mTransactionId.setText(": " + this.transactionId);
            this.mTransactionIdLL.setVisibility(0);
            this.mInclusiveTaxesLL.setVisibility(0);
        } else {
            this.mTransactionIdLL.setVisibility(8);
            this.mInclusiveTaxesLL.setVisibility(8);
        }
        this.branchName.setTypeface(this.mLatoFont);
        this.studentName.setTypeface(this.mLatoFont);
        this.enrollmentCode.setTypeface(this.mLatoFont);
        this.className.setTypeface(this.mLatoFont);
        this.amount.setTypeface(this.mLatoFont);
        this.paynow.setTypeface(this.mLatoFont);
        this.paynow.setOnClickListener(this);
    }

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

    private void getPaymentGateWays() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).GetPaymentGateWays(Integer.parseInt(this.organisationId), Integer.parseInt(this.branchId), this.feeAccountID, Utility.getSchoolApiKey(this)).enqueue(new Callback<ArrayList<GatewayModelClass>>() {
            public void onResponse(Call<ArrayList<GatewayModelClass>> call, Response<ArrayList<GatewayModelClass>> response) {
                if (SelectPaymentGateWayActivity.this.mProgressbar != null && SelectPaymentGateWayActivity.this.mProgressbar.isShowing()) {
                    SelectPaymentGateWayActivity.this.mProgressbar.dismiss();
                }
                if (response != null && response.body() != null) {
                    SelectPaymentGateWayActivity.this.mGatewayList.clear();
                    SelectPaymentGateWayActivity.this.mGatewayList = (ArrayList) response.body();
                    if (SelectPaymentGateWayActivity.this.mGatewayList != null && SelectPaymentGateWayActivity.this.mGatewayList.size() > 0) {
                        for (int i = 0; i < SelectPaymentGateWayActivity.this.mGatewayList.size(); i++) {
                            GatewayModelClass gatewayModelClass = SelectPaymentGateWayActivity.this.mGatewayList.get(i);
                            String paymentGatewayName = gatewayModelClass.getPaymentGatewayName();
                            int paymentGatewayID = gatewayModelClass.getPaymentGatewayID();
                            RadioButton radioButton = new RadioButton(new ContextThemeWrapper((Context) SelectPaymentGateWayActivity.this, R.style.MyRadioButton));
                            radioButton.setText(paymentGatewayName);
                            radioButton.setId(paymentGatewayID);
                            radioButton.setTextColor(SelectPaymentGateWayActivity.this.getResources().getColor(R.color.ColorPrimary));
                            radioButton.setTypeface(SelectPaymentGateWayActivity.this.mLatoFont);
                            radioButton.setTextSize(16.0f);
                            radioButton.setTextColor(SelectPaymentGateWayActivity.this.getResources().getColor(R.color.ColorPrimary));
                            SelectPaymentGateWayActivity.this.gatewayGroup.addView(radioButton);
                        }
                        SelectPaymentGateWayActivity.this.gatewayGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
                            @Override
                            public void onCheckedChanged(RadioGroup radioGroup, int i2) {
                                SelectPaymentGateWayActivity.this.gateWayID = SelectPaymentGateWayActivity.this.gatewayGroup.getCheckedRadioButtonId();
                                SelectPaymentGateWayActivity.this.gatewayName = String.valueOf(SelectPaymentGateWayActivity.this.gatewayGroup.getCheckedRadioButtonId());
                                SelectPaymentGateWayActivity.this.paynow.setVisibility(0);
                            }
                        });
                        if (SelectPaymentGateWayActivity.this.mGatewayList.size() > 0) {
                            SelectPaymentGateWayActivity.this.gatewayGroup.check(SelectPaymentGateWayActivity.this.mGatewayList.get(0).getPaymentGatewayID());
                            return;
                        }
                        return;
                    }
                    SelectPaymentGateWayActivity.this.mShowNodataText.setVisibility(0);
                    SelectPaymentGateWayActivity.this.paynow.setVisibility(8);
                    return;
                }
                Utility.showAlertDialog(SelectPaymentGateWayActivity.mActivityObj);
            }

            public void onFailure(Call<ArrayList<GatewayModelClass>> call, Throwable th) {
                if (SelectPaymentGateWayActivity.this.mProgressbar != null && SelectPaymentGateWayActivity.this.mProgressbar.isShowing()) {
                    SelectPaymentGateWayActivity.this.mProgressbar.dismiss();
                }
                Utility.showAlertDialog(SelectPaymentGateWayActivity.mActivityObj);
            }
        });
    }

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

    private void getPayOnlineWithStatusCheckingResult() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("OrganisationID", this.organisationId);
        hashMap.put("UserId", this.mUserId);
        hashMap.put("UserName", this.studentEnrollmentCode);
        hashMap.put("PaymentGatewayID", String.valueOf(this.gateWayID));
        hashMap.put("SID", this.mStudentEnrollmentID);
        hashMap.put("BranchID", this.branchId);
        hashMap.put("AcademicYearID", this.mAcademicYearId);
        hashMap.put("Amount", String.valueOf(this.payingAmount));
        hashMap.put("dtfeejson", this.jsonarray);
        hashMap.put("apikey", Utility.getSchoolApiKey(this));
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getPayOnlineWithStatusChecking(hashMap).enqueue(new Callback<PayOnlineValidateTimeModel>() {
            public void onResponse(Call<PayOnlineValidateTimeModel> call, Response<PayOnlineValidateTimeModel> response) {
                if (SelectPaymentGateWayActivity.this.mProgressbar != null && SelectPaymentGateWayActivity.this.mProgressbar.isShowing()) {
                    SelectPaymentGateWayActivity.this.mProgressbar.dismiss();
                }
                if (response != null && response.body() != null) {
                    PayOnlineValidateTimeModel payOnlineValidateTimeModel = (PayOnlineValidateTimeModel) response.body();
                    int status = payOnlineValidateTimeModel.getStatus();
                    String message = payOnlineValidateTimeModel.getMessage();
                    if (status == 1) {
                        Intent intent = new Intent(SelectPaymentGateWayActivity.this.getApplicationContext(), (Class<?>) OnlinePaymentActivity.class);
                        intent.putExtra("OnlinePaymentId", message);
                        if (SelectPaymentGateWayActivity.this.isAvailOffer) {
                            intent.putExtra("PayOnlineUrl", SelectPaymentGateWayActivity.this.payOnLineUrl + message + "&OPConcession=" + SelectPaymentGateWayActivity.this.opconcessionStr);
                        } else {
                            intent.putExtra("PayOnlineUrl", SelectPaymentGateWayActivity.this.payOnLineUrl + message);
                        }
                        SelectPaymentGateWayActivity.this.startActivity(intent);
                        return;
                    }
                    SelectPaymentGateWayActivity.this.mPayOnlineAlertText.setText(message);
                    if (SelectPaymentGateWayActivity.this.mPayOnlineDialog == null || SelectPaymentGateWayActivity.this.mPayOnlineDialog.isShowing()) {
                        return;
                    }
                    SelectPaymentGateWayActivity.this.mPayOnlineDialog.show();
                    return;
                }
                Utility.showAlertDialog(SelectPaymentGateWayActivity.mActivityObj);
            }

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

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

    private void getPayOnlineResult() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("OrganisationID", this.organisationId);
        hashMap.put("UserId", this.mUserId);
        hashMap.put("UserName", this.studentEnrollmentCode);
        hashMap.put("PaymentGatewayID", String.valueOf(this.gateWayID));
        hashMap.put("SID", this.mStudentEnrollmentID);
        hashMap.put("BranchID", this.branchId);
        hashMap.put("AcademicYearID", this.mAcademicYearId);
        hashMap.put("Amount", String.valueOf(this.payingAmount));
        hashMap.put("dtfeejson", this.jsonarray);
        hashMap.put("apikey", Utility.getSchoolApiKey(this));
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getPayOnlineResult(hashMap).enqueue(new Callback<String>() {
            public void onResponse(Call<String> call, Response<String> response) {
                if (SelectPaymentGateWayActivity.this.mProgressbar != null && SelectPaymentGateWayActivity.this.mProgressbar.isShowing()) {
                    SelectPaymentGateWayActivity.this.mProgressbar.dismiss();
                }
                if (response != null && response.body() != null) {
                    String str = (String) response.body();
                    Intent intent = new Intent(SelectPaymentGateWayActivity.this.getApplicationContext(), (Class<?>) OnlinePaymentActivity.class);
                    intent.putExtra("OnlinePaymentId", str);
                    if (SelectPaymentGateWayActivity.this.isAvailOffer) {
                        intent.putExtra("PayOnlineUrl", SelectPaymentGateWayActivity.this.payOnLineUrl + str + "&OPConcession=" + SelectPaymentGateWayActivity.this.opconcessionStr);
                    } else {
                        intent.putExtra("PayOnlineUrl", SelectPaymentGateWayActivity.this.payOnLineUrl + str);
                    }
                    SelectPaymentGateWayActivity.this.startActivity(intent);
                    return;
                }
                Utility.showAlertDialog(SelectPaymentGateWayActivity.mActivityObj);
            }

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

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

    TextView getElementTextView(String str, float f) {
        TextView textView = new TextView(this);
        textView.setLayoutParams(new TableRow.LayoutParams(0, -1, f));
        textView.setText(str);
        textView.setTextSize(14.0f);
        textView.setTextColor(getResources().getColor(R.color.ColorPrimaryDark));
        textView.setTypeface(this.mLatoFont);
        textView.setGravity(3);
        textView.setPadding(10, 10, 10, 10);
        return textView;
    }

    @Override
    public void onClick(View view) {
        if (view == this.paynow) {
            if (this.gateWayID == 0) {
                new AlertDialog.Builder(this).setMessage("Please select card Type/Bank").setCancelable(false).setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                    @Override
                    public void onClick(DialogInterface dialogInterface, int i) {
                        dialogInterface.cancel();
                    }
                }).show();
                return;
            }
            String str = this.transactionId;
            if (str != null && str.length() > 0) {
                payOnlineWithStatusCheckingSchoolStoreResult();
                return;
            } else {
                payOnlineWithStatusChecking();
                return;
            }
        }
        if (view == this.mCancel) {
            Dialog dialog = this.mPayOnlineDialog;
            if (dialog != null && dialog.isShowing()) {
                this.mPayOnlineDialog.dismiss();
            }
            finish();
            return;
        }
        if (view == this.mProceedAnyway) {
            Dialog dialog2 = this.mPayOnlineDialog;
            if (dialog2 != null && dialog2.isShowing()) {
                this.mPayOnlineDialog.dismiss();
            }
            payOnline();
        }
    }

    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_PAYMENT_GATEWAY_SELECTION", bundle);
    }

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

    private void getPayOnlineWithStatusCheckingSchoolStoreResult() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && !transparentProgressDialog.isShowing()) {
            this.mProgressbar.show();
        }
        HashMap hashMap = new HashMap();
        hashMap.put("OrganisationID", this.organisationId);
        hashMap.put("UserId", this.mUserId);
        hashMap.put("UserName", this.studentEnrollmentCode);
        hashMap.put("PaymentGatewayID", String.valueOf(this.gateWayID));
        hashMap.put("SID", this.mStudentEnrollmentID);
        hashMap.put("BranchID", this.branchId);
        hashMap.put("AcademicYearID", this.mAcademicYearId);
        hashMap.put("Amount", String.valueOf(this.payingAmount));
        hashMap.put("dtfeejson", this.jsonarray);
        hashMap.put("apikey", Utility.getSchoolApiKey(this));
        ((ApiInterface) ApiClient.getClient1(getApplicationContext()).create(ApiInterface.class)).getPayOnlineWithStatusCheckingSchoolStoreResult(hashMap).enqueue(new Callback<SavingResponseModel>() {
            public void onResponse(Call<SavingResponseModel> call, Response<SavingResponseModel> response) {
                if (SelectPaymentGateWayActivity.this.mProgressbar != null && SelectPaymentGateWayActivity.this.mProgressbar.isShowing()) {
                    SelectPaymentGateWayActivity.this.mProgressbar.dismiss();
                }
                if (response != null && response.body() != null) {
                    SavingResponseModel savingResponseModel = (SavingResponseModel) response.body();
                    int intValue = savingResponseModel.getStatus().intValue();
                    String message = savingResponseModel.getMessage();
                    if (intValue == 1) {
                        Intent intent = new Intent(SelectPaymentGateWayActivity.this.getApplicationContext(), (Class<?>) OnlinePaymentActivity.class);
                        intent.putExtra("OnlinePaymentId", message);
                        intent.putExtra("PayOnlineUrl", SelectPaymentGateWayActivity.this.payOnLineUrl + message);
                        SelectPaymentGateWayActivity.this.startActivity(intent);
                        return;
                    }
                    SelectPaymentGateWayActivity.this.mPayOnlineAlertText.setText(message);
                    if (SelectPaymentGateWayActivity.this.mPayOnlineDialog == null || SelectPaymentGateWayActivity.this.mPayOnlineDialog.isShowing()) {
                        return;
                    }
                    SelectPaymentGateWayActivity.this.mPayOnlineDialog.show();
                    return;
                }
                Utility.showAlertDialog(SelectPaymentGateWayActivity.mActivityObj);
            }

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

    protected void onStop() {
        TransparentProgressDialog transparentProgressDialog = this.mProgressbar;
        if (transparentProgressDialog != null && transparentProgressDialog.isShowing()) {
            this.mProgressbar.dismiss();
        }
        super.onStop();
    }
}