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.AccessToken;
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.MyApplication;
import com.mexico.inloancash.bean.India_UrlListBean;
import java.io.File;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Random;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.ඓ.AbstractC0629;
import ඓ.ඓ.K.㑃.C0668;
import ඓ.ඓ.K.㑃.C0669;
import ඓ.ඓ.K.㿎.AbstractC0700;
import ඓ.ඓ.K.㿎.C0701;
import ඓ.ඓ.K.䁗.C0707;
import ඓ.ඓ.K.䁗.C0713;
import ඓ.K.K.K.C1293;
import ῲ.ᨨ.㳳.C1841;

public class IndiaCodeActivity extends BaseActivity implements AbstractC0629 {
    public TextView code_phone;
    public LinearLayout layoutUserCode;
    public TextView mIndiaGet_Code;
    public TextView mIndiaTv_Service;
    public EditText mIndiaUser_Get_Code;

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

    /* renamed from: ᕣ  reason: contains not printable characters */
    public final CountDownTimerC0377 f2374 = new CountDownTimerC0377(LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS, 1000);

    /* renamed from: ᨨ  reason: contains not printable characters */
    public CountDownTimer f2375;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public C0668 f2376;

    /* renamed from: 㳳  reason: contains not printable characters */
    public boolean f2377 = true;

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

    /* renamed from: 㿎  reason: contains not printable characters */
    public String f2379;

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

        public void run() {
            String r0 = IndiaCodeActivity.m1394();
            if (!TextUtils.isEmpty(r0)) {
                IndiaCodeActivity.this.mIndiaUser_Get_Code.setText(r0);
            } else {
                IndiaCodeActivity.this.mIndiaUser_Get_Code.setText("095256");
            }
            IndiaCodeActivity indiaCodeActivity = IndiaCodeActivity.this;
            if (!indiaCodeActivity.f2378) {
                C1841.m4792((Context) indiaCodeActivity, "Vui lòng đọc và tích vào ô trống để nhận được sự đồng tình của người dùng.");
                return;
            }
            C0668 r1 = indiaCodeActivity.f2376;
            r1.f3663.m2089(indiaCodeActivity.code_phone.getText().toString().trim(), "211794", new C0669(r1));
        }
    }

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

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

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

    /* renamed from: com.mexico.inloancash.activity.IndiaCodeActivity$ῲ  reason: contains not printable characters */
    public class C0378 implements Callback<String> {
        public C0378(IndiaCodeActivity indiaCodeActivity) {
        }

        @Override // retrofit2.Callback
        public void onFailure(Call<String> call, Throwable th) {
            StringBuilder r1 = C1293.m3416("onFailure:");
            r1.append(th.toString());
            Log.d("loan", r1.toString());
        }

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            StringBuilder r1 = C1293.m3416("onResponse:");
            r1.append(response.toString());
            Log.d("loan", r1.toString());
        }
    }

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

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

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

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

        @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) {
                    IndiaCodeActivity.this.f2379 = india_UrlListBean.getData().getPrivacy_agreement();
                }
            }
        }
    }

    /* renamed from: 㗽  reason: contains not printable characters */
    public static String m1394() {
        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.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_code_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);
        this.f2376 = new C0668();
        this.f2376.m2096(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.code_phone.setText(getIntent().getStringExtra(PlaceFields.PHONE));
        this.mIndiaTv_Service.setText(spannableString);
        m1395();
        if (C1841.m4782("date", 0L).longValue() != 0 && this.f2373 == null) {
            if ((System.currentTimeMillis() - C1841.m4782("date", 0L).longValue()) - LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS < 0) {
                this.f2373 = new CountDownTimerC0379(LocationPackageRequestParams.DEFAULT_LAST_LOCATION_MAX_AGE_MS - (System.currentTimeMillis() - C1841.m4782("date", 0L).longValue()), 1000);
                this.f2373.start();
                return;
            }
            C1841.m4765("date", 0L);
        }
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        CountDownTimer countDownTimer = this.f2373;
        if (countDownTimer != null) {
            countDownTimer.cancel();
            this.f2373 = null;
        }
        C0668 r0 = this.f2376;
        WeakReference<V> weakReference = r0.f3627;
        if (weakReference != null) {
            weakReference.clear();
            r0.f3627 = null;
        }
        CountDownTimer countDownTimer2 = this.f2375;
        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}*/:
            default:
                return;
            case R.id.send_code /*{ENCODED_INT: 2131296904}*/:
                if (!this.f2377) {
                    return;
                }
                if (TextUtils.isEmpty(this.code_phone.getText().toString().trim())) {
                    C1841.m4792((Context) this, "Enter your mobile number.");
                    return;
                } else if (this.code_phone.getText().toString().trim().length() < 5) {
                    C1841.m4792((Context) this, "Please enter the correct mobile phone number.");
                    return;
                } else {
                    CountDownTimerC0377 r4 = this.f2374;
                    if (r4 != null) {
                        r4.start();
                        this.f2296.m2183();
                        new Handler().postDelayed(new RunnableC0376(), 1500);
                        return;
                    }
                    return;
                }
        }
    }

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

    /* renamed from: ᓣ  reason: contains not printable characters */
    public void m1396() {
        AbstractC0700 r0 = C0701.f3707.m2131();
        String r1 = C1841.m4788(AccessToken.TOKEN_KEY, "");
        MyApplication.m1353();
        r0.m2115(r1, MyApplication.f2291, C1841.m4748()).enqueue(new C0378(this));
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public void m1397(String str) {
        new HashMap().put("login", "login");
        C1841.m4792((Context) this, str);
        C1841.m4744("isFirst", "isFirst");
        m1396();
        setResult(100);
        finish();
        this.f2296.m2185();
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1398(String str) {
        C1841.m4792((Context) this, str);
        this.f2296.m2185();
    }
}
