package com.ss.android.ugc.aweme.ecommerce.pdp.widget;

import X.0CB;
import X.0CH;
import X.4ZZ;
import X.6Is;
import X.7he;
import X.C2976B2m;
import X.C2G;
import X.C6091COh;
import X.C6251CUl;
import X.C6252CUm;
import X.C6253CUn;
import X.C6254CUo;
import X.C6255CUp;
import X.C6257CUr;
import X.C6258CUs;
import X.C6259CUt;
import X.CAH;
import X.CG9;
import X.CP1;
import X.CP2;
import X.Crj;
import X.D1G;
import X.DV0;
import X.HeD;
import X.KEM;
import X.M12;
import android.content.Context;
import android.view.View;
import android.view.animation.TranslateAnimation;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.bytedance.keva.Keva;
import com.ss.android.ugc.aweme.base.arch.JediBaseWidget;
import com.ss.android.ugc.aweme.ecommerce.pdp.PdpViewModel;
import com.ss.android.ugc.aweme.framework.services.IUserService;
import com.ss.android.ugc.aweme.services.BaseUserService;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Locale;
import java.util.Map;
import java.util.Timer;
import kotlin.h.b.n;

public final class PdpAddonFloatWidget extends JediBaseWidget implements 6Is {
    public C6251CUl LJII;
    public Boolean LJIIIIZZ = false;
    public Boolean LJIIIZ = true;
    public int LJIIJ;
    public int LJIIJJI;
    public boolean LJIIL;
    public boolean LJIILIIL;
    public Boolean LJIILJJIL = true;
    public float LJIILL;
    public final Crj LJIILLIIL;
    public final float LJIIZILJ = 325.0f;
    public int LJIJ;
    public Timer LJIJI;
    public String LJIJJ;
    public String LJIJJLI;
    public String LJIL;
    public final Fragment LJJ;

    static {
        Covode.recordClassIndex(71840);
    }

    public final int LIZJ() {
        return 2131558993;
    }

    public final PdpViewModel LJIIJJI() {
        return (PdpViewModel) this.LJIILLIIL.getValue();
    }

    public final void onStateChanged(0CH r1, 0CB r2) {
        super.onStateChanged(r1, r2);
    }

    public final void LJIIIIZZ() {
        PdpAddonFloatWidget.super.LJIIIIZZ();
        Timer timer = this.LJIJI;
        if (timer != null) {
            timer.cancel();
        }
        if (n.LIZ(this.LJIIIIZZ, false)) {
            LIZ(0, 1);
        }
    }

    private int LJIILIIL() {
        String format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(new Date());
        Keva keva = CAH.LIZ;
        String str = this.LJIJJLI;
        if (str == null) {
            n.LIZ("");
        }
        if (!keva.getString(str, "").equals(format)) {
            Keva keva2 = CAH.LIZ;
            n.LIZIZ(keva2, "");
            String str2 = this.LJIJJ;
            if (str2 == null) {
                n.LIZ("");
            }
            C2G.LIZ(keva2, str2, 0);
            Keva keva3 = CAH.LIZ;
            n.LIZIZ(keva3, "");
            String str3 = this.LJIL;
            if (str3 == null) {
                n.LIZ("");
            }
            C2G.LIZ(keva3, str3, 0);
            Keva keva4 = CAH.LIZ;
            n.LIZIZ(keva4, "");
            String str4 = this.LJIJJLI;
            if (str4 == null) {
                n.LIZ("");
            }
            n.LIZIZ(format, "");
            C2G.LIZ(keva4, str4, format);
        }
        Keva keva5 = CAH.LIZ;
        String str5 = this.LJIJJ;
        if (str5 == null) {
            n.LIZ("");
        }
        return keva5.getInt(str5, 0);
    }

    private int LJIILJJIL() {
        String format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(new Date());
        Keva keva = CAH.LIZ;
        String str = this.LJIJJLI;
        if (str == null) {
            n.LIZ("");
        }
        if (!keva.getString(str, "").equals(format)) {
            Keva keva2 = CAH.LIZ;
            n.LIZIZ(keva2, "");
            String str2 = this.LJIJJ;
            if (str2 == null) {
                n.LIZ("");
            }
            C2G.LIZ(keva2, str2, 0);
            Keva keva3 = CAH.LIZ;
            n.LIZIZ(keva3, "");
            String str3 = this.LJIL;
            if (str3 == null) {
                n.LIZ("");
            }
            C2G.LIZ(keva3, str3, 0);
            Keva keva4 = CAH.LIZ;
            n.LIZIZ(keva4, "");
            String str4 = this.LJIJJLI;
            if (str4 == null) {
                n.LIZ("");
            }
            n.LIZIZ(format, "");
            C2G.LIZ(keva4, str4, format);
        }
        Keva keva5 = CAH.LIZ;
        String str5 = this.LJIL;
        if (str5 == null) {
            n.LIZ("");
        }
        return keva5.getInt(str5, 0);
    }

