package com.dlc.exam.ui.widget;

import android.webkit.JavascriptInterface;

import org.greenrobot.eventbus.EventBus;

public class JsInterface {

    public final static class JsEvent {
        public static class Office {
            public static final String DOC = "office_doc";
            public static final String PPT = "office_ppt";
            public static final String PDF = "office_pdf";
            public static final String EXCEL = "office_excel";
        }

        public final static class Pic {
            public static final String PIC = "big_pic";
        }

        public final static class Doc {
            public static final String DOC = "doc_text";
        }
    }


    @JavascriptInterface
    public void webCallBack(String tag, String data) {
        MessageEvent messageEvent = new MessageEvent(tag, data);
        switch (messageEvent.getTag()) {
            // 大图
            case JsInterface.JsEvent.Pic.PIC:
                messageEvent.setResult("预览完成".equals(data));
                break;
            // 富文本
            case JsInterface.JsEvent.Doc.DOC:
                break;
            // word
            case JsInterface.JsEvent.Office.DOC:
                messageEvent.setResult("预览完成".equals(data));
                break;
            // excel
            case JsInterface.JsEvent.Office.EXCEL:
                messageEvent.setResult("预览完成".equals(data));
                break;
            // pdf
            case JsInterface.JsEvent.Office.PDF:
                messageEvent.setResult("预览完成".equals(data));
                break;
            // ppt
            case JsInterface.JsEvent.Office.PPT:
                break;
        }
        EventBus.getDefault().post(messageEvent);
    }

}
