package com.mexico.inloancash.activity;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.TypedValue;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
import butterknife.ButterKnife;
import com.facebook.AccessToken;
import com.google.gson.Gson;
import com.indiaholacash.holacash.R;
import com.mexico.inloancash.MyApplication;
import com.mexico.inloancash.bean.India_Billing_ListBean;
import com.mingle.widget.LoadingView;
import java.util.ArrayList;
import java.util.List;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;
import ඓ.ඓ.K.ʬ.C0623;
import ඓ.ඓ.K.㿎.C0701;
import ῲ.ᨨ.ᨨ.C1729;
import ῲ.ᨨ.㳳.C1841;

public class IndiaDiscount_Activity extends BaseActivity {
    public LinearLayout mIndiaData_Layout;
    public LinearLayout mIndiaEmpty_Layout;
    public LoadingView mIndiaLoading_View;
    public RecyclerView mIndiaRecyclerView;
    public SwipeRefreshLayout mIndiaSwipeRefreshLayout;
    public ImageView mIndia_GonBack;
    public TextView title;

    /* renamed from: ඓ  reason: contains not printable characters */
    public int f2427 = 1;

    /* renamed from: ᨨ  reason: contains not printable characters */
    public List<India_Billing_ListBean.DataBean> f2428;

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

    /* renamed from: 㳳  reason: contains not printable characters */
    public C0623 f2430;

    /* renamed from: 㴹  reason: contains not printable characters */
    public int f2431 = 10;

    /* renamed from: 㿎  reason: contains not printable characters */
    public boolean f2432 = false;

    /* renamed from: com.mexico.inloancash.activity.IndiaDiscount_Activity$ʬ  reason: contains not printable characters */
    public class C0399 extends RecyclerView.AbstractC0267 {
        public C0399() {
        }

        @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0267
        public void onScrollStateChanged(RecyclerView recyclerView, int i) {
            if (i == 0 && !C1729.m4489((View) recyclerView, 1)) {
                IndiaDiscount_Activity indiaDiscount_Activity = IndiaDiscount_Activity.this;
                if (!indiaDiscount_Activity.f2432) {
                    indiaDiscount_Activity.f2427++;
                    indiaDiscount_Activity.m1422(false);
                    return;
                }
                C1841.m4792((Context) indiaDiscount_Activity, "All content has been accessed");
            }
        }
    }

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

        public void run() {
            IndiaDiscount_Activity.this.mIndiaSwipeRefreshLayout.setRefreshing(false);
        }
    }

    /* renamed from: com.mexico.inloancash.activity.IndiaDiscount_Activity$K  reason: contains not printable characters */
    public class C0401 implements SwipeRefreshLayout.AbstractC0289 {

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

            public void run() {
                IndiaDiscount_Activity.this.m1420();
            }
        }

        public C0401() {
        }

        @Override // androidx.swiperefreshlayout.widget.SwipeRefreshLayout.AbstractC0289
        /* renamed from: K  reason: contains not printable characters */
        public void m1423() {
            IndiaDiscount_Activity.this.f2429.postDelayed(new RunnableC0402(), 1000);
        }
    }

    /* renamed from: com.mexico.inloancash.activity.IndiaDiscount_Activity$㸾  reason: contains not printable characters */
    public class C0403 implements Callback<String> {

        /* renamed from: K  reason: contains not printable characters */
        public final /* synthetic */ boolean f2438;

        public C0403(boolean z) {
            this.f2438 = z;
        }

        @Override // retrofit2.Callback
        public void onFailure(Call<String> call, Throwable th) {
            IndiaDiscount_Activity.this.mIndiaSwipeRefreshLayout.setRefreshing(false);
            IndiaDiscount_Activity.this.mIndiaLoading_View.setVisibility(8);
            IndiaDiscount_Activity.this.mIndiaData_Layout.setVisibility(0);
        }

        @Override // retrofit2.Callback
        public void onResponse(Call<String> call, Response<String> response) {
            try {
                if (response.isSuccessful()) {
                    India_Billing_ListBean india_Billing_ListBean = (India_Billing_ListBean) new Gson().fromJson(response.body(), India_Billing_ListBean.class);
                    if (india_Billing_ListBean.getCode() == 200) {
                        if (this.f2438) {
                            IndiaDiscount_Activity.this.f2428.clear();
                        }
                        if (india_Billing_ListBean.getData().size() < IndiaDiscount_Activity.this.f2431) {
                            IndiaDiscount_Activity.this.f2432 = true;
                        }
                        IndiaDiscount_Activity.this.f2428.addAll(IndiaDiscount_Activity.this.m1421(india_Billing_ListBean.getData()));
                        IndiaDiscount_Activity.this.f2430.m2060(IndiaDiscount_Activity.this.f2428);
                        if (IndiaDiscount_Activity.this.f2428.size() > 0) {
                            IndiaDiscount_Activity.this.mIndiaEmpty_Layout.setVisibility(8);
                            IndiaDiscount_Activity.this.mIndiaSwipeRefreshLayout.setVisibility(0);
                        } else {
                            IndiaDiscount_Activity.this.mIndiaEmpty_Layout.setVisibility(0);
                            IndiaDiscount_Activity.this.mIndiaSwipeRefreshLayout.setVisibility(8);
                        }
                    } else if (india_Billing_ListBean.getCode() == 401) {
                        IndiaDiscount_Activity.this.startActivity(new Intent(IndiaDiscount_Activity.this, IndiaLoginActivity.class));
                    }
                }
            } catch (Exception unused) {
            }
            IndiaDiscount_Activity.this.mIndiaSwipeRefreshLayout.setRefreshing(false);
            IndiaDiscount_Activity.this.mIndiaLoading_View.setVisibility(8);
            IndiaDiscount_Activity.this.mIndiaData_Layout.setVisibility(0);
        }
    }

    @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_coupon);
        ButterKnife.m1066(this);
        this.title.setText("Coupons");
        this.f2428 = new ArrayList();
        this.f2430 = new C0623();
        this.mIndiaSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(17170443);
        this.mIndiaSwipeRefreshLayout.setColorSchemeResources(R.color.theme);
        this.mIndiaSwipeRefreshLayout.setRefreshing(false);
        this.mIndiaSwipeRefreshLayout.m972(false, 0, (int) TypedValue.applyDimension(1, 24.0f, getResources().getDisplayMetrics()));
        this.mIndiaSwipeRefreshLayout.setOnRefreshListener(new C0401());
        this.mIndiaSwipeRefreshLayout.post(new RunnableC0400());
        this.mIndiaRecyclerView.setAdapter(this.f2430);
        this.mIndiaRecyclerView.setOnScrollListener(new C0399());
        m1420();
    }

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

    public void onViewClicked() {
        finish();
    }

    /* renamed from: ؿ  reason: contains not printable characters */
    public void m1420() {
        this.f2427 = 1;
        m1422(true);
    }

    /* renamed from: K  reason: contains not printable characters */
    public final List<India_Billing_ListBean.DataBean> m1421(List<India_Billing_ListBean.DataBean> list) {
        ArrayList arrayList = new ArrayList();
        for (India_Billing_ListBean.DataBean dataBean : list) {
            if (dataBean.isCoupon()) {
                arrayList.add(dataBean);
            }
        }
        return arrayList;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1422(boolean z) {
        C0701.f3707.m2131().m2111(C1841.m4788(AccessToken.TOKEN_KEY, ""), MyApplication.f2291).enqueue(new C0403(z));
    }
}
