导航菜单

页面标题

页面副标题

Fix Locker v1.5 - ShowEmiAndOtherDetailsActivity.java 源代码

正在查看: Fix Locker v1.5 应用的 ShowEmiAndOtherDetailsActivity.java JAVA 源代码文件

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


package com.user.a4keygen.activity;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Bundle;
import android.util.Log;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.messaging.FirebaseMessaging;
import com.google.gson.JsonObject;
import com.user.a4keygen.R;
import com.user.a4keygen.constants.WebServiceUrlConstant;
import com.user.a4keygen.model.CommonResponseModel;
import com.user.a4keygen.network.ApiClient;
import com.user.a4keygen.network.ApiInterface;
import com.user.a4keygen.network.model.GetDealerDetailsByUserIdResponseModel;
import com.user.a4keygen.network.model.GetUserEmiModel;
import com.user.a4keygen.network.model.USerLoanModel;
import com.user.a4keygen.sharedprefrence.SharedPrefManager;
import com.user.a4keygen.webutil.WebClientService;
import java.text.NumberFormat;
import java.util.List;
import java.util.Locale;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

public class ShowEmiAndOtherDetailsActivity extends AppCompatActivity {
    TextView TVBalanceAmount;
    ConstraintLayout constraintLayoutAttentionDetails;
    TextView lblBalanceAmount;
    TextView lblDownPayment;
    TextView lblDueEmiAmount;
    TextView lblEmiAmount;
    TextView lblLoanAmount;
    TextView lblLoanAmountIEAValue;
    TextView lblNumOfEmi;
    TextView lblPaidEmiAmountValue;
    TextView lblPenalAmt;
    TextView lblProcessingFees;
    TextView lblProductPrice;
    TextView lblTotalPaidEmiAmount;
    TextView tvPenalty;

