package com.mexico.inloancash.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.os.Handler;
import android.text.TextUtils;
import android.util.Log;
import android.view.KeyEvent;
import android.view.View;
import android.widget.FrameLayout;
import android.widget.TextView;
import androidx.fragment.app.Fragment;
import butterknife.ButterKnife;
import com.adjust.sdk.Adjust;
import com.adjust.sdk.AdjustAttribution;
import com.facebook.appevents.AppEventsLogger;
import com.google.gson.Gson;
import com.indiaholacash.holacash.R;
import com.mexico.inloancash.MyApplication;
import com.mexico.inloancash.bean.India_Address_ListBean;
import com.mexico.inloancash.fragment.IndiaFirstPageFragment;
import com.mexico.inloancash.fragment.IndiaPersonalFragment;
import com.mexico.inloancash.fragment.MainBillFragment;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.㳳.AbstractC0671;
import ඓ.ඓ.K.㿎.C0701;
import ඓ.㸾.K.C1378;
import ඓ.㸾.K.C1387;
import ῲ.Ԕ.K.AbstractC1558;
import ῲ.ᨨ.ῲ.C1806;
import ῲ.ᨨ.㳳.C1841;

public class MainActivity extends BaseActivity implements AbstractC0671 {

    /* renamed from: ᕣ  reason: contains not printable characters */
    public static boolean f2549 = false;
    public TextView first_bill;
    public TextView mIndiaFirstTvPage;
    public FrameLayout mIndiaFrameLayout;
    public TextView mIndiaIneTvPage;

    /* renamed from: ඓ  reason: contains not printable characters */
    public List<Fragment> f2550 = new ArrayList();

    /* renamed from: ᨨ  reason: contains not printable characters */
    public volatile int f2551 = 0;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public Timer f2552 = new Timer();

    /* renamed from: 㳳  reason: contains not printable characters */
    public int f2553 = 0;

    /* renamed from: 㴹  reason: contains not printable characters */
    public long f2554 = 0;

