package com.rv.share;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.base.BaseStatusActivity;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.share.presenter.BillPresenter;
import com.rv.share.view.RvWebView;

import butterknife.BindView;
import butterknife.OnClick;

/********
 *
 * 海报界面
 * created by john
 */
public class BillActivity extends BaseStatusActivity<BillPresenter> {

    @BindView(R2.id.tv_back_title)
    TextView tvBackTitle;
    @BindView(R2.id.btn_share)
    Button btnShare;
    @BindView(R2.id.ll_webview)
    LinearLayout llWebView;

    private String url;


    public static Intent getIntent(Context var1, String var2) {
        Intent intent = new Intent(var1, BillActivity.class);
        intent.putExtra("billUrl", var2);
        return intent;
    }


    @Override
    protected int setLayout() {
        return R.layout.activity_bill;
    }


    @Override
    protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {

        url = intent.getStringExtra("billUrl");
        titleView.setVisibility(View.GONE);

        RvWebView view = new RvWebView(getApplicationContext(), listener);
        llWebView.addView(view);
        view.loadUrl("https://www.baidu.com");

//        llLongClick.setOnLongClickListener(new View.OnLongClickListener() {
//            @Override
//            public boolean onLongClick(View view) {
//                mPresenter.showShareDialog(llBillContent);
//                return false;
//            }
//        });

//        Bitmap success = ZxingUtils.createQRImage(testUrl, DisplayUtil.dip2px(this, 80f), DisplayUtil.dip2px(this, 80f),
//                BitmapFactory.decodeResource(getResources(), com.rv.home.R.mipmap.ic_launcher));
//        imgZxing.setImageBitmap(success);
    }

    @Override
    protected void loadData(Bundle savedInstanceState, Intent intent) {

    }

    @Override
    public void onShowResult(int requestType, BaseBean result) {

    }

    @Override
    public void onDestroy() {
        llWebView.removeAllViews();
        super.onDestroy();
    }

    @OnClick({R2.id.tv_back_title, R2.id.btn_share})
    public void onViewClicked(View view) {
        int id = view.getId();
        if (id == R.id.tv_back_title) {
            finish();
        } else if (id == R.id.btn_share) {
            mPresenter.showShareDialog(llWebView);
        }
    }

    private RvWebView.WebViewListener listener = new RvWebView.WebViewListener() {
        @Override
        public void share(String url, String title, String desc) {

        }

        @Override
        public void shareBill() {
            mPresenter.showShareDialog(llWebView);
        }

        @Override
        public void finish() {

        }
    };


}
