package com.ss.android.ugc.aweme.tools.draft.adapter.viewholder;

import X.03G;
import X.070;
import X.0CB;
import X.0CG;
import X.0CH;
import X.2xd;
import X.2yn;
import X.3ZQ;
import X.3ae;
import X.AnonymousClass6ZR;
import X.AnonymousClass74J;
import X.AnonymousClass770;
import X.AnonymousClass771;
import X.AnonymousClass772;
import X.AnonymousClass773;
import X.AnonymousClass775;
import X.BJv;
import X.C38646es;
import X.C38666eu;
import X.C42016kJ;
import X.C42616lH;
import X.C527473w;
import X.C533876i;
import X.C535076u;
import X.C535476y;
import X.CbN;
import X.FWb;
import X.FaH;
import X.FdE;
import X.HeD;
import X.M12;
import X.OCO;
import X.QJv;
import X.QNA;
import X.Qen;
import X.TSt;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CompoundButton;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Space;
import android.widget.TextView;
import androidx.core.g.t;
import com.bytedance.covode.number.Covode;
import com.bytedance.frameworks.apm.trace.MethodCollector;
import com.ss.android.ugc.aweme.creative.model.publish.AVTextExtraStruct;
import com.ss.android.ugc.aweme.shortvideo.model.GreenScreenMaterial$MediaType$Companion;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import kotlin.h.b.n;

public final class DraftViewHolder extends C533876i<C527473w> implements 0CG {
    public final String LIZ = "DraftViewHolder";
    public BJv LIZIZ;
    public ViewGroup LIZJ;
    public QJv LIZLLL;
    public 03G LJ;
    public C535076u LJFF;
    public long LJI;
    public C527473w LJII;
    public final C42616lH LJIIIIZZ;
    public TextView LJIIIZ;
    public ImageView LJIIJ;
    public TextView LJIIJJI;
    public View LJIIL;
    public ImageView LJIILIIL;
    public AnonymousClass775 LJIILJJIL;
    public Space LJIILL;
    public RelativeLayout LJIILLIIL;
    public Context LJIIZILJ;
    public C38666eu LJIJ;

    static {
        Covode.recordClassIndex(119284);
    }

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

    public static final /* synthetic */ C527473w LIZ(DraftViewHolder draftViewHolder) {
        C527473w r1 = draftViewHolder.LJII;
        if (r1 == null) {
            n.LIZ("");
        }
        return r1;
    }

    public static final /* synthetic */ QJv LIZIZ(DraftViewHolder draftViewHolder) {
        QJv qJv = draftViewHolder.LIZLLL;
        if (qJv == null) {
            n.LIZ("");
        }
        return qJv;
    }

