package com.wisewoods.eduandroid.ui;

import android.content.Intent;
import android.os.Bundle;
import android.widget.LinearLayout;

import com.blankj.utilcode.util.ActivityUtils;
import com.blankj.utilcode.util.ColorUtils;
import com.just.agentweb.AgentWeb;
import com.wisewoods.base.base.BaseActivity;
import com.wisewoods.eduandroid.R;
import com.wisewoods.eduandroid.databinding.ActivityWebBinding;

public class WebActivity extends BaseActivity<ActivityWebBinding> {

    AgentWeb mAgentWeb;

    public static void start(String url, String title) {
        Intent intent = new Intent(ActivityUtils.getTopActivity(), WebActivity.class);
        intent.putExtra("url", url);
        intent.putExtra("title", title);
        ActivityUtils.startActivity(intent);
    }

    @Override
    protected void initData(Bundle savedInstanceState) {

        String url = getIntent().getStringExtra("url");
        String title = getIntent().getStringExtra("title");
        showBarBack(binding.bar.tvTitle, title, binding.bar.ivBack);

        mAgentWeb = AgentWeb.with(this)
                .setAgentWebParent(binding.llWeb, new LinearLayout.LayoutParams(-1, -1))
                .useDefaultIndicator(ColorUtils.getColor(R.color.theme))
                .createAgentWeb()
                .ready()
                .go(url);
    }


    @Override
    protected void onPause() {
        mAgentWeb.getWebLifeCycle().onPause();
        super.onPause();

    }

    @Override
    protected void onResume() {
        mAgentWeb.getWebLifeCycle().onResume();
        super.onResume();
    }

    @Override
    protected void onDestroy() {
        mAgentWeb.getWebLifeCycle().onDestroy();
        super.onDestroy();
    }

}
