package com.zhihu.matisse.internal.ui.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.text.format.DateUtils;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.zhihu.matisse.R$id;
import com.zhihu.matisse.R$layout;
import com.zhihu.matisse.internal.entity.Item;
import ඓ.ᨨ.K.ʬ.K.C0765;
import ඓ.ᨨ.K.ඓ.K.C0778;

public class MediaGrid extends SquareFrameLayout implements View.OnClickListener {

    /* renamed from: ʬ  reason: contains not printable characters */
    public CheckView f3373;

    /* renamed from: ඓ  reason: contains not printable characters */
    public TextView f3374;

    /* renamed from: ῲ  reason: contains not printable characters */
    public ImageView f3375;

    /* renamed from: ⁱ  reason: contains not printable characters */
    public C0568 f3376;

    /* renamed from: 㴹  reason: contains not printable characters */
    public Item f3377;

    /* renamed from: 㸾  reason: contains not printable characters */
    public ImageView f3378;

    /* renamed from: 㿎  reason: contains not printable characters */
    public AbstractC0569 f3379;

    /* renamed from: com.zhihu.matisse.internal.ui.widget.MediaGrid$ῲ  reason: contains not printable characters */
    public static class C0568 {

        /* renamed from: ʬ  reason: contains not printable characters */
        public boolean f3380;

        /* renamed from: ῲ  reason: contains not printable characters */
        public Drawable f3381;

        /* renamed from: K  reason: contains not printable characters */
        public int f3382;

        /* renamed from: 㸾  reason: contains not printable characters */
        public RecyclerView.AbstractC0269 f3383;

        public C0568(int i, Drawable drawable, boolean z, RecyclerView.AbstractC0269 r4) {
            this.f3382 = i;
            this.f3381 = drawable;
            this.f3380 = z;
            this.f3383 = r4;
        }
    }

    /* renamed from: com.zhihu.matisse.internal.ui.widget.MediaGrid$K  reason: contains not printable characters */
    public interface AbstractC0569 {
        /* renamed from: K  reason: contains not printable characters */
        void m1931(ImageView imageView, Item item, RecyclerView.AbstractC0269 v);

        /* renamed from: K  reason: contains not printable characters */
        void m1932(CheckView checkView, Item item, RecyclerView.AbstractC0269 v);
    }

    public MediaGrid(Context context) {
        super(context);
        m1928(context);
    }

    public Item getMedia() {
        return this.f3377;
    }

    public void onClick(View view) {
        AbstractC0569 k = this.f3379;
        if (k != null) {
            ImageView imageView = this.f3375;
            if (view == imageView) {
                k.m1931(imageView, this.f3377, this.f3376.f3383);
                return;
            }
            CheckView checkView = this.f3373;
            if (view == checkView) {
                k.m1932(checkView, this.f3377, this.f3376.f3383);
            }
        }
    }

    public void setCheckEnabled(boolean z) {
        this.f3373.setEnabled(z);
    }

    public void setChecked(boolean z) {
        this.f3373.setChecked(z);
    }

    public void setCheckedNum(int i) {
        this.f3373.setCheckedNum(i);
    }

    public void setOnMediaGridClickListener(AbstractC0569 k) {
        this.f3379 = k;
    }

    /* renamed from: K  reason: contains not printable characters */
    public final void m1928(Context context) {
        LayoutInflater.from(context).inflate(R$layout.media_grid_content, (ViewGroup) this, true);
        this.f3375 = (ImageView) findViewById(R$id.media_thumbnail);
        this.f3373 = (CheckView) findViewById(R$id.check_view);
        this.f3378 = (ImageView) findViewById(R$id.gif);
        this.f3374 = (TextView) findViewById(R$id.video_duration);
        this.f3375.setOnClickListener(this);
        this.f3373.setOnClickListener(this);
    }

    public MediaGrid(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        m1928(context);
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1930(C0568 r1) {
        this.f3376 = r1;
    }

    /* renamed from: K  reason: contains not printable characters */
    public void m1929(Item item) {
        this.f3377 = item;
        this.f3378.setVisibility(this.f3377.m1912() ? 0 : 8);
        this.f3373.setCountable(this.f3376.f3380);
        if (this.f3377.m1912()) {
            C0765 k = C0778.C0779.f3967.f3947;
            Context context = getContext();
            C0568 r10 = this.f3376;
            k.m2310(context, r10.f3382, r10.f3381, this.f3375, this.f3377.m1915());
        } else {
            C0765 k2 = C0778.C0779.f3967.f3947;
            Context context2 = getContext();
            C0568 r102 = this.f3376;
            k2.m2308(context2, r102.f3382, r102.f3381, this.f3375, this.f3377.m1915());
        }
        if (this.f3377.m1913()) {
            this.f3374.setVisibility(0);
            this.f3374.setText(DateUtils.formatElapsedTime(this.f3377.f3338 / 1000));
            return;
        }
        this.f3374.setVisibility(8);
    }
}