    private final void LIZ(C527473w r10) {
        MethodCollector.i(11541);
        BJv bJv = this.LIZIZ;
        if (bJv == null) {
            n.LIZ("");
        }
        bJv.setSpanColor(070.LIZJ(this.LJIIZILJ, 2131099750));
        String str = r10.LJIIIZ;
        if (str.length() == 0) {
            BJv bJv2 = this.LIZIZ;
            if (bJv2 == null) {
                n.LIZ("");
            }
            bJv2.setText(this.LJIIZILJ.getText(2131824079));
            BJv bJv3 = this.LIZIZ;
            if (bJv3 == null) {
                n.LIZ("");
            }
            bJv3.setTextColor(070.LIZJ(this.LJIIZILJ, 2131099758));
            MethodCollector.o(11541);
            return;
        }
        BJv bJv4 = this.LIZIZ;
        if (bJv4 == null) {
            n.LIZ("");
        }
        bJv4.setText(str);
        List<? extends AVTextExtraStruct> list = r10.LJIIJ;
        if (list != null) {
            ArrayList arrayList = new ArrayList();
            for (T next : list) {
                if (!((AVTextExtraStruct) next).isTransient()) {
                    arrayList.add(next);
                }
            }
            List<AVTextExtraStruct> list2 = arrayList;
            if (list2 != null) {
                BJv bJv5 = this.LIZIZ;
                if (bJv5 == null) {
                    n.LIZ("");
                }
                bJv5.LIZ(FaH.LIZ(list2), true ^ FWb.LIZIZ.LIZ().LJJIIJ().LIZ());
                for (AVTextExtraStruct aVTextExtraStruct : list2) {
                    if (aVTextExtraStruct.getType() == 0 || aVTextExtraStruct.getType() == 5) {
                        switch (aVTextExtraStruct.getSubType()) {
                            case 1:
                            case 6:
                            case 8:
                            case 9:
                            case 10:
                            case 12:
                            case 13:
                                BJv bJv6 = this.LIZIZ;
                                if (bJv6 == null) {
                                    n.LIZ("");
                                }
                                Context context = bJv6.getContext();
                                n.LIZIZ(context, "");
                                BJv bJv7 = this.LIZIZ;
                                if (bJv7 == null) {
                                    n.LIZ("");
                                }
                                CbN cbN = new CbN(context, bJv7);
                                BJv bJv8 = this.LIZIZ;
                                if (bJv8 == null) {
                                    n.LIZ("");
                                }
                                bJv8.LIZ(aVTextExtraStruct.getStart(), aVTextExtraStruct.getEnd(), cbN);
                                break;
                            case GreenScreenMaterial$MediaType$Companion.VIDEO:
                                BJv bJv9 = this.LIZIZ;
                                if (bJv9 == null) {
                                    n.LIZ("");
                                }
                                Context context2 = bJv9.getContext();
                                n.LIZIZ(context2, "");
                                BJv bJv10 = this.LIZIZ;
                                if (bJv10 == null) {
                                    n.LIZ("");
                                }
                                FdE fdE = new FdE(context2, bJv10);
                                BJv bJv11 = this.LIZIZ;
                                if (bJv11 == null) {
                                    n.LIZ("");
                                }
                                Context context3 = bJv11.getContext();
                                n.LIZIZ(context3, "");
                                fdE.LIZ = BitmapFactory.decodeResource(context3.getResources(), 2131234054);
                                BJv bJv12 = this.LIZIZ;
                                if (bJv12 == null) {
                                    n.LIZ("");
                                }
                                bJv12.LIZ(aVTextExtraStruct.getStart(), aVTextExtraStruct.getEnd(), fdE);
                                break;
                            case 3:
                                BJv bJv13 = this.LIZIZ;
                                if (bJv13 == null) {
                                    n.LIZ("");
                                }
                                Context context4 = bJv13.getContext();
                                n.LIZIZ(context4, "");
                                BJv bJv14 = this.LIZIZ;
                                if (bJv14 == null) {
                                    n.LIZ("");
                                }
                                FdE fdE2 = new FdE(context4, bJv14);
                                BJv bJv15 = this.LIZIZ;
                                if (bJv15 == null) {
                                    n.LIZ("");
                                }
                                Context context5 = bJv15.getContext();
                                n.LIZIZ(context5, "");
                                fdE2.LIZ = BitmapFactory.decodeResource(context5.getResources(), 2131234056);
                                BJv bJv16 = this.LIZIZ;
                                if (bJv16 == null) {
                                    n.LIZ("");
                                }
                                bJv16.LIZ(aVTextExtraStruct.getStart(), aVTextExtraStruct.getEnd(), fdE2);
                                break;
                        }
                    }
                }
            }
        }
        BJv bJv17 = this.LIZIZ;
        if (bJv17 == null) {
            n.LIZ("");
        }
        bJv17.setTextColor(070.LIZJ(this.LJIIZILJ, 2131099750));
        MethodCollector.o(11541);
    }

