package com.mexico.inloancash.activity;

import android.content.Context;
import android.content.Intent;
import android.graphics.Color;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.os.Environment;
import android.os.Handler;
import android.text.SpannableString;
import android.text.TextUtils;
import android.text.style.ForegroundColorSpan;
import android.text.style.UnderlineSpan;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.ButterKnife;
import com.facebook.appevents.AppEventsConstants;
import com.facebook.places.internal.LocationPackageRequestParams;
import com.facebook.places.model.PlaceFields;
import com.google.android.material.slider.BasicLabelFormatter;
import com.google.gson.Gson;
import com.indiaholacash.holacash.R;
import com.mexico.inloancash.bean.India_UrlListBean;
import java.io.File;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.㿎.C0701;
import ඓ.ඓ.K.䁗.C0707;
import ඓ.ඓ.K.䁗.C0713;
import ඓ.K.K.K.C1293;
import ῲ.ᨨ.㳳.C1841;

public class IndiaLoginActivity extends BaseActivity {
    public LinearLayout layoutUserCode;
    public LinearLayout login_linear;
    public TextView mIndiaGet_Code;
    public TextView mIndiaTv_Service;
    public EditText mIndiaUser_Contact_Phone;
    public EditText mIndiaUser_Get_Code;

    /* renamed from: ඓ  reason: contains not printable characters */
    public CountDownTimer f2465;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public boolean f2466 = true;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public String f2467;

    /* renamed from: 㳳  reason: contains not printable characters */
    public final CountDownTimerC0417 f2468 = new CountDownTimerC0417(LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS, 1000);

    /* renamed from: 㴹  reason: contains not printable characters */
    public boolean f2469 = true;

    /* renamed from: 㿎  reason: contains not printable characters */
    public CountDownTimer f2470;

    /* renamed from: com.mexico.inloancash.activity.IndiaLoginActivity$ʬ  reason: contains not printable characters */
    public class C0414 implements Callback<String> {
        public C0414() {
        }

