// Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
// 
//     private RefWatcher refWatcher;
// 
//     ApplicationComponent mApplicationComponent;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         refWatcher = LeakCanary.install(this);
// 
//         if (BuildConfig.DEBUG) {
//             //警告在主线程中执行耗时操作
//             StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
//             StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
// 
//             Timber.plant(new Timber.DebugTree());
//         }
// 
//     }
// 
//     public static GankApp get(Context context) {
//         return (GankApp) context.getApplicationContext();
//     }
// 
//     public static RefWatcher getRefWatcher(Context context) {
//         return ((GankApp) context.getApplicationContext()).refWatcher;
//     }
// 
//     public ApplicationComponent getComponent() {
//         if (mApplicationComponent == null) {
//             mApplicationComponent = DaggerApplicationComponent.builder()
//                     .applicationModule(new ApplicationModule(this))
//                     .build();
//         }
//         return mApplicationComponent;
//     }
// 
// 
// }
// 
// Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
//     private final Fragment mFragment;
// 
//     public FragmentModule(Fragment fragment) {
//         mFragment = fragment;
//     }
// 
//     @Provides
//     @com.yunq.gankio.injection.Fragment
//     Context provideContext() {
//         return mFragment.getActivity();
//     }
// }
// 
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
// public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
// 
// 
//     private static final String KEY_UTF_8 = "UTF-8";
// 
//     private Context mContext;
// 
//     @Inject
//     public CustomDialogPresenter(Context context) {
//         mContext = context;
//     }
// 
//     public AlertDialog makeDialog(Fragment fragment, View customView) {
// 
//         String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE);
//         String htmlFileName = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_HTML_FILE_NAME);
//         int accentColor = fragment.getArguments().getInt(CustomWebViewDialog.EXTRA_ACCENT_COLOR);
// 
//         final WebView webView = (WebView) customView.findViewById(R.id.webView);
//         webView.getSettings().setDefaultTextEncodingName(KEY_UTF_8);
//         loadData(webView, htmlFileName, accentColor);
// 
//         AlertDialog dialog = new AlertDialog.Builder(mContext)
//                 .setTitle(dialogTitle)
//                 .setView(customView)
//                 .setPositiveButton(android.R.string.ok, null)
//                 .show();
//         return dialog;
//     }
// 
//     private void loadData(WebView webView, String htmlFileName, int accentColor) {
//         try {
//             StringBuilder buf = new StringBuilder();
//             InputStream json = mContext.getAssets().open(htmlFileName);
//             BufferedReader in = new BufferedReader(new InputStreamReader(json, KEY_UTF_8));
//             String str;
//             while ((str = in.readLine()) != null)
//                 buf.append(str);
//             in.close();
// 
//             String formatLodString = buf.toString()
//                     .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
//                     .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
//                     .replace("{link-color-active}", colorToHex(accentColor));
//             webView.loadDataWithBaseURL(null, formatLodString, "text/html", KEY_UTF_8, null);
//         } catch (Throwable e) {
//             webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", KEY_UTF_8);
//         }
//     }
// 
//     private String colorToHex(int color) {
//         return Integer.toHexString(color).substring(2);
//     }
// 
//     private int shiftColor(int color, boolean up) {
//         float[] hsv = new float[3];
//         Color.colorToHSV(color, hsv);
//         hsv[2] *= (up ? 1.1f : 0.9f); // value component
//         return Color.HSVToColor(hsv);
//     }
// }
// 
// Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }


import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import com.yunq.gankio.injection.component.DaggerFragmentComponent;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.presenter.CustomDialogPresenter;
import com.yunq.gankio.presenter.view.ICustomDialog;
import javax.inject.Inject;
package com.yunq.gankio.ui.fragment;





/**
 * A simple {@link Fragment} subclass.
 */
