package com.mexico.inloancash.fragment;

import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.AsyncTask;
import android.os.Build;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import butterknife.ButterKnife;
import butterknife.Unbinder;
import com.facebook.AccessToken;
import com.google.gson.Gson;
import com.indiaholacash.holacash.R;
import com.mexico.inloancash.MyApplication;
import com.mexico.inloancash.activity.IndiaCerActivity;
import com.mexico.inloancash.activity.IndiaLoginActivity;
import com.mexico.inloancash.bean.BaseBean;
import com.zhihu.matisse.MimeType;
import java.io.File;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.Iterator;
import java.util.List;
import org.json.JSONObject;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.ⁱ.C0647;
import ඓ.ඓ.K.ⁱ.C0648;
import ඓ.ඓ.K.ⁱ.C0655;
import ඓ.ඓ.K.ⁱ.C0657;
import ඓ.ඓ.K.ⁱ.C0663;
import ඓ.ඓ.K.㳳.AbstractC0671;
import ඓ.ඓ.K.㳳.AbstractC0672;
import ඓ.ඓ.K.㴹.DialogC0684;
import ඓ.ඓ.K.㿎.C0701;
import ඓ.ඓ.K.䁗.C0727;
import ඓ.ඓ.K.䁗.ᓆ.C0715;
import ඓ.ඓ.K.䁗.ᓆ.C0717;
import ඓ.ᨨ.K.C0804;
import ඓ.ᨨ.K.C0805;
import ඓ.ᨨ.K.ʬ.K.C0765;
import ඓ.ᨨ.K.ඓ.K.C0778;
import ඓ.ᨨ.K.ඓ.K.C0782;
import ඓ.ⁱ.K.ʬ.C1248;
import ඓ.ⁱ.K.ῲ.C1253;
import ඓ.ⁱ.K.㸾.AbstractC1268;
import ඓ.ⁱ.K.㸾.C1272;
import ඓ.ⁱ.K.㸾.C1288;
import ඓ.K.K.K.C1293;
import ᕣ.K.K.AbstractC1459;
import ᕣ.K.K.AbstractC1461;
import ᕣ.K.K.C1460;
import ᕣ.K.K.C1468;
import ᕣ.K.K.RunnableC1467;
import ῲ.ᨨ.㳳.C1841;

public class IndiaFourthStepAuthFragment extends C0648 implements AbstractC0672, AbstractC0671 {
    public TextView mHaveWorkText;
    public EditText mIndia_CompanyName;
    public EditText mIndia_Company_Address;
    public LinearLayout mIndia_Company_Linear;
    public EditText mIndia_Company_Phone;
    public EditText mIndia_Company_Region;
    public LinearLayout mIndia_HaveWorkLinear;
    public TextView mIndia_JobType;
    public TextView mIndia_Payday;
    public ImageView mIndia_Prove;
    public EditText mIndia_Salary;
    public Button mIndia_Submit;
    public EditText mIndia_TvInCome;
    public LinearLayout mIndia_WageLinear;
    public EditText mIndia_WorkCity;
    public TextView mIndia_WorkLength;
    public LinearLayout mIndia_WorkLength_Linear;

    /* renamed from: ʬ  reason: contains not printable characters */
    public Unbinder f2641;

    /* renamed from: Ԕ  reason: contains not printable characters */
    public String f2642 = "north-us";

    /* renamed from: Ԛ  reason: contains not printable characters */
    public List<String> f2643;

    /* renamed from: ؿ  reason: contains not printable characters */
    public Uri f2644;

    /* renamed from: ݜ  reason: contains not printable characters */
    public List<String> f2645;

    /* renamed from: ඓ  reason: contains not printable characters */
    public IndiaCerActivity f2646;

    /* renamed from: ᓣ  reason: contains not printable characters */
    public File f2647 = null;

