package com.example.jingbin.cloudreader.view.webview;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.text.TextUtils;

import com.example.jingbin.cloudreader.utils.DebugUtil;

/**
 * @author jingbin
 */
public class WebUtil {

    public static void startActivity(Activity activity, String url) {
        try {
            Intent intent1 = new Intent();
            intent1.setAction("android.intent.action.VIEW");
            Uri uri = Uri.parse(url);
            intent1.setData(uri);
            intent1.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            activity.startActivity(intent1);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    /**
     * 处理三方链接
     * 屏蔽网页里的广告
     * 简书“jianshu.com”
     **/
    public static boolean handleThirdApp(Activity activity, String originalUrl, String backUrl) {
        DebugUtil.error("----backUrl:  " + backUrl);
        boolean isJump = true;
        if (!TextUtils.isEmpty(originalUrl)) {
            if (backUrl.startsWith("openapp.jdmobile:")// 京东
                    || backUrl.startsWith("zhihu:")// 知乎
                    || backUrl.startsWith("tbopen:")// 淘宝
                    || backUrl.startsWith("vipshop:")//
                    || backUrl.startsWith("youku:")//
                    || backUrl.startsWith("uclink:")// UC
                    || backUrl.startsWith("ucbrowser:")// UC
                    || backUrl.startsWith("alipay:")// 支付宝
                    || backUrl.startsWith("newsapp:")//
                    || backUrl.startsWith("sinaweibo:")// 新浪
                    || backUrl.startsWith("suning:")//
            ) {
                isJump = false;
            }
        }
        if (isJump) {
            startActivity(activity, backUrl);
        }
        return isJump;
    }
}

@@ -933,32 +933,301 @@
   %22 + backUrl);%0A
+%0A        /**http%E5%BC%80%E5%A4%B4%E7%9B%B4%E6%8E%A5%E8%B7%B3%E8%BF%87*/%0A        if (backUrl.startsWith(%22http%22)) %7B%0A            // %E5%8F%AF%E8%83%BD%E6%9C%89%E6%8F%90%E7%A4%BA%E4%B8%8B%E8%BD%BDApk%E6%96%87%E4%BB%B6%0A            if (backUrl.contains(%22.apk%22)) %7B%0A                startActivity(activity, backUrl);%0A                return true;%0A            %7D%0A            return false;%0A        %7D%0A%0A
         boolean 
@@ -1569,24 +1569,26 @@
 (%22youku:%22)//
+%E4%BC%98%E9%85%B7
 %0A           

update 屏蔽网页里的广告