package com.danding.yang800;

import android.support.v4.content.ContextCompat;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.widget.ImageView;
import android.widget.TextView;

import com.danding.yang800.Presenter.CourseActivityPresenter;
import com.danding.yang800.Util.StatusColorUtil;
import com.yanzhenjie.sofia.Sofia;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class CourseActivity extends AppCompatActivity {
    @BindView(R.id.course_backTv)
    TextView course_backTv;
    @BindView(R.id.course_webview)
    WebView course_webview;
    CourseActivityPresenter presenter;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        int type = StatusColorUtil.StatusBarLightMode(this);
//        if (type > 0) {
//            StatusColorUtil.setStatusBarColor(this, R.color.white);
//            StatusColorUtil.StatusBarLightMode(this, type);
//        }
        setContentView(R.layout.activity_course);
        Sofia.with(this).statusBarDarkFont().statusBarBackground(ContextCompat.getColor(this, R.color.white));
        ButterKnife.bind(this);
        initWeb();
        presenter = new CourseActivityPresenter(this);
        presenter.getInfo();
    }

    private void initWeb() {
        WebSettings wSet = course_webview.getSettings();
        wSet.setJavaScriptEnabled(true);
        wSet.setUseWideViewPort(true);
        wSet.setLoadWithOverviewMode(true);

    }

    @OnClick({R.id.course_backTv})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.course_backTv:
                finish();
                break;

        }
    }

    public void update(String result) {
        course_webview.loadUrl(result);
    }
}