public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {

    public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
    public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
    public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";

    @Inject
    CustomDialogPresenter mPresenter;
    @Inject
    Context mContext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initInjection();
    }

    private void initInjection() {
        DaggerFragmentComponent.builder()
// Path: app/src/main/java/com/yunq/gankio/GankApp.java
// public class GankApp extends Application {
// 
//     private RefWatcher refWatcher;
// 
//     ApplicationComponent mApplicationComponent;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         refWatcher = LeakCanary.install(this);
// 
//         if (BuildConfig.DEBUG) {
//             //警告在主线程中执行耗时操作
//             StrictMode.setThreadPolicy(new StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build());
//             StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build());
// 
//             Timber.plant(new Timber.DebugTree());
//         }
// 
//     }
// 
//     public static GankApp get(Context context) {
//         return (GankApp) context.getApplicationContext();
//     }
// 
//     public static RefWatcher getRefWatcher(Context context) {
//         return ((GankApp) context.getApplicationContext()).refWatcher;
//     }
// 
//     public ApplicationComponent getComponent() {
//         if (mApplicationComponent == null) {
//             mApplicationComponent = DaggerApplicationComponent.builder()
//                     .applicationModule(new ApplicationModule(this))
//                     .build();
//         }
//         return mApplicationComponent;
//     }
// 
// 
// }
// 
// Path: app/src/main/java/com/yunq/gankio/injection/module/FragmentModule.java
// @Module
// public class FragmentModule {
//     private final Fragment mFragment;
// 
//     public FragmentModule(Fragment fragment) {
//         mFragment = fragment;
//     }
// 
//     @Provides
//     @com.yunq.gankio.injection.Fragment
//     Context provideContext() {
//         return mFragment.getActivity();
//     }
// }
// 
// Path: app/src/main/java/com/yunq/gankio/presenter/CustomDialogPresenter.java
// public class CustomDialogPresenter extends BasePresenter<ICustomDialog> {
// 
// 
//     private static final String KEY_UTF_8 = "UTF-8";
// 
//     private Context mContext;
// 
//     @Inject
//     public CustomDialogPresenter(Context context) {
//         mContext = context;
//     }
// 
//     public AlertDialog makeDialog(Fragment fragment, View customView) {
// 
//         String dialogTitle = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_DIALOG_TITLE);
//         String htmlFileName = fragment.getArguments().getString(CustomWebViewDialog.EXTRA_HTML_FILE_NAME);
//         int accentColor = fragment.getArguments().getInt(CustomWebViewDialog.EXTRA_ACCENT_COLOR);
// 
//         final WebView webView = (WebView) customView.findViewById(R.id.webView);
//         webView.getSettings().setDefaultTextEncodingName(KEY_UTF_8);
//         loadData(webView, htmlFileName, accentColor);
// 
//         AlertDialog dialog = new AlertDialog.Builder(mContext)
//                 .setTitle(dialogTitle)
//                 .setView(customView)
//                 .setPositiveButton(android.R.string.ok, null)
//                 .show();
//         return dialog;
//     }
// 
//     private void loadData(WebView webView, String htmlFileName, int accentColor) {
//         try {
//             StringBuilder buf = new StringBuilder();
//             InputStream json = mContext.getAssets().open(htmlFileName);
//             BufferedReader in = new BufferedReader(new InputStreamReader(json, KEY_UTF_8));
//             String str;
//             while ((str = in.readLine()) != null)
//                 buf.append(str);
//             in.close();
// 
//             String formatLodString = buf.toString()
//                     .replace("{style-placeholder}", "body { background-color: #ffffff; color: #000; }")
//                     .replace("{link-color}", colorToHex(shiftColor(accentColor, true)))
//                     .replace("{link-color-active}", colorToHex(accentColor));
//             webView.loadDataWithBaseURL(null, formatLodString, "text/html", KEY_UTF_8, null);
//         } catch (Throwable e) {
//             webView.loadData("<h1>Unable to load</h1><p>" + e.getLocalizedMessage() + "</p>", "text/html", KEY_UTF_8);
//         }
//     }
// 
//     private String colorToHex(int color) {
//         return Integer.toHexString(color).substring(2);
//     }
// 
//     private int shiftColor(int color, boolean up) {
//         float[] hsv = new float[3];
//         Color.colorToHSV(color, hsv);
//         hsv[2] *= (up ? 1.1f : 0.9f); // value component
//         return Color.HSVToColor(hsv);
//     }
// }
// 
// Path: app/src/main/java/com/yunq/gankio/presenter/view/ICustomDialog.java
// public interface ICustomDialog extends IBaseView {
// }


// Path: app/src/main/java/com/yunq/gankio/ui/fragment/CustomWebViewDialog.java
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.Fragment;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import com.yunq.gankio.GankApp;
import com.yunq.gankio.R;
import com.yunq.gankio.injection.component.DaggerFragmentComponent;
import com.yunq.gankio.injection.module.FragmentModule;
import com.yunq.gankio.presenter.CustomDialogPresenter;
import com.yunq.gankio.presenter.view.ICustomDialog;
import javax.inject.Inject;

package com.yunq.gankio.ui.fragment;





/**
 * A simple {@link Fragment} subclass.
 */
public class CustomWebViewDialog extends DialogFragment implements ICustomDialog {

    public static final String EXTRA_DIALOG_TITLE = "DIALOG_TITLE";
    public static final String EXTRA_HTML_FILE_NAME = "HTML_FILE_NAME";
    public static final String EXTRA_ACCENT_COLOR = "ACCENT_COLOR";

    @Inject
    CustomDialogPresenter mPresenter;
    @Inject
    Context mContext;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        initInjection();
    }

    private void initInjection() {
        DaggerFragmentComponent.builder()
                .fragmentModule(new FragmentModule(this))