    public final /* synthetic */ void LIZ(AnonymousClass74J r14) {
        C527473w r142 = (C527473w) r14;
        M12.LIZ(r142);
        this.LJII = r142;
        if (r142 == null) {
            n.LIZ("");
        }
        r142.LJ = false;
        C527473w r2 = this.LJII;
        if (r2 == null) {
            n.LIZ("");
        }
        if (r2.LIZ) {
            AnonymousClass775 r5 = this.LJIILJJIL;
            if (r5 == null) {
                n.LIZ("");
            }
            if (!r5.LIZJ) {
                r5.LIZJ = true;
                r5.LIZ.startScroll(0, 0, -r5.LIZIZ, 0, 200);
                if (r5.LIZLLL != null) {
                    r5.LIZLLL.LIZ(r5.LIZIZ, r5.LIZJ);
                }
            }
            ImageView imageView = this.LJIILIIL;
            if (imageView == null) {
                n.LIZ("");
            }
            imageView.animate().alpha(0.0f).setDuration(200).start();
        } else {
            AnonymousClass775 r52 = this.LJIILJJIL;
            if (r52 == null) {
                n.LIZ("");
            }
            if (r52.LIZJ) {
                r52.LIZJ = false;
                r52.LIZ.startScroll(-r52.LIZIZ, 0, r52.LIZIZ, 0, 200);
                if (r52.LIZLLL != null) {
                    r52.LIZLLL.LIZ(r52.LIZIZ, r52.LIZJ);
                }
            }
            ImageView imageView2 = this.LJIILIIL;
            if (imageView2 == null) {
                n.LIZ("");
            }
            imageView2.animate().alpha(1.0f).setDuration(200).start();
            C527473w r22 = this.LJII;
            if (r22 == null) {
                n.LIZ("");
            }
            r22.LJ = false;
        }
        C527473w r23 = this.LJII;
        if (r23 == null) {
            n.LIZ("");
        }
        if (r23.LIZIZ) {
            TextView textView = this.LJIIJJI;
            if (textView == null) {
                n.LIZ("");
            }
            Context context = this.LJIIZILJ;
            C527473w r24 = this.LJII;
            if (r24 == null) {
                n.LIZ("");
            }
            long j = r24.LJFF;
            M12.LIZ(context);
            String string = context.getString(2131832273, new Object[]{Double.valueOf(((double) j) / 1048576.0d)});
            n.LIZIZ(string, "");
            textView.setText(string);
        }
        03G r3 = this.LJ;
        if (r3 == null) {
            n.LIZ("");
        }
        r3.setOnCheckedChangeListener((CompoundButton.OnCheckedChangeListener) null);
        03G r32 = this.LJ;
        if (r32 == null) {
            n.LIZ("");
        }
        C527473w r25 = this.LJII;
        if (r25 == null) {
            n.LIZ("");
        }
        r32.setChecked(r25.LJ);
        03G r33 = this.LJ;
        if (r33 == null) {
            n.LIZ("");
        }
        r33.setOnCheckedChangeListener(new AnonymousClass772(this));
        QJv qJv = this.LIZLLL;
        if (qJv == null) {
            n.LIZ("");
        }
        C527473w r26 = this.LJII;
        if (r26 == null) {
            n.LIZ("");
        }
        qJv.setTag(r26.LIZJ);
        QJv qJv2 = this.LIZLLL;
        if (qJv2 == null) {
            n.LIZ("");
        }
        3ZQ LIZ2 = 2xd.LIZ(new 2yn(this));
        View view = this.itemView;
        n.LIZIZ(view, "");
        Context context2 = view.getContext();
        n.LIZIZ(context2, "");
        QNA LIZ3 = LIZ2.LIZ(context2);
        3ae r6 = new 3ae();
        r6.LIZIZ = 2130968593;
        View view2 = this.itemView;
        n.LIZIZ(view2, "");
        r6.LJII = (int) HeD.LIZIZ(view2.getContext(), 64.0f);
        View view3 = this.itemView;
        n.LIZIZ(view3, "");
        r6.LJI = (int) HeD.LIZIZ(view3.getContext(), 64.0f);
        View view4 = this.itemView;
        n.LIZIZ(view4, "");
        Context context3 = view4.getContext();
        n.LIZIZ(context3, "");
        qJv2.setImageDrawable(Qen.LIZ(LIZ3, r6.LIZ(context3)));
        C527473w r4 = this.LJII;
        if (r4 == null) {
            n.LIZ("");
        }
        File file = new File(r4.LIZLLL);
        if (file.exists()) {
            Uri fromFile = Uri.fromFile(file);
            QJv qJv3 = this.LIZLLL;
            if (qJv3 == null) {
                n.LIZ("");
            }
            OCO.LIZ(qJv3, fromFile.toString(), -1, -1);
        } else {
            C42016kJ LIZ4 = this.LJIIIIZZ.LIZ(r4.LIZJ);
            if (LIZ4 == null) {
                AnonymousClass6ZR.LIZIZ(this.LIZ + ": bindDraftCover -> draft is null");
                TSt.LIZ("queryNull -> " + this.LIZ + " : bindDraftCover");
            } else {
                int dimensionPixelOffset = this.LJIIZILJ.getResources().getDimensionPixelOffset(2131165585);
                C38666eu r34 = new C38666eu(dimensionPixelOffset, dimensionPixelOffset, Bitmap.Config.ARGB_8888);
                this.LJIJ = r34;
                C38646es.LIZ(LIZ4, r34, new C535476y(this, LIZ4));
            }
        }
        C527473w r27 = this.LJII;
        if (r27 == null) {
            n.LIZ("");
        }
        LIZ(r27);
        TextView textView2 = this.LJIIIZ;
        if (textView2 == null) {
            n.LIZ("");
        }
        textView2.setVisibility(8);
        ImageView imageView3 = this.LJIIJ;
        if (imageView3 == null) {
            n.LIZ("");
        }
        imageView3.setVisibility(8);
        RelativeLayout relativeLayout = this.LJIILLIIL;
        if (relativeLayout == null) {
            n.LIZ("");
        }
        ViewGroup.LayoutParams layoutParams = relativeLayout.getLayoutParams();
        Space space = this.LJIILL;
        if (space == null) {
            n.LIZ("");
        }
        ViewGroup.LayoutParams layoutParams2 = space.getLayoutParams();
        int LIZIZ2 = (int) HeD.LIZIZ(this.LJIIZILJ, 8.0f);
        int LIZIZ3 = (int) HeD.LIZIZ(this.LJIIZILJ, 88.0f);
        if (r142.LJIIL) {
            layoutParams2.height = LIZIZ2 * 2;
            LIZIZ3 += LIZIZ2;
        } else {
            layoutParams2.height = LIZIZ2;
        }
        C527473w r28 = this.LJII;
        if (r28 == null) {
            n.LIZ("");
        }
        if (!r28.LJIIJJI) {
            View view5 = this.LJIIL;
            if (view5 == null) {
                n.LIZ("");
            }
            view5.setVisibility(4);
            layoutParams.height = LIZIZ3 - LIZIZ2;
        } else {
            View view6 = this.LJIIL;
            if (view6 == null) {
                n.LIZ("");
            }
            view6.setVisibility(0);
            layoutParams.height = LIZIZ3;
        }
        Space space2 = this.LJIILL;
        if (space2 == null) {
            n.LIZ("");
        }
        space2.setLayoutParams(layoutParams2);
        RelativeLayout relativeLayout2 = this.LJIILLIIL;
        if (relativeLayout2 == null) {
            n.LIZ("");
        }
        relativeLayout2.setLayoutParams(layoutParams);
        RelativeLayout relativeLayout3 = this.LJIILLIIL;
        if (relativeLayout3 == null) {
            n.LIZ("");
        }
        relativeLayout3.setLayoutParams(layoutParams);
    }

