package com.ss.android.ugc.aweme.share;

import X.878;
import X.C5167OLa;
import X.C5170OLd;
import X.Lnj;
import X.M12;
import android.content.Intent;
import android.os.Bundle;
import android.text.TextUtils;
import androidx.fragment.app.Fragment;
import com.bytedance.covode.number.Covode;
import com.ss.android.ugc.aweme.openauthorize.AwemeAuthorizeLoginActivity;
import com.ss.android.ugc.aweme.opensdkservice.HandleMediaListener;
import com.ss.android.ugc.aweme.opensdkservice.IOpenPlatformService;
import com.ss.android.ugc.aweme.services.external.ui.EditConfig;
import com.ss.android.ugc.aweme.shortvideo.AVChallenge;
import java.util.ArrayList;

public final class OpenPlatformServiceImpl implements IOpenPlatformService {
    static {
        Covode.recordClassIndex(106877);
    }

    public static IOpenPlatformService LIZ() {
        IOpenPlatformService iOpenPlatformService = (IOpenPlatformService) Lnj.LIZ(IOpenPlatformService.class, false);
        if (iOpenPlatformService != null) {
            return iOpenPlatformService;
        }
        Object LIZIZ = Lnj.LIZIZ(IOpenPlatformService.class, false);
        if (LIZIZ != null) {
            return (IOpenPlatformService) LIZIZ;
        }
        return new OpenPlatformServiceImpl();
    }

    public final boolean LIZ(Intent intent) {
        M12.LIZ(intent);
        M12.LIZ(intent);
        if (!TextUtils.isEmpty(C5170OLd.LIZ(intent, "_aweme_open_sdk_params_client_key"))) {
            return true;
        }
        return false;
    }

    public final void LIZ(Intent intent, HandleMediaListener handleMediaListener) {
        M12.LIZ(intent);
        C5167OLa oLa = new C5167OLa(handleMediaListener);
        M12.LIZ(intent, oLa);
        Bundle LIZ = C5170OLd.LIZ(intent);
        if (LIZ != null) {
            ArrayList<String> stringArrayList = LIZ.getStringArrayList("AWEME_EXTRA_IMAGE_MESSAGE_PATH");
            ArrayList<String> stringArrayList2 = LIZ.getStringArrayList("AWEME_EXTRA_VIDEO_MESSAGE_PATH");
            if (!878.LIZ(stringArrayList)) {
                oLa.LIZIZ(stringArrayList);
            } else if (!878.LIZ(stringArrayList2)) {
                oLa.LIZ(stringArrayList2);
            } else {
                oLa.LIZ();
            }
        }
    }

    public final void LIZ(EditConfig.Builder builder, String str) {
        M12.LIZ(builder, str);
        AVChallenge aVChallenge = new AVChallenge();
        ArrayList arrayList = new ArrayList();
        aVChallenge.challengeName = str;
        arrayList.add(aVChallenge);
        builder.challenges(arrayList);
    }

    public final void LIZ(Fragment fragment, ArrayList<String> arrayList, String str) {
        M12.LIZ(fragment, arrayList, str);
        if (fragment != null && fragment.getContext() != null) {
            Intent intent = new Intent(fragment.getContext(), AwemeAuthorizeLoginActivity.class);
            intent.putStringArrayListExtra("authorize_hide_platforms", arrayList);
            if (str != null) {
                intent.putExtra("auth_from_app", str);
            }
            fragment.startActivityForResult(intent, 2001);
        }
    }
}
