package com.rv.share;

import android.content.Intent;
import android.graphics.Color;
import android.os.Build;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.WindowManager;
import android.widget.Button;
import android.widget.ImageButton;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.ScrollView;
import android.widget.Toast;

import com.ruiwenliu.wrapper.base.BaseBean;
import com.ruiwenliu.wrapper.weight.TitleView;
import com.rv.component.utils.DisplayUtil;
import com.rv.home.rv.module.basic.BaseStatusActivity;
import com.rv.share.presenter.SharePresenter;
import com.rv.share.view.RvWebView;

import butterknife.BindView;
import butterknife.OnClick;

public class ShareActivity extends BaseStatusActivity<SharePresenter> {

    @BindView(R2.id.ll_webview_content)
    LinearLayout llWebViewContent;

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

    @Override
    protected void initView(Bundle savedInstanceState, TitleView titleView, Intent intent) {
        titleView.setTitle("邀请有礼");
        titleView.setImageResource(R.id.iv_title_right, R.drawable.tourism_rv_rentingcar_icon_share);
        titleView.setChildClickListener(R.id.iv_title_right, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                mPresenter.showShareDialog("https://xxtest.upyuns.com/h5/appHtml/view/download.html?userid=1234&test=xxxx", "测试", null);
            }
        });
//        titleView.setVisibility(View.GONE);
        RvWebView view = new RvWebView(getApplicationContext(), mListener);
        llWebViewContent.addView(view);
        view.loadUrl("https://xxtest.upyuns.com/h5/appHtml/view/invitationCourtesy.html");

    }

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        super.onTouchEvent(event);
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                break;

            case MotionEvent.ACTION_SCROLL:
                Log.e("xxxx", "ACTION_SCROLL");
                break;
        }
        return super.onTouchEvent(event);
    }

    @Override
    protected void loadData(Bundle savedInstanceState, Intent intent) {
        super.loadData(savedInstanceState, intent);
    }

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

    }

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

    private RvWebView.WebViewListener mListener = new RvWebView.WebViewListener() {

        @Override
        public void share(String url, String title, String des) {
            mPresenter.showShareDialog(url, title, des);
        }

        @Override
        public void shareBill() {
            startActivity(new Intent(getApplicationContext(), BillActivity.class));
        }

        @Override
        public void finish() {
            ShareActivity.this.finish();
        }
    };
}