    /* JADX WARNING: type inference failed for: r0v34, types: [X.771, android.view.View$OnClickListener] */
    /* JADX INFO: super call moved to the top of the method (can break code semantics) */
    public DraftViewHolder(View view, C535076u r5, C42616lH r6) {
        super(view);
        M12.LIZ(view, r5, r6);
        this.LJIIIIZZ = r6;
        this.LJFF = r5;
        Context context = view.getContext();
        n.LIZIZ(context, "");
        this.LJIIZILJ = context;
        BJv LIZ2 = t.LIZ(view, 2131362562);
        n.LIZIZ(LIZ2, "");
        this.LIZIZ = LIZ2;
        View LIZ3 = t.LIZ(view, 2131367370);
        n.LIZIZ(LIZ3, "");
        this.LIZJ = (ViewGroup) LIZ3;
        View LIZ4 = t.LIZ(view, 2131371942);
        n.LIZIZ(LIZ4, "");
        this.LJIIJJI = (TextView) LIZ4;
        View LIZ5 = t.LIZ(view, 2131362553);
        n.LIZIZ(LIZ5, "");
        this.LJIIIZ = (TextView) LIZ5;
        View LIZ6 = t.LIZ(view, 2131363223);
        n.LIZIZ(LIZ6, "");
        this.LJIIJ = (ImageView) LIZ6;
        QJv LIZ7 = t.LIZ(view, 2131363809);
        n.LIZIZ(LIZ7, "");
        this.LIZLLL = LIZ7;
        View LIZ8 = t.LIZ(view, 2131371876);
        n.LIZIZ(LIZ8, "");
        this.LJIIL = LIZ8;
        View LIZ9 = t.LIZ(view, 2131364236);
        n.LIZIZ(LIZ9, "");
        this.LJIILIIL = (ImageView) LIZ9;
        03G LIZ10 = t.LIZ(view, 2131363271);
        n.LIZIZ(LIZ10, "");
        this.LJ = LIZ10;
        View LIZ11 = t.LIZ(view, 2131367280);
        n.LIZIZ(LIZ11, "");
        AnonymousClass775 r1 = (AnonymousClass775) LIZ11;
        this.LJIILJJIL = r1;
        if (r1 == null) {
            n.LIZ("");
        }
        r1.setOnScrollListener(new AnonymousClass773(this));
        View LIZ12 = t.LIZ(view, 2131364235);
        n.LIZIZ(LIZ12, "");
        this.LJIILL = (Space) LIZ12;
        View LIZ13 = t.LIZ(view, 2131364231);
        n.LIZIZ(LIZ13, "");
        RelativeLayout relativeLayout = (RelativeLayout) LIZ13;
        this.LJIILLIIL = relativeLayout;
        if (relativeLayout == null) {
            n.LIZ("");
        }
        relativeLayout.setOnClickListener(new AnonymousClass771(this));
        RelativeLayout relativeLayout2 = this.LJIILLIIL;
        if (relativeLayout2 == null) {
            n.LIZ("");
        }
        relativeLayout2.setOnLongClickListener(new AnonymousClass770(this));
    }
}
