Kate Mobile v109.1版本的 MD5 值为:fcd76ded5f363ecbfac46035a4ed2a23

以下内容为反编译后的 VideoLogic.java 源代码,内容仅作参考


package com.perm.kate;

import android.app.Activity;
import android.app.Application;
import android.content.ActivityNotFoundException;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.preference.PreferenceManager;
import android.text.TextUtils;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
import android.widget.Toast;
import androidx.appcompat.app.AlertDialog;
import com.flurry.android.FlurryAgent;
import com.perm.kate.api.Video;
import com.perm.kate.session.Callback;
import com.perm.kate.session.Session;
import com.perm.kate.video_cache.VideoCache;
import com.perm.utils.ProxyManager;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.TreeMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public abstract class VideoLogic {
    static boolean access$500() {
        return videoInternal();
    }

    public static void displayPlayWith(final Video video, final Activity activity) {
        if (activity.isFinishing()) {
            return;
        }
        final ArrayList arrayList = new ArrayList();
        arrayList.add(new MenuItemDetails((int) R.string.player_external, 0));
        arrayList.add(new MenuItemDetails((int) R.string.player_internal, 1));
        arrayList.add(new MenuItemDetails((int) R.string.player_browser, 2));
        arrayList.add(new MenuItemDetails((int) R.string.player_browser_player, 3));
        AlertDialog create = new AlertDialog.Builder(activity).setItems(MenuItemDetails.toArray(arrayList), new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialogInterface, int i) {
                int i2 = ((MenuItemDetails) arrayList.get(i)).code;
                if (i2 == 0) {
                    VideoLogic.playExternal(video, activity, null);
                } else if (i2 == 1) {
                    VideoLogic.playInternal(video, activity);
                } else if (i2 == 2) {
                    VideoLogic.playBrowser(video.getVideoUrl(), activity);
                } else if (i2 != 3) {
                } else {
                    VideoLogic.playBrowser(video.player, activity);
                }
            }
        }).create();
        create.setCanceledOnTouchOutside(true);
        create.show();
    }

    public static void displayQualityMenu(final Video video, final Activity activity) {
        final ArrayList arrayList = new ArrayList();
        if (!TextUtils.isEmpty(video.mp4_240)) {
            arrayList.add(new MenuItemDetails("240", 240));
        }
        if (!TextUtils.isEmpty(video.mp4_360)) {
            arrayList.add(new MenuItemDetails("360", 360));
        }
        if (!TextUtils.isEmpty(video.mp4_480)) {
            arrayList.add(new MenuItemDetails("480", 480));
        }
        if (!TextUtils.isEmpty(video.mp4_720)) {
            arrayList.add(new MenuItemDetails("HD-720", 720));
        }
        if (!TextUtils.isEmpty(video.mp4_1080)) {
            arrayList.add(new MenuItemDetails("Full HD-1080", 1080));
        }
        if (!TextUtils.isEmpty(video.hls_ondemand)) {
            arrayList.add(new MenuItemDetails("HLS", 2000));
        }
        if (arrayList.size() == 0) {
            playExternal(video, activity, null);
        } else if (activity.isFinishing()) {
        } else {
            activity.runOnUiThread(new Runnable() {
                @Override
                public void run() {
                    new AlertDialog.Builder(activity).setTitle(R.string.label_quality_video).setItems(MenuItemDetails.toArray(arrayList), new DialogInterface.OnClickListener() {
                        @Override
                        public void onClick(DialogInterface dialogInterface, int i) {
                            int i2 = ((MenuItemDetails) arrayList.get(i)).code;
                            if (i2 == 240) {
                                AnonymousClass3 anonymousClass3 = AnonymousClass3.this;
                                Video video2 = video;
                                VideoLogic.playExternal(video2, activity, video2.mp4_240);
                            } else if (i2 == 360) {
                                AnonymousClass3 anonymousClass32 = AnonymousClass3.this;
                                Video video3 = video;
                                VideoLogic.playExternal(video3, activity, video3.mp4_360);
                            } else if (i2 == 480) {
                                AnonymousClass3 anonymousClass33 = AnonymousClass3.this;
                                Video video4 = video;
                                VideoLogic.playExternal(video4, activity, video4.mp4_480);
                            } else if (i2 == 720) {
                                AnonymousClass3 anonymousClass34 = AnonymousClass3.this;
                                Video video5 = video;
                                VideoLogic.playExternal(video5, activity, video5.mp4_720);
                            } else if (i2 == 1080) {
                                AnonymousClass3 anonymousClass35 = AnonymousClass3.this;
                                Video video6 = video;
                                VideoLogic.playExternal(video6, activity, video6.mp4_1080);
                            } else if (i2 != 2000) {
                            } else {
                                AnonymousClass3 anonymousClass36 = AnonymousClass3.this;
                                Video video7 = video;
                                VideoLogic.playExternal(video7, activity, video7.hls_ondemand);
                            }
                        }
                    }).show();
                }
            });
        }
    }

    public static void fetchAndPlay(long j, long j2, String str, BaseActivity baseActivity) {
        fetchAndPlay(j, j2, str, baseActivity, false);
    }

    public static void fetchAndPlay(final long j, final long j2, final String str, final BaseActivity baseActivity, final boolean z) {
        String tryFromCache;
        if (!z && (tryFromCache = VideoCache.tryFromCache(j, j2)) != null) {
            playExternal(null, baseActivity, tryFromCache);
            return;
        }
        final Callback callback = new Callback(baseActivity) {
            @Override
            public void error(Throwable th) {
                baseActivity.showProgressBar(false);
                super.error(th);
            }

            @Override
            public void ready(Object obj) {
                boolean z2 = false;
                baseActivity.showProgressBar(false);
                ArrayList arrayList = (ArrayList) obj;
                if (arrayList == null || arrayList.size() == 0) {
                    return;
                }
                Video video = (Video) arrayList.get(0);
                if (VideoLogic.isPHPUrlHLS(video.hls)) {
                    video.hls = VideoLogic.getDirectHLSUrl(video.hls);
                }
                if (z) {
                    VideoLogic.displayQualityMenu(video, baseActivity);
                    return;
                }
                String videoUrl = VideoLogic.getVideoUrl(video);
                boolean z3 = videoUrl != null && (videoUrl.contains("vkuservideo") || videoUrl.contains("userapi.com"));
                if (videoUrl != null && "video/mp4".equals(VideoLogic.guessVideoType(videoUrl))) {
                    z2 = true;
                }
                if (ProxyManager.getEnabled() && z3) {
                    VideoLogic.playInternal(video, baseActivity);
                } else if (z2 && VideoLogic.access$500()) {
                    VideoLogic.playInternal(video, baseActivity);
                } else {
                    VideoLogic.playExternal(video, baseActivity, null);
                }
            }
        };
        baseActivity.showProgressBar(true);
        new Thread() {
            @Override
            public void run() {
                String str2 = j2 + "_" + j;
                if (!TextUtils.isEmpty(str)) {
                    str2 = str2 + "_" + str;
                }
                KApplication.session.getVideo(str2, null, null, null, null, null, false, callback, baseActivity);
            }
        }.start();
    }

    public static void fetchAndPlayWith(final long j, final long j2, final String str, final BaseActivity baseActivity) {
        final Callback callback = new Callback(baseActivity) {
            @Override
            public void error(Throwable th) {
                baseActivity.showProgressBar(false);
                super.error(th);
            }

            @Override
            public void ready(Object obj) {
                baseActivity.showProgressBar(false);
                ArrayList arrayList = (ArrayList) obj;
                if (arrayList == null || arrayList.size() == 0 || baseActivity.isFinishing()) {
                    return;
                }
                final Video video = (Video) arrayList.get(0);
                if (VideoLogic.isPHPUrlHLS(video.hls)) {
                    video.hls = VideoLogic.getDirectHLSUrl(video.hls);
                }
                baseActivity.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        VideoLogic.displayPlayWith(video, baseActivity);
                    }
                });
            }
        };
        baseActivity.showProgressBar(true);
        new Thread() {
            @Override
            public void run() {
                String str2 = j2 + "_" + j;
                if (!TextUtils.isEmpty(str)) {
                    str2 = str2 + "_" + str;
                }
                KApplication.session.getVideo(str2, null, null, null, null, null, false, callback, baseActivity);
            }
        }.start();
    }

    public static void fetchAndShowInstructions(final long j, final long j2, final String str, final BaseActivity baseActivity) {
        final Callback callback = new Callback(baseActivity) {
            @Override
            public void error(Throwable th) {
                baseActivity.showProgressBar(false);
                super.error(th);
            }

            @Override
            public void ready(Object obj) {
                baseActivity.showProgressBar(false);
                ArrayList arrayList = (ArrayList) obj;
                if (arrayList == null || arrayList.size() == 0) {
                    return;
                }
                VideoLogic.showInstructionsOnUiThread(baseActivity, VideoLogic.getVideoUrl((Video) arrayList.get(0)));
            }
        };
        baseActivity.showProgressBar(true);
        new Thread() {
            @Override
            public void run() {
                String str2 = j2 + "_" + j;
                if (!TextUtils.isEmpty(str)) {
                    str2 = str2 + "_" + str;
                }
                KApplication.session.getVideo(str2, null, null, null, null, null, false, callback, baseActivity);
            }
        }.start();
    }

    public static String getDirectHLSUrl(String str) {
        HttpURLConnection httpURLConnection;
        Throwable th;
        IOException e;
        MalformedURLException e2;
        HttpURLConnection httpURLConnection2;
        try {
            try {
                ArrayList arrayList = new ArrayList();
                httpURLConnection = (HttpURLConnection) new URL(str).openConnection();
                try {
                    if (httpURLConnection.getResponseCode() == 200) {
                        BufferedInputStream bufferedInputStream = new BufferedInputStream(httpURLConnection.getInputStream());
                        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(bufferedInputStream));
                        while (true) {
                            String readLine = bufferedReader.readLine();
                            if (readLine == null) {
                                break;
                            } else if (!readLine.startsWith("#")) {
                                arrayList.add(readLine);
                            }
                        }
                        bufferedInputStream.close();
                    }
                    String hLSUrlbyQuality = getHLSUrlbyQuality(arrayList);
                    httpURLConnection.disconnect();
                    return hLSUrlbyQuality;
                } catch (MalformedURLException e3) {
                    e2 = e3;
                    e2.printStackTrace();
                } catch (IOException e4) {
                    e = e4;
                    e.printStackTrace();
                    if (httpURLConnection != null) {
                        httpURLConnection.disconnect();
                    }
                    return str;
                } catch (Throwable th2) {
                    th = th2;
                    th.printStackTrace();
                    Helper.reportError(th, str);
                    if (httpURLConnection != null) {
                        httpURLConnection.disconnect();
                    }
                    return str;
                }
            } catch (Throwable th3) {
                if (httpURLConnection2 != null) {
                    httpURLConnection2.disconnect();
                }
                throw th3;
            }
        } catch (MalformedURLException e5) {
            httpURLConnection = null;
            e2 = e5;
        } catch (IOException e6) {
            httpURLConnection = null;
            e = e6;
        } catch (Throwable th4) {
            httpURLConnection = null;
            th = th4;
        }
    }

    private static String getExtension(String str) {
        if (str == null) {
            return null;
        }
        if (str.contains(".mp4")) {
            return "mp4";
        }
        if (str.contains(".flv")) {
            return "flv";
        }
        return null;
    }

    private static String getFilename(Video video, String str) {
        if (video == null || video.title == null || str == null) {
            return null;
        }
        String extension = getExtension(str);
        if (extension == null) {
            extension = "mp4";
        }
        return Helper.limitFilename(video.title) + "." + extension;
    }

    private static String getHLSUrlbyQuality(ArrayList arrayList) {
        int qualityPreference = getQualityPreference();
        if (arrayList.size() > qualityPreference) {
            return (String) arrayList.get(qualityPreference);
        }
        if (arrayList.size() > 0) {
            return (String) arrayList.get(arrayList.size() - 1);
        }
        return null;
    }

    private static int getQualityPreference() {
        Application application = KApplication.current;
        return Integer.parseInt(PreferenceManager.getDefaultSharedPreferences(application).getString(application.getString(R.string.key_hd_quality_video), "0"));
    }

    private static void getRecommendedPlayers(String str, ArrayList arrayList, ArrayList arrayList2) {
        if ("mp4".equals(str) || "vkvd".equals(str) || "vkuser".equals(str)) {
            arrayList.add("MX Player");
            arrayList2.add("market://details?id=com.mxtech.videoplayer.ad");
            arrayList.add("VLC");
            arrayList2.add("market://details?id=org.videolan.vlc");
            arrayList.add("BSPlayer FREE");
            arrayList2.add("market://details?id=com.bsplayer.bspandroid.free");
            arrayList.add("KMPlayer");
            arrayList2.add("market://details?id=com.kmplayer");
        }
        if ("youtube".equals(str)) {
            arrayList.add("YouTube");
            arrayList2.add("market://details?id=com.google.android.youtube");
        }
        if ("flv".equals(str)) {
            arrayList.add("MX Player");
            arrayList2.add("market://details?id=com.mxtech.videoplayer.ad");
            arrayList.add("VLC");
            arrayList2.add("market://details?id=org.videolan.vlc");
            arrayList.add("BSPlayer FREE");
            arrayList2.add("market://details?id=com.bsplayer.bspandroid.free");
            arrayList.add("KMPlayer");
            arrayList2.add("market://details?id=com.kmplayer");
        }
        if ("rutube".equals(str)) {
            arrayList.add("Rutube");
            arrayList2.add("market://details?id=ru.rutube.app");
        }
        if ("coub".equals(str)) {
            arrayList.add("Coub Player");
            arrayList2.add("market://details?id=ru.tihelper.coubclient");
        }
        if ("vimeo".equals(str)) {
            arrayList.add("Filmo HD for Vimeo");
            arrayList2.add("market://details?id=com.husseinala.vimeoplayer");
            arrayList.add("Vimeo");
            arrayList2.add("market://details?id=com.vimeo.android.videoapp");
        }
        if ("m3u8".equals(str)) {
            arrayList.add("MX Player");
            arrayList2.add("market://details?id=com.mxtech.videoplayer.ad");
            arrayList.add("VLC");
            arrayList2.add("market://details?id=org.videolan.vlc");
            arrayList.add("KMPlayer");
            arrayList2.add("market://details?id=com.kmplayer");
        }
    }

    private static String getVideoTypeForFlurry(String str) {
        if (str == null) {
            return "null";
        }
        String lowerCase = str.toLowerCase();
        return lowerCase.contains(".mp4") ? "mp4" : lowerCase.contains(".flv") ? "flv" : lowerCase.contains("youtu") ? "youtube" : lowerCase.contains("rutube") ? "rutube" : lowerCase.contains("vimeo") ? "vimeo" : lowerCase.contains("coub.com") ? "coub" : lowerCase.contains("ivi.ru") ? "ivi" : lowerCase.contains("carambatv.ru") ? "carambatv" : lowerCase.contains("dailymotion.com") ? "dailymotion" : lowerCase.contains("now.ru") ? "now" : lowerCase.contains("megogo.net") ? "megogo" : lowerCase.contains("myvi.ru") ? "myvi" : lowerCase.contains("1tv.ru") ? "1tv" : lowerCase.contains("molodejj.tv") ? "molodejj" : lowerCase.contains("tvigle.ru") ? "tvigle" : (lowerCase.contains("tchkcdn.com") || lowerCase.contains("tochka.net")) ? "tochka" : lowerCase.contains("rutv.ru") ? "rutv" : lowerCase.contains("zoomby.ru") ? "zoomby" : lowerCase.contains("kinopoisk.ru") ? "kinopoisk" : lowerCase.contains("videomore.ru") ? "videomore" : lowerCase.contains("tvzavr.ru") ? "tvzavr" : lowerCase.contains("bigmir.net") ? "bigmir" : lowerCase.contains("vireg.tv") ? "vireg" : lowerCase.contains("pladform") ? "pladform" : lowerCase.contains("smexo.tv") ? "smexo.tv" : lowerCase.contains("videocore") ? "videocore" : lowerCase.contains("ntv.ru") ? "ntv.ru" : lowerCase.contains("vine.co") ? "vine" : (lowerCase.contains("m3u8") || lowerCase.contains("video_hls")) ? "m3u8" : lowerCase.contains("://vkvd") ? "vkvd" : lowerCase.contains(".vkuser.net/") ? "vkuser" : lowerCase.length() >= 30 ? lowerCase.substring(0, 30) : lowerCase;
    }

    static String getVideoUrl(Video video) {
        String str;
        int qualityPreference = getQualityPreference();
        ArrayList arrayList = new ArrayList(9);
        if (qualityPreference == 4) {
            arrayList.addAll(Arrays.asList(video.mp4_1080, video.mp4_720, video.mp4_480, video.mp4_360, video.mp4_240));
        } else if (qualityPreference == 3) {
            arrayList.addAll(Arrays.asList(video.mp4_720, video.mp4_480, video.mp4_360, video.mp4_240, video.mp4_1080));
        } else if (qualityPreference == 2) {
            arrayList.addAll(Arrays.asList(video.mp4_480, video.mp4_360, video.mp4_240, video.mp4_720, video.mp4_1080));
        } else if (qualityPreference == 1) {
            arrayList.addAll(Arrays.asList(video.mp4_360, video.mp4_240, video.mp4_480, video.mp4_720, video.mp4_1080));
        } else {
            arrayList.addAll(Arrays.asList(video.mp4_240, video.mp4_360, video.mp4_480, video.mp4_720, video.mp4_1080));
        }
        arrayList.add(video.flv_320);
        arrayList.add(video.hls);
        arrayList.add(video.live);
        arrayList.add(video.external);
        Iterator it = arrayList.iterator();
        while (true) {
            if (!it.hasNext()) {
                str = null;
                break;
            }
            str = (String) it.next();
            if (!TextUtils.isEmpty(str)) {
                break;
            }
        }
        Log.i("Kate.VideoLogic", "getVideoUrl url=" + str);
        return str;
    }

    public static String guessVideoType(String str) {
        if (str.contains(".mp4")) {
            return "video/mp4";
        }
        if (str.contains(".flv")) {
            return "video/x-flv";
        }
        if (str.contains(".m3u8")) {
            return "application/x-mpegURL";
        }
        if (str.contains("://vkvd") || str.contains(".vkuser.net/")) {
            return "video/mp4";
        }
        return null;
    }

    public static boolean isPHPUrlHLS(String str) {
        return str != null && str.contains("video_hls.php");
    }

    public static void lambda$playExternal$0(Video video) {
        Toast.makeText(KApplication.current, video.content_restricted_message, 1).show();
    }

    public static void openLink(String str, Activity activity) {
        try {
            activity.startActivity(new Intent("android.intent.action.VIEW", Uri.parse(str)));
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th);
        }
    }

    public static void playBrowser(String str, Activity activity) {
        try {
            Intent intent = new Intent();
            intent.setAction("android.intent.action.VIEW");
            intent.setData(Uri.parse(str));
            activity.startActivity(Intent.createChooser(intent, null));
        } catch (ActivityNotFoundException e) {
            Helper.reportError(e, str);
            e.printStackTrace();
        }
    }

    public static void playExternal(final Video video, Activity activity, String str) {
        if (str == null) {
            try {
                str = getVideoUrl(video);
            } catch (ActivityNotFoundException unused) {
                reportExternalVideoNotInstalled(str);
                if (str == null || !str.contains(".mp4")) {
                    showInstructionsOnUiThread(activity, str);
                    return;
                } else {
                    playInternal(video, activity);
                    return;
                }
            } catch (Throwable th) {
                if (!Helper.isNoiseException(th)) {
                    Helper.reportError(th, video != null ? video.player : null);
                }
                th.printStackTrace();
                return;
            }
        }
        reportExternalVideoTry(str);
        if (video != null && !TextUtils.isEmpty(video.content_restricted_message) && !activity.isFinishing()) {
            activity.runOnUiThread(new Runnable() {
                @Override
                public final void run() {
                    VideoLogic.lambda$playExternal$0(Video.this);
                }
            });
        }
        if (str != null && !str.equals("")) {
            Log.i("Kate.VideoLogic", "video_url " + str);
            boolean contains = str.contains("m3u8");
            if (!str.contains(".1080.mp4") && Session.isVideoOverHttp() && !contains) {
                str = str.replace("https://", "http://");
                Log.i("Kate.VideoLogic", "video_url after https replace " + str);
            }
            String vimeoFix = vimeoFix(str);
            Log.i("Kate.VideoLogic", "video_url after vimeo fix " + vimeoFix);
            String rutubeFix = rutubeFix(vimeoFix);
            String guessVideoType = guessVideoType(rutubeFix);
            String filename = getFilename(video, rutubeFix);
            Log.i("Kate.VideoLogic", "filename=" + filename);
            Intent intent = new Intent("android.intent.action.VIEW");
            if (guessVideoType != null) {
                intent.setDataAndType(Uri.parse(rutubeFix), guessVideoType);
            } else {
                intent.setData(Uri.parse(rutubeFix));
            }
            if (filename != null) {
                intent.putExtra("com.android.extra.filename", filename);
            }
            activity.startActivity(intent);
            return;
        }
        playBrowser(video.getVideoUrl(), activity);
    }

    public static void playInternal(Video video, Activity activity) {
        try {
            String videoUrl = getVideoUrl(video);
            if (videoUrl.contains("youtube")) {
                Log.i("Kate.VideoLogic", "Can't play youtube in internal player");
            } else if (videoUrl.contains(".flv")) {
                Log.i("Kate.VideoLogic", "Can't play FLV in internal player");
            } else {
                Intent intent = new Intent();
                intent.setClass(activity, VideoViewActivity.class);
                intent.putExtra("video_url", videoUrl);
                activity.startActivity(intent);
            }
        } catch (Throwable th) {
            if (!Helper.isNoiseException(th)) {
                Helper.reportError(th);
            }
            th.printStackTrace();
        }
    }

    private static void reportExternalVideoNotInstalled(String str) {
        if (System.nanoTime() % 100 < 99) {
            return;
        }
        TreeMap treeMap = new TreeMap();
        treeMap.put("type", getVideoTypeForFlurry(str));
        FlurryAgent.logEvent("VIDEO_EXTERNAL_NO_PLAYER_INSTALLED", treeMap);
    }

    private static void reportExternalVideoTry(String str) {
        if (System.nanoTime() % 10000 < 9995) {
            return;
        }
        TreeMap treeMap = new TreeMap();
        treeMap.put("type", getVideoTypeForFlurry(str));
        FlurryAgent.logEvent("VIDEO_EXTERNAL_TRY", treeMap);
    }

    private static String rutubeFix(String str) {
        try {
            Matcher matcher = Pattern.compile("video\\.rutube\\.ru/(\\d+)$").matcher(str);
            if (matcher.find()) {
                return "http://rutube.ru/video/embed/" + matcher.group(1);
            }
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th);
        }
        return str;
    }

    static void showInstructions(final Activity activity, String str) {
        try {
            View inflate = LayoutInflater.from(activity).inflate(R.layout.video_instructions, (ViewGroup) null);
            ArrayList arrayList = new ArrayList();
            ArrayList arrayList2 = new ArrayList();
            arrayList.add(inflate.findViewById(R.id.fl_button_bg));
            arrayList2.add((TextView) inflate.findViewById(R.id.button3));
            arrayList.add(inflate.findViewById(R.id.fl_button_bg2));
            arrayList2.add((TextView) inflate.findViewById(R.id.button1));
            arrayList.add(inflate.findViewById(R.id.fl_button_bg3));
            arrayList2.add((TextView) inflate.findViewById(R.id.button2));
            arrayList.add(inflate.findViewById(R.id.fl_button_bg4));
            arrayList2.add((TextView) inflate.findViewById(R.id.button4));
            ArrayList arrayList3 = new ArrayList();
            ArrayList arrayList4 = new ArrayList();
            getRecommendedPlayers(str, arrayList3, arrayList4);
            for (int i = 0; i < arrayList3.size(); i++) {
                ((View) arrayList.get(i)).setVisibility(0);
                ((TextView) arrayList2.get(i)).setText((CharSequence) arrayList3.get(i));
                final String str2 = (String) arrayList4.get(i);
                ((TextView) arrayList2.get(i)).setOnClickListener(new View.OnClickListener() {
                    @Override
                    public void onClick(View view) {
                        VideoLogic.openLink(str2, activity);
                    }
                });
            }
            AlertDialog create = new AlertDialog.Builder(activity).setView(inflate).setPositiveButton(R.string.close, (DialogInterface.OnClickListener) null).create();
            create.setCanceledOnTouchOutside(true);
            create.show();
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th);
        }
    }

    public static void showInstructionsOnUiThread(final Activity activity, String str) {
        final String videoTypeForFlurry = getVideoTypeForFlurry(str);
        activity.runOnUiThread(new Runnable() {
            @Override
            public void run() {
                VideoLogic.showInstructions(activity, videoTypeForFlurry);
            }
        });
    }

    private static boolean videoInternal() {
        return PreferenceManager.getDefaultSharedPreferences(KApplication.current).getBoolean("video_internal", false);
    }

    private static String vimeoFix(String str) {
        try {
            Matcher matcher = Pattern.compile("vimeo\\.com/(\\d+)$").matcher(str);
            if (matcher.find()) {
                return "http://player.vimeo.com/video/" + matcher.group(1);
            }
        } catch (Throwable th) {
            th.printStackTrace();
            Helper.reportError(th);
        }
        return str;
    }
}