package ඓ.ᨨ.K.ඓ.㸾;

import android.content.ActivityNotFoundException;
import android.content.Context;
import android.content.Intent;
import android.graphics.Point;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.zhihu.matisse.R$id;
import com.zhihu.matisse.R$layout;
import com.zhihu.matisse.R$string;
import com.zhihu.matisse.internal.entity.Item;
import it.sephiroth.android.library.imagezoom.ImageViewTouch;
import it.sephiroth.android.library.imagezoom.ImageViewTouchBase;
import ඓ.ᨨ.K.ඓ.ඓ.C0771;
import ඓ.ᨨ.K.ඓ.K.C0778;
import ඓ.ᨨ.K.㴹.AbstractC0807;

/* renamed from: ඓ.ᨨ.K.ඓ.㸾.ῲ  reason: contains not printable characters */
/* compiled from: PreviewItemFragment */
public class C0793 extends Fragment {

    /* renamed from: ῲ  reason: contains not printable characters */
    public AbstractC0807 f3987;

    /* renamed from: ඓ.ᨨ.K.ඓ.㸾.ῲ$ῲ  reason: contains not printable characters */
    /* compiled from: PreviewItemFragment */
    public class C0794 implements ImageViewTouch.AbstractC0578 {
        public C0794() {
        }
    }

    /* renamed from: ඓ.ᨨ.K.ඓ.㸾.ῲ$K  reason: contains not printable characters */
    /* compiled from: PreviewItemFragment */
    public class View$OnClickListenerC0795 implements View.OnClickListener {

        /* renamed from: ῲ  reason: contains not printable characters */
        public final /* synthetic */ Item f3990;

        public View$OnClickListenerC0795(Item item) {
            this.f3990 = item;
        }

        public void onClick(View view) {
            Intent intent = new Intent("android.intent.action.VIEW");
            intent.setDataAndType(this.f3990.f3339, "video/*");
            try {
                C0793.this.startActivity(intent);
            } catch (ActivityNotFoundException unused) {
                Toast.makeText(C0793.this.getContext(), R$string.error_no_video_activity, 0).show();
            }
        }
    }

    @Override // androidx.fragment.app.Fragment
    public void onAttach(Context context) {
        super.onAttach(context);
        if (context instanceof AbstractC0807) {
            this.f3987 = (AbstractC0807) context;
            return;
        }
        throw new RuntimeException(context.toString() + " must implement OnFragmentInteractionListener");
    }

    @Override // androidx.fragment.app.Fragment
    public View onCreateView(LayoutInflater layoutInflater, ViewGroup viewGroup, Bundle bundle) {
        return layoutInflater.inflate(R$layout.fragment_preview_item, viewGroup, false);
    }

    @Override // androidx.fragment.app.Fragment
    public void onDetach() {
        super.onDetach();
        this.f3987 = null;
    }

    @Override // androidx.fragment.app.Fragment
    public void onViewCreated(View view, Bundle bundle) {
        super.onViewCreated(view, bundle);
        Item item = (Item) getArguments().getParcelable("args_item");
        if (item != null) {
            View findViewById = view.findViewById(R$id.video_play_button);
            if (item.m1913()) {
                findViewById.setVisibility(0);
                findViewById.setOnClickListener(new View$OnClickListenerC0795(item));
            } else {
                findViewById.setVisibility(8);
            }
            ImageViewTouch imageViewTouch = (ImageViewTouch) view.findViewById(R$id.image_view);
            imageViewTouch.setDisplayType(ImageViewTouchBase.DisplayType.FIT_TO_SCREEN);
            imageViewTouch.setSingleTapListener(new C0794());
            Point r7 = C0771.m2342(item.m1915(), getActivity());
            if (item.m1912()) {
                C0778.C0779.f3967.f3947.m2309(getContext(), r7.x, r7.y, imageViewTouch, item.m1915());
            } else {
                C0778.C0779.f3967.f3947.m2307(getContext(), r7.x, r7.y, imageViewTouch, item.m1915());
            }
        }
    }

    /* renamed from: 㿎  reason: contains not printable characters */
    public void m2379() {
        if (getView() != null) {
            ((ImageViewTouch) getView().findViewById(R$id.image_view)).m1974();
        }
    }
}