    /* renamed from: ᕣ  reason: contains not printable characters */
    public String f2648;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public AbstractC1268 f2649;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public String f2650 = "";

    /* renamed from: 㑃  reason: contains not printable characters */
    public String f2651 = "lb5ntuPzvl6BoSqL5yato8Pqwg5WXoPHGVzTktIt";

    /* renamed from: 㗗  reason: contains not printable characters */
    public File f2652;

    /* renamed from: 㗽  reason: contains not printable characters */
    public File f2653 = null;

    /* renamed from: 㳳  reason: contains not printable characters */
    public C1272 f2654;

    /* renamed from: 㴹  reason: contains not printable characters */
    public DialogC0684 f2655;

    /* renamed from: 㸾  reason: contains not printable characters */
    public View f2656;

    /* renamed from: 㿎  reason: contains not printable characters */
    public C1288 f2657;

    /* renamed from: 䀟  reason: contains not printable characters */
    public List<String> f2658;

    /* renamed from: 䁗  reason: contains not printable characters */
    public String f2659 = "7i3g_SDTFCvJ-TYs3FBfCJJtki8Rp2hYfNVIK908";

    /* renamed from: com.mexico.inloancash.fragment.IndiaFourthStepAuthFragment$ʬ  reason: contains not printable characters */
    public class C0479 implements AbstractC1461 {
        public C0479() {
        }
    }

