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 ඓ.ඓ.K.ʬ.C0627;
import ඓ.ඓ.K.㿎.C0701;
import ῲ.ᨨ.ᨨ.C1729;
import ῲ.ᨨ.㳳.C1841;

public class IndiaBillActivity extends BaseActivity {
    public LinearLayout mDataLayout;
    public LinearLayout mIndiaEmpty_Layout;
    public ImageView mIndiaGonBack;
    public LoadingView mLoadingView;
    public RecyclerView mRecyclerView;
    public SwipeRefreshLayout mSwipeRefreshLayout;
    public TextView mTitle;

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

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

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

    /* renamed from: 㳳  reason: contains not printable characters */
    public C0627 f2355;

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

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

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

        @Override // androidx.recyclerview.widget.RecyclerView.AbstractC0267
        public void onScrollStateChanged(RecyclerView recyclerView, int i) {
            if (i == 0 && !C1729.m4489((View) recyclerView, 1)) {
                IndiaBillActivity indiaBillActivity = IndiaBillActivity.this;
                if (!indiaBillActivity.f2357) {
                    indiaBillActivity.f2352++;
                    indiaBillActivity.m1384(false);
                    return;
                }
                C1841.m4792((Context) indiaBillActivity, "All data has been collected");
            }
        }
    }

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

        public void run() {
            IndiaBillActivity.this.mSwipeRefreshLayout.setRefreshing(false);
        }
    }

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

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

            public void run() {
                IndiaBillActivity.this.m1383();
            }
        }

        public C0371() {
        }

        @Override // androidx.swiperefreshlayout.widget.SwipeRefreshLayout.AbstractC0289
        /* renamed from: K  reason: contains not printable characters */
        public void m1385() {
            IndiaBillActivity.this.f2354.postDelayed(new RunnableC0372(), 1000);
        }
    }

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

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

        public C0373(boolean z) {
            this.f2363 = z;
        }

        @Override // retrofit2.Callback
        public void onFailure(Call<String> call, Throwable th) {
            IndiaBillActivity.this.mSwipeRefreshLayout.setRefreshing(false);
            IndiaBillActivity.this.mLoadingView.setVisibility(8);
            IndiaBillActivity.this.mDataLayout.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.f2363) {
                            IndiaBillActivity.this.f2353.clear();
                        }
                        if (india_Billing_ListBean.getData().size() < IndiaBillActivity.this.f2356) {
                            IndiaBillActivity.this.f2357 = true;
                        }
                        IndiaBillActivity.this.f2353.addAll(india_Billing_ListBean.getData());
                        IndiaBillActivity.this.f2355.m2060(IndiaBillActivity.this.f2353);
                        if (IndiaBillActivity.this.f2353.size() > 0) {
                            IndiaBillActivity.this.mIndiaEmpty_Layout.setVisibility(8);
                            IndiaBillActivity.this.mSwipeRefreshLayout.setVisibility(0);
                        } else {
                            IndiaBillActivity.this.mIndiaEmpty_Layout.setVisibility(0);
                            IndiaBillActivity.this.mSwipeRefreshLayout.setVisibility(8);
                        }
                    } else if (india_Billing_ListBean.getCode() == 401) {
                        IndiaBillActivity.this.startActivity(new Intent(IndiaBillActivity.this, IndiaLoginActivity.class));
                    }
                }
            } catch (Exception unused) {
            }
            IndiaBillActivity.this.mSwipeRefreshLayout.setRefreshing(false);
            IndiaBillActivity.this.mLoadingView.setVisibility(8);
            IndiaBillActivity.this.mDataLayout.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_my_view_bill_layout);
        ButterKnife.m1066(this);
        this.mTitle.setText(R.string.bill);
        this.f2353 = new ArrayList();
        this.f2355 = new C0627();
        this.mSwipeRefreshLayout.setProgressBackgroundColorSchemeResource(17170443);
        this.mSwipeRefreshLayout.setColorSchemeResources(R.color.theme);
        this.mSwipeRefreshLayout.setRefreshing(false);
        this.mSwipeRefreshLayout.m972(false, 0, (int) TypedValue.applyDimension(1, 24.0f, getResources().getDisplayMetrics()));
        this.mSwipeRefreshLayout.setOnRefreshListener(new C0371());
        this.mSwipeRefreshLayout.post(new RunnableC0370());
        this.mRecyclerView.setAdapter(this.f2355);
        this.mRecyclerView.setOnScrollListener(new C0369());
        m1383();
    }

    @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 m1383() {
        this.f2352 = 1;
        m1384(true);
    }

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