package com.ydl.component.service.web;


import android.app.Activity;
import android.content.Intent;

import com.alibaba.android.arouter.launcher.ARouter;
import com.ydl.confide.api.IConfideService;
import com.ydl.webview.H5JsBean;
import com.ydl.webview.H5Params;
import com.ydl.webview.NewH5Activity;
import com.ydl.ydlcommon.modular.ModularServiceManager;
import com.yidianling.common.tools.LogUtil;
import com.yidianling.im.api.service.IImService;

/**
 * webview 点击事件监听 抽象类
 * Created by harvie on 2017/7/4 0004.
 */
public class WVClickAbstractListener implements WebViewClientClickListener {

    public Activity mContext;

    public WVClickAbstractListener(Activity activity) {
        this.mContext = activity;
    }

    @Override
    public void openH5(H5JsBean.H5JsCmd.Params jsData) {
        LogUtil.d("openH5 params: " + jsData.toString());
        H5Params h5Params = new H5Params(jsData.getUrl(), null);
        h5Params.setShareData(jsData.getShare());
        h5Params.setShowMenu(jsData.getDot_flag());
        NewH5Activity.start(mContext, h5Params);
    }

    @Override
    public void courseList() {

    }

    @Override
    public void activeDetail(String id) {

    }

    @Override
    public void contactYi() {

    }

    @Override
    public void contactCourseCustomerService() {

    }

    @Override
    public void openTopicDetail(String topic_id) {

    }

    @Override
    public void openMember(String id) {

    }

    @Override
    public void sendTrend() {

    }

    @Override
    public void sendResultTrend(String cover1, String title1, String purl1, String share_url1) {

    }

    @Override
    public void sendInfo(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void searchList(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void openExpertsHome(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void openTest(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void chat(int id, int toUid, int canTalk, String accessToken, int isFromQingShu) {

    }

    @Override
    public void chatSendMessage(int id, int toUid, int canTalk, String accessToken, int isFromQingShu) {

    }

    @Override
    public void chatTeam(int tid, int doctorId) {

    }

    @Override
    public void jumpLogin(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void openFmDetail(int id) {

    }

    @Override
    public void openArticle() {

    }

    @Override
    public void openFmList() {

    }

    @Override
    public void sendSubscriptionTimeMessage(String to_uid) {

    }

    @Override
    public void pay(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void payReceipt(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void payCourse(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void payTest(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void viewTestResult(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void ydlNative(H5JsBean.H5JsCmd jsData) {

    }

    @Override
    public void openOrderDetail(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void expertProduct(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void order(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void toOrderCt(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void showDocList(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void goodExpert() {

    }

    @Override
    public void copyWechat(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void goWechat() {

    }

    @Override
    public void listenOrderDetail(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void detailSub(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void openAgreement(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void modifyEval(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void visitEval(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void coursePlay(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void closeFloatView() {

    }

    @Override
    public void courseWriteComment(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void courseComment(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void listenTel(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void voiceBroadcast(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void tel(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void onOrderByApp(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void orderSetTime(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void searchServiceDoc(int cateId) {

    }

    @Override
    public void openTestDetail(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void shareAction(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void openTestList() {

    }

    @Override
    public void feedBack() {

    }

    @Override
    public void phoneCall() {

    }

    @Override
    public void chatSchedule(H5JsBean.H5JsCmd.Params params) {
        ModularServiceManager.INSTANCE.provide(IImService.class)
                .chatScheule(mContext, params.getUser_url(), params.getDoc_url(), params.getDsmId(), params.getTitle(), params.getToUid());
    }

    @Override
    public void invite(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void balance(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void switchDownRefresh(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void recharge() {

    }

    @Override
    public void bindPhone() {

    }

    @Override
    public void refresh() {

    }

    @Override
    public void listenAgora(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void setTitle(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void saveImage(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void sendToExpert(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void confideConnect(H5JsBean.H5JsCmd.Params jsData) {
        ((IConfideService) ARouter.getInstance().build("/confide/ConfideService").navigation()).connectionJava(jsData.getId(), 3, mContext, null, jsData.getCallType());
    }

    @Override
    public void confidePay(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void back() {

    }

    @Override
    public void commonPay(H5JsBean.H5JsCmd.Params jsData) {

    }

    @Override
    public void hideStatusBar() {

    }

    @Override
    public void showStatusBar() {

    }

    @Override
    public void openRightTopMenu() {
        if (mContext instanceof NewH5Activity) {
            ((NewH5Activity) mContext).openRightTopMenu();
        }
    }

    @Override
    public void openShareMenu(H5JsBean.H5JsCmd.Params params) {
        if (mContext instanceof NewH5Activity) {
            ((NewH5Activity) mContext).openShareMenu(params);
        }
    }

    @Override
    public void closeWebKit() {
        if (mContext instanceof NewH5Activity) {
            ((NewH5Activity) mContext).finish();
        }
    }

    @Override
    public void goHome(H5JsBean.H5JsCmd.Params params) {

    }

    @Override
    public void sendUnReadNum(String callbackFuncName, String uid) {

        final StringBuffer sb = new StringBuffer();
        sb.append(callbackFuncName);
        sb.append("('");
        sb.append("33,125");
        sb.append("')");
        if (mContext instanceof NewH5Activity) {
            ((NewH5Activity) mContext).callJSFunc(sb.toString());
        }


    }

    @Override
    public void shouldShowTitleBar(boolean isShowTitleBar) {
        if (mContext instanceof NewH5Activity) {
            if (isShowTitleBar) {
                ((NewH5Activity) mContext).showTitleBar();
            } else {
                ((NewH5Activity) mContext).hideJavaTitleBar();
            }
        }
    }

    @Override
    public void setSelfPageType(int selfType) {
        if (mContext instanceof NewH5Activity) {
            ((NewH5Activity) mContext).setSelfPageType(selfType);
        }
    }

    @Override
    public void playMeditation(int mediaId, long meditationId, int meditationType, String mediaCoverUrl) {

        if (mContext instanceof NewH5Activity) {
            ARouter.getInstance().build("/muse/play")
                    .withLong("MEDITATION_ID", meditationId)
                    .withLong("MEDIA_ID", mediaId)
                    .withInt("MEDITATION_TYPE", meditationType)
                    .withString("MEDIA_COVER_URL", mediaCoverUrl)
                    .navigation();
        }
    }

    @Override
    public void switchSound(int mediaId, long meditationId, int meditationType, int businessType,
                            String buried, String mediaUrl, String mediaCoverUrl,
                            String title, String desc, int status) {
        if (mContext instanceof NewH5Activity) {
            ((NewH5Activity) mContext).switchSound(mediaId, meditationId, meditationType,
                    businessType, buried, mediaUrl, mediaCoverUrl, title, desc, status);
        }
    }
}