    /* renamed from: com.mexico.inloancash.fragment.IndiaFourthStepAuthFragment$ῲ  reason: contains not printable characters */
    public class C0480 implements Callback<String> {
        public C0480() {
        }

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

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            if (response.isSuccessful()) {
                BaseBean baseBean = (BaseBean) new Gson().fromJson(response.body(), BaseBean.class);
                if (baseBean.getCode() == 200) {
                    IndiaFourthStepAuthFragment.this.f2646.finish();
                    C1841.m4792((Context) IndiaFourthStepAuthFragment.this.f2646, "Information saved successfully");
                } else if (baseBean.getCode() == 401) {
                    IndiaFourthStepAuthFragment.this.startActivity(new Intent(IndiaFourthStepAuthFragment.this.getContext(), IndiaLoginActivity.class));
                }
            }
            IndiaFourthStepAuthFragment.this.f3640.m2185();
        }
    }

    /* renamed from: com.mexico.inloancash.fragment.IndiaFourthStepAuthFragment$K  reason: contains not printable characters */
    public class C0481 implements TextWatcher {
        public C0481() {
        }

        public void afterTextChanged(Editable editable) {
        }

        public void beforeTextChanged(CharSequence charSequence, int i, int i2, int i3) {
        }

        public void onTextChanged(CharSequence charSequence, int i, int i2, int i3) {
            IndiaFourthStepAuthFragment.this.m1537();
        }
    }

    public IndiaFourthStepAuthFragment(IndiaCerActivity indiaCerActivity) {
        this.f2646 = indiaCerActivity;
    }

    @Override // androidx.fragment.app.Fragment
    public void onActivityResult(int i, int i2, Intent intent) {
        super.onActivityResult(i, i2, intent);
        if (i != 1) {
            if (i == 2) {
                if (Build.VERSION.SDK_INT < 24) {
                    File file = this.f2652;
                    if (file != null) {
                        this.f2647 = file;
                    } else {
                        return;
                    }
                } else {
                    this.f2647 = new File(C1841.m4786(this.f2644, getActivity()));
                    if (this.f2647 == null) {
                        return;
                    }
                }
                this.f3640.m2183();
            } else if (i == 1002 && i2 == -1) {
                Log.d("loan", "onActivityResult:1002");
                ArrayList parcelableArrayListExtra = intent.getParcelableArrayListExtra("extra_result_selection");
                if (parcelableArrayListExtra != null && !parcelableArrayListExtra.isEmpty()) {
                    m1541((Uri) parcelableArrayListExtra.get(0));
                    this.f3640.m2183();
                }
            }
        } else if (intent != null) {
            this.f2644 = intent.getData();
            this.f2647 = new File(C1841.m4786(this.f2644, getActivity()));
            this.f3640.m2183();
        }
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        this.f2656 = layoutInflater.inflate(R.layout.india_activity_four_view_auths_layout_fragment, viewGroup, false);
        this.f2646.m1391("Work information");
        this.f2641 = ButterKnife.m1067(this, this.f2656);
        C1272.C1273 k = new C1272.C1273();
        k.f4985 = 524288;
        k.f4980 = 1048576;
        k.f4984 = 10;
        k.f4979 = true;
        k.f4982 = 60;
        k.f4981 = this.f2649;
        k.f4983 = C1253.f4936;
        this.f2654 = k.m3378();
        this.f2648 = C0727.m2149(this.f2651, this.f2659).m2150(this.f2642);
        this.mHaveWorkText.addTextChangedListener(new C0481());
        return this.f2656;
    }

    @Override // androidx.fragment.app.Fragment
    public void onDestroy() {
        super.onDestroy();
        this.f2641.m1069();
    }

    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.company_linear /*{ENCODED_INT: 2131296459}*/:
                this.f2658 = new ArrayList();
                this.f2658.add("Accountant / Finance Officer");
                this.f2658.add("Customer service");
                this.f2658.add("Engineer");
                this.f2658.add("Executive");
                this.f2658.add("General Administration");
                this.f2658.add("Technologies");
                this.f2658.add("Consultant/Analyst");
                this.f2658.add("Store");
                this.f2658.add("Teacher");
                this.f2658.add("Military");
                this.f2658.add("Retired");
                this.f2658.add("Student");
                this.f2658.add("Businessman");
                this.f2658.add("Policeman");
                this.f2658.add("Farmer");
                this.f2658.add("Fisherman");
                this.f2658.add("Creator");
                this.f2658.add("Doctor");
                this.f2658.add("Medical staff (nurses, midwives, etc.)");
                this.f2658.add("Law (lawyer, notary)");
                this.f2658.add("Hospitality and restaurant (chef, waiter, etc.)");
                this.f2658.add("Investigator");
                this.f2658.add("Designer");
                this.f2658.add("Architect");
                this.f2658.add("Art workers (artists, musicians, painters, etc.)");
                this.f2658.add("Security");
                this.f2658.add("Runners");
                this.f2658.add("Distributor");
                this.f2658.add("Air transport (pilot, stewardess)");
                this.f2658.add("Maritime transport (Captain, ABK)");
                this.f2658.add("Ground transportation (driver, driver)");
                this.f2658.add("Workers (factory workers, constitution workers, agricultural workers)");
                this.f2658.add("Supir & Carpentry and craftsmen (carpenters, leather craftsmen, etc.)");
                this.f2658.add("Housewife");
                this.f2658.add("Informal workers (domestic helpers, assistants, etc.)");
                this.f2658.add("National Office / National Organization");
                this.f2658.add("Government officials / state institutions (other than state officials / organizations)");
                this.f2658.add("Others");
                this.f2655 = new DialogC0684(getContext(), this, "Kind of job", this.f2658, "job");
                this.f2655.show();
                return;
            case R.id.have_work_linear /*{ENCODED_INT: 2131296589}*/:
                this.f2643 = new ArrayList();
                this.f2643.add("FULL");
                this.f2643.add("NO_WORK");
                this.f2643.add("PART");
                this.f2643.add("SELF");
                this.f2655 = new DialogC0684(getContext(), this, "Work Ndustry", this.f2643, "work");
                this.f2655.show();
                return;
            case R.id.prove /*{ENCODED_INT: 2131296824}*/:
                Log.d("loan", "chooseWorkCard");
                new C0715(getActivity()).m2142("android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6544(new C0655(this));
                return;
            case R.id.submit /*{ENCODED_INT: 2131296953}*/:
                m1546();
                return;
            case R.id.wage_linear /*{ENCODED_INT: 2131297067}*/:
                ArrayList arrayList = new ArrayList();
                for (int i = 1; i < 31; i++) {
                    arrayList.add(i + "");
                }
                this.f2655 = new DialogC0684(getContext(), this, "Día de paga", arrayList, "date");
                this.f2655.show();
                return;
            case R.id.work_length_linear /*{ENCODED_INT: 2131297079}*/:
                this.f2645 = new ArrayList();
                this.f2645.add("Within 1 year");
                this.f2645.add("1 ～ 3 years");
                this.f2645.add("3 ～ 10 years");
                this.f2645.add("More than 10 years");
                this.f2645.add("unknown");
                this.f2655 = new DialogC0684(getContext(), this, "Years of work", this.f2645, "length");
                this.f2655.show();
                return;
            default:
                return;
        }
    }

    /* renamed from: ʬ  reason: contains not printable characters */
    public /* synthetic */ void m1536(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            m1538();
        } else {
            C1841.m4792(getContext(), "Please open the memory card read-write, camera permission");
        }
    }

    /* renamed from: ᕣ  reason: contains not printable characters */
    public void m1537() {
    }

    /* renamed from: ᨨ  reason: contains not printable characters */
    public void m1538() {
        File file = new File(Environment.getExternalStorageDirectory(), "myimage");
        if (!file.exists()) {
            file.mkdirs();
        }
        String format = new SimpleDateFormat("yyyyMMddHHmmss").format(new Date());
        this.f2652 = new File(file, C1293.m3412(format, ".jpg"));
        if (!this.f2652.exists()) {
            try {
                this.f2652.createNewFile();
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
        Intent intent = new Intent("android.media.action.IMAGE_CAPTURE");
        if (Build.VERSION.SDK_INT < 24) {
            this.f2652 = new File(file, C1293.m3412(format, ".jpg"));
            this.f2644 = Uri.fromFile(this.f2652);
            intent.putExtra("output", this.f2644);
        } else {
            this.f2644 = getActivity().getContentResolver().insert(MediaStore.Images.Media.EXTERNAL_CONTENT_URI, new ContentValues());
            intent.putExtra("output", this.f2644);
        }
        startActivityForResult(intent, 2);
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public /* synthetic */ void m1539(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            C0804 r1 = new C0804(new C0805(this), EnumSet.of(MimeType.JPEG, MimeType.PNG), true);
            r1.f4006.f3944 = true;
            r1.m2392(1);
            C0778 r0 = r1.f4006;
            r0.f3946 = 10;
            r0.f3961 = false;
            r0.f3952 = true;
            r0.f3949 = 1;
            r1.f4006.f3957 = new C0782(true, "PhotoPickerIndia");
            r1.m2393(0.85f);
            C0778 r02 = r1.f4006;
            r02.f3950 = false;
            r02.f3949 = 1;
            C0765 k = new C0765();
            C0778 r03 = r1.f4006;
            r03.f3947 = k;
            r03.f3963 = R.style.MyMatisse;
            r1.m2394(1002);
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1544(String str, C1248 r2, JSONObject jSONObject) {
        if (r2.m3322()) {
            this.f2650 = str;
            if (!TextUtils.isEmpty(this.f2650)) {
                m1545();
                return;
            }
            return;
        }
        this.f3640.m2185();
        C1841.m4792((Context) this.f2646, "Image upload failed, please check internet connection");
    }

    /* renamed from: 㳳  reason: contains not printable characters */
    public void m1545() {
        C0701.f3707.m2131().m2121(C1841.m4788(AccessToken.TOKEN_KEY, ""), MyApplication.f2291, this.mIndia_CompanyName.getText().toString().trim(), this.mIndia_Company_Phone.getText().toString().trim(), String.valueOf(this.f2658.indexOf(this.mIndia_JobType.getText().toString().trim())), this.mIndia_TvInCome.getText().toString().trim(), this.mIndia_WorkCity.getText().toString().trim(), this.mIndia_Company_Address.getText().toString().trim()).enqueue(new C0480());
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public void m1546() {
        if (C1293.m3418(this.mIndia_CompanyName)) {
            C1841.m4792(getContext(), "Company name cannot be empty");
        } else if (C1293.m3418(this.mIndia_Company_Phone)) {
            C1841.m4792(getContext(), "Company phone number cannot be empty");
        } else if (C1293.m3418(this.mIndia_TvInCome)) {
            C1841.m4792(getContext(), "Monthly income cannot be empty");
        } else if (C1293.m3418(this.mIndia_WorkCity)) {
            C1841.m4792(getContext(), "Work city cannot be empty");
        } else if (C1293.m3418(this.mIndia_Company_Address)) {
            C1841.m4792(getContext(), "Address cannot be empty");
        } else if (TextUtils.isEmpty(this.mIndia_JobType.getText().toString().trim())) {
            C1841.m4792(getContext(), "Please select the type of work");
        } else {
            this.f3640.m2183();
            String str = this.f2648;
            SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
            StringBuilder r1 = C1293.m3416("icon_3");
            r1.append(simpleDateFormat.format(new Date()));
            String sb = r1.toString();
            this.f2657 = new C1288(this.f2654);
            File file = this.f2653;
            if (file == null) {
                m1545();
            } else {
                this.f2657.m3396(file, sb, str, new C0657(this), null);
            }
        }
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0671
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m1535() {
        new C0715(this.f2646).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6542(new C0717()).m6544(new C0663(this));
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0672
    /* renamed from: K  reason: contains not printable characters */
    public void m1543(String str, String str2) {
        if (str.equals("job")) {
            this.mIndia_JobType.setText(str2);
        } else if (str.equals("length")) {
            this.mIndia_WorkLength.setText(str2);
        } else if (str.equals("date")) {
            this.mIndia_Payday.setText(str2);
        } else if (str.equals("inCome")) {
            this.mIndia_TvInCome.setText(str2);
        }
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0671
    /* renamed from: K  reason: contains not printable characters */
    public void m1540() {
        new C0715(this.f2646).m2142("android.permission.WRITE_EXTERNAL_STORAGE", "android.permission.READ_EXTERNAL_STORAGE", "android.permission.CAMERA").m6542(new C0717()).m6544(new C0647(this));
    }

    /* renamed from: K  reason: contains not printable characters */
    public /* synthetic */ void m1542(Boolean bool) throws Exception {
        if (bool.booleanValue()) {
            startActivityForResult(new Intent("android.intent.action.PICK", MediaStore.Images.Media.EXTERNAL_CONTENT_URI), 1);
        } else {
            C1841.m4792(getContext(), "Please open the memory card read-write, camera permission");
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1541(Uri uri) {
        String r6 = C1841.m4785(getContext(), uri);
        C1468.C1469 r0 = C1468.m3677(getContext());
        r0.f5481.add(new C1460(r0, new File(r6)));
        r0.f5478 = 20;
        r0.f5479 = new C0479();
        C1468 r62 = new C1468(r0, null);
        Context context = r0.f5482;
        List<AbstractC1459> list = r62.f5473;
        if (list == null || (list.size() == 0 && r62.f5477 != null)) {
            AbstractC1461 r1 = r62.f5477;
            new NullPointerException("image file cannot be null");
            IndiaFourthStepAuthFragment.this.f3640.m2185();
        }
        Iterator<AbstractC1459> it2 = r62.f5473.iterator();
        while (it2.hasNext()) {
            AsyncTask.SERIAL_EXECUTOR.execute(new RunnableC1467(r62, context, it2.next()));
            it2.remove();
        }
    }
}
