package basic.taobaotv.present;

import android.graphics.Bitmap;
import android.text.TextUtils;
import android.webkit.WebView;
import android.webkit.WebViewClient;

import basic.taobaotv.config.TaobaotvConfig;
import basic.taobaotv.view.ITaobaoTvView;

/**
 * Created by fanwang on 10/8/16.
 */
public class WasuTaobaoTVClient extends WebViewClient implements ITaobaoTvPresent{

    private ITaobaoTvView iTaobaoTvView = null;

    public WasuTaobaoTVClient(ITaobaoTvView view){
        iTaobaoTvView = view;
    }

//    public void onPageStarted(WebView view, String url, Bitmap favicon){
//
//        //注意，下面的判断就是意图分析
//        if (TextUtils.equals(url, TaobaotvConfig.BACK_URL)) {
//            iTaobaoTvView.onBackUrl();
//        }
//    }


   //重写webclient，从而截获跳转的地址
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        //注意，下面的判断就是意图分析
        if (TextUtils.equals(url, TaobaotvConfig.BACK_URL)) {
            iTaobaoTvView.onBackUrl();

        return true;
    }

        return false;
    }

}