    public final void LJIIL() {
        Map<String, String> map;
        int LJIILIIL2 = LJIILIIL();
        if (LJIILIIL2 >= C6091COh.LIZ().LIZIZ) {
            CG9 cg9 = LJIIJJI().LJJ;
            if (cg9 != null) {
                cg9.LIZIZ("cancel", LJIILIIL2);
                return;
            }
            return;
        }
        int LJIILJJIL2 = LJIILJJIL();
        if (LJIILJJIL2 >= C6091COh.LIZ().LIZIZ) {
            CG9 cg92 = LJIIJJI().LJJ;
            if (cg92 != null) {
                cg92.LIZIZ("non_click", LJIILJJIL2);
                return;
            }
            return;
        }
        View view = this.LJ;
        if (view != null) {
            view.setVisibility(0);
        }
        TranslateAnimation translateAnimation = new TranslateAnimation(-1000.0f, 0.0f, 0.0f, 0.0f);
        translateAnimation.setDuration(500);
        View view2 = this.LJ;
        if (view2 != null) {
            view2.setAnimation(translateAnimation);
        }
        View view3 = this.LJ;
        if (view3 != null) {
            view3.startAnimation(translateAnimation);
        }
        CG9 cg93 = LJIIJJI().LJJ;
        if (cg93 != null) {
            C6251CUl cUl = this.LJII;
            if (cUl != null) {
                map = cUl.LJI;
            } else {
                map = null;
            }
            cg93.LIZJ((Map<String, ? extends Object>) map);
        }
        this.LJIIIIZZ = false;
        this.LJIIIZ = false;
    }

    /* JADX WARNING: type inference failed for: r0v17, types: [android.view.View$OnClickListener, X.CUo] */
    /* JADX WARNING: type inference failed for: r0v18, types: [android.view.View$OnClickListener, X.CUn] */
    public final void LIZLLL() {
        4ZZ findViewById;
        Context context;
        PdpAddonFloatWidget.super.LIZLLL();
        View view = this.LJ;
        if (view != null) {
            view.setVisibility(4);
        }
        IUserService createIUserServicebyMonsterPlugin = BaseUserService.createIUserServicebyMonsterPlugin(false);
        StringBuilder sb = new StringBuilder("addon_recom_close_count");
        n.LIZIZ(createIUserServicebyMonsterPlugin, "");
        sb.append(createIUserServicebyMonsterPlugin.getCurrentUserID());
        this.LJIJJ = sb.toString();
        this.LJIL = "addon_recom_no_click_count" + createIUserServicebyMonsterPlugin.getCurrentUserID();
        this.LJIJJLI = "addon_recom_count_date" + createIUserServicebyMonsterPlugin.getCurrentUserID();
        View view2 = this.LJ;
        if (!(view2 == null || (context = view2.getContext()) == null)) {
            int LIZ = HeD.LIZ(context);
            this.LJIJ = LIZ;
            this.LJIILL = this.LJIIZILJ - ((float) LIZ);
        }
        Timer timer = new Timer();
        this.LJIJI = timer;
        timer.schedule(new C6258CUs(this), 500, 500);
        DV0.LIZ(this, LJIIJJI(), CP1.LIZ, new C6255CUp(this));
        DV0.LIZ(this, LJIIJJI(), CP2.LIZ, new C6257CUr(this));
        DV0.LIZ(this, LJIIJJI(), C6259CUt.LIZ, new C6252CUm(this));
        View view3 = this.LJ;
        if (view3 != null) {
            view3.setOnClickListener(new C6253CUn(this));
        }
        View view4 = this.LJ;
        if (view4 != null && (findViewById = view4.findViewById(2131363398)) != null) {
            findViewById.setOnClickListener(new C6254CUo(this));
        }
    }

    public PdpAddonFloatWidget(Fragment fragment) {
        M12.LIZ(fragment);
        this.LJJ = fragment;
        D1G LIZ = KEM.LIZ.LIZ(PdpViewModel.class);
        this.LJIILLIIL = 7he.LIZ(new C2976B2m(this, LIZ, LIZ));
    }

    public final void LIZ(int i, int i2) {
        String format = new SimpleDateFormat("yyyyMMdd", Locale.getDefault()).format(new Date());
        Keva keva = CAH.LIZ;
        String str = this.LJIJJLI;
        if (str == null) {
            n.LIZ("");
        }
        if (keva.getString(str, "").equals(format)) {
            Keva keva2 = CAH.LIZ;
            n.LIZIZ(keva2, "");
            String str2 = this.LJIJJ;
            if (str2 == null) {
                n.LIZ("");
            }
            Keva keva3 = CAH.LIZ;
            String str3 = this.LJIJJ;
            if (str3 == null) {
                n.LIZ("");
            }
            C2G.LIZ(keva2, str2, keva3.getInt(str3, 0) + i);
            Keva keva4 = CAH.LIZ;
            n.LIZIZ(keva4, "");
            String str4 = this.LJIL;
            if (str4 == null) {
                n.LIZ("");
            }
            Keva keva5 = CAH.LIZ;
            String str5 = this.LJIL;
            if (str5 == null) {
                n.LIZ("");
            }
            C2G.LIZ(keva4, str4, keva5.getInt(str5, 0) + i2);
            return;
        }
        Keva keva6 = CAH.LIZ;
        n.LIZIZ(keva6, "");
        String str6 = this.LJIJJ;
        if (str6 == null) {
            n.LIZ("");
        }
        C2G.LIZ(keva6, str6, i);
        Keva keva7 = CAH.LIZ;
        n.LIZIZ(keva7, "");
        String str7 = this.LJIL;
        if (str7 == null) {
            n.LIZ("");
        }
        C2G.LIZ(keva7, str7, i2);
        Keva keva8 = CAH.LIZ;
        n.LIZIZ(keva8, "");
        String str8 = this.LJIJJLI;
        if (str8 == null) {
            n.LIZ("");
        }
        n.LIZIZ(format, "");
        C2G.LIZ(keva8, str8, format);
    }
}
