/*
 * COPYRIGHT (c) 2018 All rights reserved by HANWHA LIFE.
 */
package kr.co.zumo.app.lifeplus.view.dialog;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebView;

import kr.co.zumo.app.R;
import kr.co.zumo.app.lifeplus.util.StringUtil;

/**
 * WebDialog
 * <pre>
 * </pre>
 *
 * @author 민효동
 * @version 1.0
 * @history 민효동   [2018. 9. 18.]   [최초 작성]
 * @since 2018. 9. 18.
 */
public class WebDialog extends DialogBase {

  private String url;
  private WebView webView;

  @Override
  public void onCreate(Bundle savedInstanceState) {
    setStyle(DialogFragment.STYLE_NO_TITLE, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    setStyle(DialogFragment.STYLE_NO_FRAME, android.R.style.Theme_Translucent_NoTitleBar_Fullscreen);
    super.onCreate(savedInstanceState);
  }

  @Override
  public void onDestroyView() {
    super.onDestroyView();
  }

  /**
   * 표시할 url 지정
   * 
   * @param url
   */
  public void setUrl(String url) {
    this.url = url;

    render();
  }

  private void render() {
    if (null != webView && StringUtil.isFull(url)) {
      webView.loadUrl(url);
    }
  }

  @Nullable
  @Override
  public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
    return inflater.inflate(R.layout.web_dialog, container, false);
  }

  @Override
  public void onActivityCreated(Bundle savedInstanceState) {
    super.onActivityCreated(savedInstanceState);

    webView = getView().findViewById(R.id.web_view);

    render();

  }

  @Override
  public void setEnabled() {

  }

  @Override
  public void setDisabled() {

  }

  @Override
  public void restart() {

  }
}
