package com.qimai.yttgrass.view;

import android.app.Activity;
import android.view.ViewGroup;
import android.webkit.JavascriptInterface;
import android.webkit.WebView;
import android.widget.LinearLayout;


public class BaseFunc {

    Activity mActivity;
    WebView webView;

    public BaseFunc(Activity mActivity, WebView webView) {
        this.mActivity = mActivity;

        this.webView = webView;
    }

//注册一个重新计算高度的方法

    @JavascriptInterface
    public void resize(final float height) {
        mActivity.runOnUiThread(new Runnable() {
            @Override

            public void run() {
                webView.setLayoutParams(new LinearLayout.LayoutParams(mActivity.getResources().getDisplayMetrics().widthPixels, (int) (height * mActivity.getResources().getDisplayMetrics().density)+20));
                webView.requestLayout();
                webView.invalidate();

            }
        });
    }
}