    /* renamed from: 㿎  reason: contains not printable characters */
    public TimerTask f2555;

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

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

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            try {
                response.isSuccessful();
            } catch (Exception unused) {
            }
        }
    }

    /* renamed from: com.mexico.inloancash.activity.MainActivity$ῲ  reason: contains not printable characters */
    public class C0446 extends TimerTask {

        /* renamed from: com.mexico.inloancash.activity.MainActivity$ῲ$K  reason: contains not printable characters */
        public class RunnableC0447 implements Runnable {

            /* renamed from: ῲ  reason: contains not printable characters */
            public final /* synthetic */ AdjustAttribution f2558;

            public RunnableC0447(AdjustAttribution adjustAttribution) {
                this.f2558 = adjustAttribution;
            }

            public void run() {
                String str = this.f2558.trackerName;
                SharedPreferences.Editor edit = C1841.m4812().edit();
                edit.putString("trackerName", str);
                edit.commit();
                MainActivity.this.m1488();
            }
        }

        public C0446() {
        }

        public void run() {
            MainActivity.this.f2551++;
            AdjustAttribution attribution = Adjust.getAttribution();
            if (attribution != null && !TextUtils.isEmpty(attribution.trackerName)) {
                MainActivity.this.runOnUiThread(new RunnableC0447(attribution));
            }
            if (MainActivity.this.f2551 == 3) {
                MainActivity.this.f2555.cancel();
                MainActivity.this.f2551 = 0;
            }
        }
    }

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

        public void run() {
            MainActivity.this.m1481();
        }
    }

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

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

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            try {
                if (response.isSuccessful() && ((India_Address_ListBean) new Gson().fromJson(response.body(), India_Address_ListBean.class)).getStatus() == 1) {
                    C1841.m4744("address", response.body());
                }
            } catch (Exception unused) {
            }
        }
    }

    @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_main);
        ButterKnife.m1066(this);
        AppEventsLogger.newLogger(this);
        this.f2550.add(new IndiaFirstPageFragment());
        this.f2550.add(new MainBillFragment());
        this.f2550.add(new IndiaPersonalFragment());
        StringBuilder sb = new StringBuilder();
        try {
            BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(getAssets().open("address.json")));
            while (true) {
                String readLine = bufferedReader.readLine();
                if (readLine == null) {
                    break;
                }
                sb.append(readLine);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        C1841.m4744("address", sb.toString());
        getSupportFragmentManager().m3915().m4096(R.id.frame_layout, this.f2550.get(0)).m4096(R.id.frame_layout, this.f2550.get(1)).m4087(this.f2550.get(1)).m4090(this.f2550.get(0)).m4095();
        m1485(0);
        new Handler().postDelayed(new RunnableC0448(), 2000);
        C1841.f6259 = C1841.m4812();
        if (TextUtils.isEmpty(C1841.f6259.getString("trackerName", ""))) {
            m1487();
        }
    }

    @Override // androidx.appcompat.app.AppCompatActivity, androidx.fragment.app.FragmentActivity
    public void onDestroy() {
        super.onDestroy();
        m1488();
    }

    @Override // androidx.appcompat.app.AppCompatActivity
    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        if (i == 4) {
            long currentTimeMillis = System.currentTimeMillis();
            if (currentTimeMillis - this.f2554 > 2000) {
                C1841.m4792((Context) this, "Press again to exit the program");
                this.f2554 = currentTimeMillis;
                return true;
            }
            finish();
        }
        return super.onKeyDown(i, keyEvent);
    }

    @Override // com.mexico.inloancash.activity.BaseActivity, androidx.fragment.app.FragmentActivity
    public void onResume() {
        super.onResume();
        if (!C1841.m4767()) {
            m1485(0);
        } else if (TextUtils.isEmpty(C1841.m4788("bank", "")) || TextUtils.isEmpty(C1841.m4788("address", ""))) {
            m1482();
        }
    }

    public void onViewClicked(View view) {
        int id = view.getId();
        if (id != R.id.first_bill) {
            if (id == R.id.first_page) {
                m1485(0);
            } else if (id == R.id.mine_page) {
                if (C1841.m4767()) {
                    m1485(2);
                } else {
                    startActivity(new Intent(this, IndiaLoginActivity.class));
                }
            }
        } else if (C1841.m4767()) {
            m1485(1);
        } else {
            startActivity(new Intent(this, IndiaLoginActivity.class));
        }
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0671
    /* renamed from: ʬ  reason: contains not printable characters */
    public void m1479() {
    }

    /* renamed from: ؿ  reason: contains not printable characters */
    public void m1480() {
        C0701.f3707.m2131().m2110(MyApplication.f2291).enqueue(new C0445(this));
    }

    /* renamed from: ݜ  reason: contains not printable characters */
    public final void m1481() {
        int r1 = C1841.m4771("express.FIRST_OPEN", 0);
        Log.d("loan", "firstOpen:" + r1);
        if (r1 == 0) {
            C1841.m4764("express.FIRST_OPEN", 1);
            m1480();
        }
    }

    /* renamed from: ᓣ  reason: contains not printable characters */
    public void m1482() {
        C0701.f3707.m2131().m2124().enqueue(new C0449(this));
    }

    /* renamed from: ῲ  reason: contains not printable characters */
    public C1387 m1483(boolean z) {
        C1387 r0 = C1387.m3583(this);
        C1378 r1 = r0.f5330;
        r1.f5253 = true;
        if (!r1.f5253) {
            r0.f5310 = 0;
        } else if (r0.f5310 == 0) {
            r0.f5310 = 4;
        }
        r0.f5330.f5258 = C1806.m4686(r0.f5317, z ? R.color.color_f7f7f7 : R.color.theme);
        r0.m3588(z, 0.2f);
        r0.m3591(z, 0.2f);
        return r0;
    }

    /* renamed from: 㗽  reason: contains not printable characters */
    public void m1487() {
        TimerTask timerTask = this.f2555;
        if (timerTask != null) {
            timerTask.cancel();
        }
        this.f2555 = new C0446();
        this.f2552.schedule(this.f2555, 2000, 3000);
    }

    /* renamed from: 䀟  reason: contains not printable characters */
    public void m1488() {
        Timer timer = this.f2552;
        if (timer != null) {
            timer.cancel();
            this.f2551 = 0;
        }
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1485(int i) {
        m1486(i == 2);
        if (this.f2553 != i) {
            AbstractC1558 r2 = getSupportFragmentManager().m3915();
            r2.m4087(this.f2550.get(this.f2553));
            if (!this.f2550.get(i).isAdded()) {
                r2.m4096(R.id.frame_layout, this.f2550.get(i));
            }
            r2.m4090(this.f2550.get(i)).m4095();
        }
        if (i == 0) {
            this.mIndiaFirstTvPage.setSelected(true);
            this.mIndiaIneTvPage.setSelected(false);
            this.first_bill.setSelected(false);
        } else if (i == 1) {
            this.mIndiaFirstTvPage.setSelected(false);
            this.mIndiaIneTvPage.setSelected(false);
            this.first_bill.setSelected(true);
        } else {
            this.mIndiaFirstTvPage.setSelected(false);
            this.mIndiaIneTvPage.setSelected(true);
            this.first_bill.setSelected(false);
        }
        this.f2553 = i;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1486(boolean z) {
        C1387 r1 = m1483(z);
        if (r1 != null) {
            r1.m3586();
        }
    }

    @Override // ඓ.ඓ.K.㳳.AbstractC0671
    /* renamed from: K  reason: contains not printable characters */
    public void m1484() {
        startActivity(new Intent(this, IndiaLoginActivity.class));
    }
}