        @Override // retrofit2.Callback
        public void onFailure(Call<String> call, Throwable th) {
        }

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                India_UrlListBean india_UrlListBean = (India_UrlListBean) new Gson().fromJson(response.body(), India_UrlListBean.class);
                if (india_UrlListBean.getCode() == 200) {
                    IndiaLoginActivity.this.f2467 = india_UrlListBean.getData().getPrivacy_agreement();
                }
            }
        }
    }

    /* renamed from: com.mexico.inloancash.activity.IndiaLoginActivity$ῲ  reason: contains not printable characters */
    public class RunnableC0415 implements Runnable {
        public RunnableC0415() {
        }

        public void run() {
            String r0 = IndiaLoginActivity.m1437();
            if (!TextUtils.isEmpty(r0)) {
                IndiaLoginActivity.this.mIndiaUser_Get_Code.setText(r0);
            } else {
                IndiaLoginActivity.this.mIndiaUser_Get_Code.setText("095256");
            }
            IndiaLoginActivity indiaLoginActivity = IndiaLoginActivity.this;
            if (!indiaLoginActivity.f2469) {
                C1841.m4792((Context) indiaLoginActivity, "Vui lòng đọc và tích vào ô trống để nhận được sự đồng tình của người dùng.");
            }
        }
    }

    /* renamed from: com.mexico.inloancash.activity.IndiaLoginActivity$K  reason: contains not printable characters */
    public class CountDownTimerC0416 extends CountDownTimer {
        public CountDownTimerC0416(long j, long j2) {
            super(j, j2);
        }

        public void onFinish() {
            IndiaLoginActivity.this.mIndiaGet_Code.setBackgroundResource(R.drawable.shape_send_bg);
            C1841.m4765("date", 0L);
            IndiaLoginActivity.this.mIndiaGet_Code.setText("Send");
            IndiaLoginActivity.this.mIndiaGet_Code.setClickable(true);
            IndiaLoginActivity.this.mIndiaGet_Code.setTextColor(Color.parseColor("#ffffff"));
        }

        public void onTick(long j) {
            IndiaLoginActivity.this.mIndiaGet_Code.setBackgroundResource(R.drawable.india_login_button_normal);
            IndiaLoginActivity.this.mIndiaGet_Code.setClickable(false);
            TextView textView = IndiaLoginActivity.this.mIndiaGet_Code;
            textView.setText((j / 1000) + "s");
            IndiaLoginActivity.this.mIndiaGet_Code.setTextColor(Color.parseColor("#999999"));
            SpannableString spannableString = new SpannableString(IndiaLoginActivity.this.mIndiaGet_Code.getText().toString());
            spannableString.setSpan(new ForegroundColorSpan(Color.parseColor("#999999")), 0, 2, 17);
            IndiaLoginActivity.this.mIndiaGet_Code.setText(spannableString);
        }
    }

    /* renamed from: com.mexico.inloancash.activity.IndiaLoginActivity$㸾  reason: contains not printable characters */
    public class CountDownTimerC0417 extends CountDownTimer {
        public CountDownTimerC0417(long j, long j2) {
            super(j, j2);
        }

        public void onFinish() {
            IndiaLoginActivity.this.mIndiaGet_Code.setText("Send");
            IndiaLoginActivity.this.mIndiaGet_Code.setClickable(true);
            IndiaLoginActivity.this.mIndiaGet_Code.setBackgroundResource(R.drawable.shape_send_bg);
        }

        public void onTick(long j) {
            IndiaLoginActivity.this.mIndiaGet_Code.setClickable(false);
            TextView textView = IndiaLoginActivity.this.mIndiaGet_Code;
            textView.setText((j / 1000) + "s");
            IndiaLoginActivity.this.mIndiaGet_Code.setBackgroundResource(R.drawable.india_login_button_normal);
        }
    }

    /* renamed from: ᓣ  reason: contains not printable characters */
    public static String m1437() {
        String str = "";
        try {
            Random random = new Random();
            str = random.nextInt(BasicLabelFormatter.MILLION) + str;
            int length = str.length();
            if (length < 6) {
                for (int i = 1; i <= 6 - length; i++) {
                    str = AppEventsConstants.EVENT_PARAM_VALUE_NO + str;
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        return str;
    }

    @Override // androidx.fragment.app.FragmentActivity
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i == 100 || i2 == 100) {
            finish();
        }
    }

    @Override // androidx.activity.ComponentActivity, androidx.core.app.ComponentActivity, com.mexico.inloancash.activity.BaseActivity, androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onCreate(Bundle bundle) {
        super.onCreate(bundle);
        setContentView(R.layout.india_activity_view_login_layout);
        if (!C1841.m4808()) {
            try {
                String str = getPackageName() + ".install";
                if (!new File(Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS), str + ".txt").exists()) {
                    C1841.m4758();
                    C1841.m4803(true);
                    try {
                        new C0713().m2137(this, C0707.m2136(), str);
                        Log.e("data", "First installation statistics");
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                } else {
                    Log.e("data", "Not the first time statistics");
                }
            } catch (Exception e2) {
                e2.printStackTrace();
            }
        }
        ButterKnife.m1066(this);
        SpannableString spannableString = new SpannableString(getResources().getString(R.string.login_agreement1));
        Matcher matcher = Pattern.compile("privacidad").matcher(getResources().getString(R.string.login_agreement1));
        while (matcher.find()) {
            spannableString.setSpan(new UnderlineSpan(), matcher.start(), matcher.end(), 33);
        }
        this.mIndiaTv_Service.setText(spannableString);
        m1438();
        if (C1841.m4782("date", 0L).longValue() != 0 && this.f2465 == null) {
            if ((System.currentTimeMillis() - C1841.m4782("date", 0L).longValue()) - LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS < 0) {
                this.f2465 = new CountDownTimerC0416(LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS - (System.currentTimeMillis() - C1841.m4782("date", 0L).longValue()), 1000);
                this.f2465.start();
                return;
            }
            C1841.m4765("date", 0L);
        }
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        CountDownTimer countDownTimer = this.f2465;
        if (countDownTimer != null) {
            countDownTimer.cancel();
            this.f2465 = null;
        }
        CountDownTimer countDownTimer2 = this.f2470;
        if (countDownTimer2 != null) {
            countDownTimer2.cancel();
        }
    }

    @Override // androidx.appcompat.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            finish();
        }
        return super.onKeyDown(i, keyEvent);
    }

    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.ll_new_jump_xieyi /*{ENCODED_INT: 2131296661}*/:
            case R.id.service /*{ENCODED_INT: 2131296905}*/:
                Intent intent = new Intent(this, IndiaWeb_ViewActivity.class);
                intent.putExtra("webUrl", "https://adminmxwj.cashbeemuch.com/appapi/login/prestamos_privacy_agreement.html");
                intent.putExtra("titleName", "Política de Privacidad");
                startActivity(intent);
                return;
            case R.id.login_sure /*{ENCODED_INT: 2131296675}*/:
                if (C1293.m3418(this.mIndiaUser_Contact_Phone)) {
                    C1841.m4792((Context) this, "Enter your mobile number");
                    return;
                } else if (!this.f2469) {
                    C1841.m4792((Context) this, "Please read and tick the box to receive the user agreement.");
                    return;
                } else {
                    Intent intent2 = new Intent(this, IndiaCodeActivity.class);
                    intent2.putExtra(PlaceFields.PHONE, this.mIndiaUser_Contact_Phone.getText().toString().trim());
                    startActivityForResult(intent2, 100);
                    return;
                }
            case R.id.send_code /*{ENCODED_INT: 2131296904}*/:
                if (!this.f2466) {
                    return;
                }
                if (C1293.m3418(this.mIndiaUser_Contact_Phone)) {
                    C1841.m4792((Context) this, "Enter your mobile number.");
                    return;
                } else if (this.mIndiaUser_Contact_Phone.getText().toString().trim().length() < 5) {
                    C1841.m4792((Context) this, "Please enter the correct mobile phone number.");
                    return;
                } else {
                    CountDownTimerC0417 r4 = this.f2468;
                    if (r4 != null) {
                        r4.start();
                        this.f2296.m2183();
                        new Handler().postDelayed(new RunnableC0415(), 1500);
                        return;
                    }
                    return;
                }
            default:
                return;
        }
    }

    /* renamed from: ؿ  reason: contains not printable characters */
    public void m1438() {
        C0701.f3707.m2131().m2109().enqueue(new C0414());
    }
}