    protected void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        if (WebClientService.getWebServiceUrl().equals(WebServiceUrlConstant.GMM_WEB_SERVICE_URL)) {
            setContentView(R.layout.show_emi_other_details_gmm);
        } else {
            setContentView(R.layout.activity_show_emi_and_other_details);
        }
        this.lblProductPrice = (TextView) findViewById(R.id.lblProductPrice);
        this.lblDownPayment = (TextView) findViewById(R.id.lblDownPayment);
        this.lblEmiAmount = (TextView) findViewById(R.id.lblEmiAmount);
        this.lblNumOfEmi = (TextView) findViewById(R.id.lblNumOfEmi);
        this.lblProcessingFees = (TextView) findViewById(R.id.lblProcessingFees);
        this.lblLoanAmount = (TextView) findViewById(R.id.lblLoanAmount);
        this.lblTotalPaidEmiAmount = (TextView) findViewById(R.id.lblTotalPaidEmiAmount);
        this.TVBalanceAmount = (TextView) findViewById(R.id.TVBalanceAmount);
        this.lblDueEmiAmount = (TextView) findViewById(R.id.lblDueEmiAmount);
        this.lblPenalAmt = (TextView) findViewById(R.id.lblPenalAmt);
        if (WebClientService.getWebServiceUrl().equals(WebServiceUrlConstant.ADVANCE_FINANCE_URL_PROD) || WebClientService.getWebServiceUrl().equals("http://103.196.193.4/advancefinance-ws-v1.0/") || WebClientService.getWebServiceUrl().equals("http://advancefinance.in/advancefinance-ws-v1.0_test/")) {
            ConstraintLayout findViewById = findViewById(R.id.constraintLayoutAttentionDetails);
            this.constraintLayoutAttentionDetails = findViewById;
            findViewById.setVisibility(0);
            TextView textView = (TextView) findViewById(R.id.penalty_tv);
            this.tvPenalty = textView;
            textView.setVisibility(0);
        }
        checkInternet();
    }

    public void storeToken(String str) {
        SharedPrefManager.getInstance(getApplicationContext()).saveDeviceToken(str);
        if (WebClientService.isNull(SharedPrefManager.getInstance(getApplicationContext()).getUserId())) {
            return;
        }
        onSaveTokenOnRemote(str);
    }

    private void onSaveTokenOnRemote(String str) {
        JsonObject jsonObject = new JsonObject();
        jsonObject.addProperty("id", SharedPrefManager.getInstance(getApplicationContext()).getUserId());
        jsonObject.addProperty("token", str);
        ((ApiInterface) ApiClient.getInstance(this).getClient().create(ApiInterface.class)).tokenUpdate(jsonObject).enqueue(new Callback<CommonResponseModel>() {
            public void onResponse(Call<CommonResponseModel> call, Response<CommonResponseModel> response) {
                if (response.isSuccessful()) {
                    return;
                }
                Log.e("TAG", "Token update fail from remote");
            }

            public void onFailure(Call<CommonResponseModel> call, Throwable th) {
                Log.e("TAG", "Token update fail");
            }
        });
    }

    private void generateFcmToken() {
        System.out.println("PrevioseToken " + SharedPrefManager.getInstance(getApplicationContext()).getDeviceToken());
        FirebaseMessaging.getInstance().getToken().addOnCompleteListener(new OnCompleteListener<String>() {
            public void onComplete(Task<String> task) {
                if (!task.isSuccessful()) {
                    Log.w("TAG", "Fetching FCM registration token failed", task.getException());
                    return;
                }
                String str = (String) task.getResult();
                System.out.println("nowGenetedToken " + str);
                ShowEmiAndOtherDetailsActivity.this.storeToken(str);
                Log.d("FCM Token", "Token updated: " + str);
            }
        });
    }

    private void checkInternet() {
        if (WebClientService.isInternetOn(this)) {
            getDealerDetailsByUserIdApi();
            generateFcmToken();
            return;
        }
        AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setTitle("INTERNET CONNECTION");
        builder.setMessage("PLEASE TURN ON INTERNET");
        builder.setCancelable(false);
        builder.setPositiveButton("OK", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                dialogInterface.dismiss();
            }
        });
        builder.create().show();
    }

    private void getDealerDetailsByUserIdApi() {
        try {
            ((ApiInterface) ApiClient.getInstance(this).getClient().create(ApiInterface.class)).getDealerDetailsApi(SharedPrefManager.getInstance(getApplicationContext()).getUserId()).enqueue(new Callback<GetDealerDetailsByUserIdResponseModel>() {
                public void onResponse(Call<GetDealerDetailsByUserIdResponseModel> call, Response<GetDealerDetailsByUserIdResponseModel> response) {
                    if (response != null) {
                        try {
                            if (response.isSuccessful() && response.body() != null) {
                                if ("S".equals(((GetDealerDetailsByUserIdResponseModel) response.body()).getStatus())) {
                                    if (((GetDealerDetailsByUserIdResponseModel) response.body()).getData() != null) {
                                        ShowEmiAndOtherDetailsActivity.this.handleResponse(((GetDealerDetailsByUserIdResponseModel) response.body()).getData().getEmis(), ((GetDealerDetailsByUserIdResponseModel) response.body()).getData().getuSerLoanModel());
                                    }
                                } else if ("F".equals(((GetDealerDetailsByUserIdResponseModel) response.body()).getStatus())) {
                                    if (!WebClientService.isNull(((GetDealerDetailsByUserIdResponseModel) response.body()).getMessage())) {
                                        Toast.makeText((Context) ShowEmiAndOtherDetailsActivity.this, (CharSequence) "Something went wrong", 1);
                                    } else {
                                        Toast.makeText((Context) ShowEmiAndOtherDetailsActivity.this, (CharSequence) "Something went wrong", 1);
                                    }
                                }
                            } else {
                                Toast.makeText((Context) ShowEmiAndOtherDetailsActivity.this, (CharSequence) "Response Is Null Something went wrong", 1);
                            }
                        } catch (Exception e) {
                            e.printStackTrace();
                            Toast.makeText((Context) ShowEmiAndOtherDetailsActivity.this, (CharSequence) "Something went wrong", 1);
                        }
                    }
                }

                public void onFailure(Call<GetDealerDetailsByUserIdResponseModel> call, Throwable th) {
                    Toast.makeText((Context) ShowEmiAndOtherDetailsActivity.this, (CharSequence) "Something went wrong", 1);
                }
            });
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public void handleResponse(List<GetUserEmiModel> list, USerLoanModel uSerLoanModel) {
        try {
            setPaidEmiAmount(list, uSerLoanModel);
            if (WebClientService.isNull(list)) {
                return;
            }
            setTableLayoutAndEmiData(list);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private void setTableLayoutAndEmiData(List<GetUserEmiModel> list) {
        TableLayout tableLayout = (TableLayout) findViewById(R.id.emiTableLayout);
        for (GetUserEmiModel getUserEmiModel : list) {
            TableRow tableRow = new TableRow(this);
            TextView textView = new TextView(this);
            textView.setTextColor(getResources().getColor(R.color.black));
            textView.setText(getUserEmiModel.getCreatedAt());
            textView.setPadding(8, 8, 8, 8);
            tableRow.addView(textView);
            TextView textView2 = new TextView(this);
            textView2.setText(String.valueOf(getUserEmiModel.getEmiAmount()));
            textView2.setTextColor(getResources().getColor(R.color.black));
            textView2.setPadding(8, 8, 8, 8);
            tableRow.addView(textView2);
            TextView textView3 = new TextView(this);
            textView3.setTextColor(getResources().getColor(R.color.black));
            textView3.setText(getUserEmiModel.getPaymentMode());
            textView3.setPadding(8, 8, 8, 8);
            tableRow.addView(textView3);
            TextView textView4 = new TextView(this);
            textView4.setTextColor(getResources().getColor(R.color.black));
            textView4.setText(getUserEmiModel.getRemark());
            textView4.setPadding(8, 8, 8, 8);
            tableRow.addView(textView4);
            tableLayout.addView(tableRow);
            tableLayout.setPadding(12, 0, 8, 0);
        }
    }

    private String addRupeeSign(int i) {
        return NumberFormat.getCurrencyInstance(new Locale("en", "in")).format(i);
    }

    private void setPaidEmiAmount(List<GetUserEmiModel> list, USerLoanModel uSerLoanModel) {
        int i;
        int i2 = 0;
        int i3 = 0;
        for (int i4 = 0; i4 < list.size(); i4++) {
            try {
                i3 += list.get(i4).getEmiAmount();
            } catch (Exception e) {
                e.printStackTrace();
                return;
            }
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getLoanAmount())) {
            this.lblLoanAmount.setText(String.valueOf(uSerLoanModel.getLoanAmount()));
            i = uSerLoanModel.getLoanAmount().intValue();
        } else {
            this.lblLoanAmount.setText("N/A");
            i = 0;
        }
        if (!WebClientService.isNullTest(Integer.valueOf(i3))) {
            this.lblTotalPaidEmiAmount.setText(String.valueOf(i3));
            i2 = i3;
        } else {
            this.lblTotalPaidEmiAmount.setText("N/A");
        }
        this.TVBalanceAmount.setText(String.valueOf(i - i2));
        if (!WebClientService.isNullTest(uSerLoanModel.getProductPrice())) {
            this.lblProductPrice.setText(String.valueOf(uSerLoanModel.getProductPrice()));
        } else {
            this.lblProductPrice.setText("N/A");
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getDownPayment())) {
            this.lblDownPayment.setText(String.valueOf(uSerLoanModel.getDownPayment()));
        } else {
            this.lblDownPayment.setText("N/A");
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getActualEMI())) {
            this.lblEmiAmount.setText(String.valueOf(uSerLoanModel.getActualEMI()));
        } else {
            this.lblEmiAmount.setText("N/A");
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getNoOfEmi())) {
            this.lblNumOfEmi.setText(String.valueOf(uSerLoanModel.getNoOfEmi()));
        } else {
            this.lblNumOfEmi.setText("N/A");
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getProessingFees())) {
            this.lblProcessingFees.setText(String.valueOf(uSerLoanModel.getProessingFees()));
        } else {
            this.lblProcessingFees.setText("N/A");
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getDueAmount())) {
            this.lblDueEmiAmount.setText(String.valueOf(uSerLoanModel.getDueAmount()));
        } else {
            this.lblProductPrice.setText("N/A");
        }
        if (!WebClientService.isNullTest(uSerLoanModel.getPenaltyAmount())) {
            this.lblPenalAmt.setText(String.valueOf(uSerLoanModel.getPenaltyAmount()));
        } else {
            this.lblPenalAmt.setText("N/A");
        }
    }
}