// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java
// public class DelegateClassGenerator extends ClassGenerator {
//     private final ClassName viewClass;
//     private ClassName presenterClass;
//     private ViewType viewType;
//     private int resourceID = -1;
//     private String presenterFieldNameInView = "";
//     private String presenterViewQualifiedName;
//     private boolean injectablePresenterInView = false;
//     private ClassName presenterTypeInView;
//     private BaseDecorator decorator;
// 
//     private String presenterId = "";
// 
//     public String getPresenterId() {
//         return presenterId;
//     }
// 
//     public DelegateClassGenerator(String packageName, String className, ClassName viewClass) {
//         super(packageName, className);
//         this.viewClass = viewClass;
//     }
// 
//     public ClassName getViewClass() {
//         return viewClass;
//     }
// 
//     public String getPresenterViewQualifiedName() {
//         return presenterViewQualifiedName;
//     }
// 
//     public void setPresenterViewQualifiedName(String presenterViewQualifiedName) {
//         this.presenterViewQualifiedName = presenterViewQualifiedName;
//     }
// 
//     public void setViewType(ViewType viewType) {
//         this.viewType = viewType;
//         switch (viewType) {
//             case ACTIVITY:
//                 decorator = new ActivityDecorator(this);
//                 break;
//             case SUPPORT_ACTIVITY:
//                 decorator = new SupportActivityDecorator(this);
//                 break;
//             case FRAGMENT:
//                 decorator = new FragmentDecorator(this);
//                 break;
//             case SUPPORT_FRAGMENT:
//                 decorator = new SupportFragmentDecorator(this);
//                 break;
//             case CUSTOM_VIEW:
//                 decorator = new CustomViewDecorator(this);
//                 break;
//             case CONDUCTOR_CONTROLLER:
//                 decorator = new ConductorControllerDecorator(this);
//                 break;
//         }
//     }
// 
//     public void setResourceID(int resourceID) {
//         this.resourceID = resourceID;
//     }
// 
//     public void setPresenter(ClassName presenter) {
//         this.presenterClass = presenter;
//     }
// 
//     public void setViewPresenterField(String fieldName) {
//         presenterFieldNameInView = fieldName;
//     }
// 
//     @Override
//     public JavaFile build() {
//         TypeSpec.Builder result =
//                 TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC)
//                         .addSuperinterface(
//                                 ParameterizedTypeName.get(VIEW_DELEGATE, viewClass,
//                                                           getPresenterFactoryTypeName()));
//         decorator.build(result);
//         return JavaFile.builder(getPackageName(), result.build())
//                 .addFileComment("Generated class from EasyMVP. Do not modify!").build();
//     }
// 
// 
//     public void injectablePresenterInView(boolean injectable) {
//         this.injectablePresenterInView = injectable;
//     }
// 
//     private TypeName getPresenterFactoryTypeName() {
//         return ParameterizedTypeName.get(PROVIDER, presenterClass);
//     }
// 
//     public ClassName getPresenterClass() {
//         return presenterClass;
//     }
// 
//     public boolean isInjectablePresenterInView() {
//         return injectablePresenterInView;
//     }
// 
//     public ClassName getPresenterTypeInView() {
//         return presenterTypeInView;
//     }
// 
//     public void setPresenterTypeInView(String presenterTypeInView) {
//         this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView);
//     }
// 
//     public String getPresenterFieldNameInView() {
//         return presenterFieldNameInView;
//     }
// 
//     public int getResourceID() {
//         return resourceID;
//     }
// 
//     public void setPresenterId(String presenterId) {
//         this.presenterId = presenterId;
//     }
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// static ClassName getLoader(boolean supportLibrary) {
//     return get(supportLibrary, SUPPORT_LOADER, LOADER);
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// public static ClassName getLoaderCallbacks() {
//     return LOADER_CALLBACKS;
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// public static ClassName getLoaderManager() {
//     return LOADER_MANAGER;
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// public static ClassName getPresenterLoader() {
//     return PRESENTER_LOADER;
// }


import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import easymvp.compiler.generator.DelegateClassGenerator;
import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader;
import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks;
import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager;
import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;
package easymvp.compiler.generator.decorator;




/**
 * @author Saeed Masoumi (saeed@6thsolution.com)
 */
public class FragmentDecorator extends BaseDecorator {

    public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) {
        super(delegateClassGenerator);
    }

    @Override
    public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) {
        return methodSignature.addStatement("return view.getLoaderManager()")
                .returns(getLoaderManager())
                .build();
    }

    @Override
    public String createContextField(String viewField) {
        return "final $T context = " + viewField + ".getActivity().getApplicationContext()";
    }

    @Override
    protected void implementInitializer(MethodSpec.Builder method) {

    }

    @Override
    protected ClassName getPresenterLoaderClass() {
        return getPresenterLoader();
    }

    @Override
    protected ClassName getLoaderCallbacksClass() {
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/DelegateClassGenerator.java
// public class DelegateClassGenerator extends ClassGenerator {
//     private final ClassName viewClass;
//     private ClassName presenterClass;
//     private ViewType viewType;
//     private int resourceID = -1;
//     private String presenterFieldNameInView = "";
//     private String presenterViewQualifiedName;
//     private boolean injectablePresenterInView = false;
//     private ClassName presenterTypeInView;
//     private BaseDecorator decorator;
// 
//     private String presenterId = "";
// 
//     public String getPresenterId() {
//         return presenterId;
//     }
// 
//     public DelegateClassGenerator(String packageName, String className, ClassName viewClass) {
//         super(packageName, className);
//         this.viewClass = viewClass;
//     }
// 
//     public ClassName getViewClass() {
//         return viewClass;
//     }
// 
//     public String getPresenterViewQualifiedName() {
//         return presenterViewQualifiedName;
//     }
// 
//     public void setPresenterViewQualifiedName(String presenterViewQualifiedName) {
//         this.presenterViewQualifiedName = presenterViewQualifiedName;
//     }
// 
//     public void setViewType(ViewType viewType) {
//         this.viewType = viewType;
//         switch (viewType) {
//             case ACTIVITY:
//                 decorator = new ActivityDecorator(this);
//                 break;
//             case SUPPORT_ACTIVITY:
//                 decorator = new SupportActivityDecorator(this);
//                 break;
//             case FRAGMENT:
//                 decorator = new FragmentDecorator(this);
//                 break;
//             case SUPPORT_FRAGMENT:
//                 decorator = new SupportFragmentDecorator(this);
//                 break;
//             case CUSTOM_VIEW:
//                 decorator = new CustomViewDecorator(this);
//                 break;
//             case CONDUCTOR_CONTROLLER:
//                 decorator = new ConductorControllerDecorator(this);
//                 break;
//         }
//     }
// 
//     public void setResourceID(int resourceID) {
//         this.resourceID = resourceID;
//     }
// 
//     public void setPresenter(ClassName presenter) {
//         this.presenterClass = presenter;
//     }
// 
//     public void setViewPresenterField(String fieldName) {
//         presenterFieldNameInView = fieldName;
//     }
// 
//     @Override
//     public JavaFile build() {
//         TypeSpec.Builder result =
//                 TypeSpec.classBuilder(getClassName()).addModifiers(Modifier.PUBLIC)
//                         .addSuperinterface(
//                                 ParameterizedTypeName.get(VIEW_DELEGATE, viewClass,
//                                                           getPresenterFactoryTypeName()));
//         decorator.build(result);
//         return JavaFile.builder(getPackageName(), result.build())
//                 .addFileComment("Generated class from EasyMVP. Do not modify!").build();
//     }
// 
// 
//     public void injectablePresenterInView(boolean injectable) {
//         this.injectablePresenterInView = injectable;
//     }
// 
//     private TypeName getPresenterFactoryTypeName() {
//         return ParameterizedTypeName.get(PROVIDER, presenterClass);
//     }
// 
//     public ClassName getPresenterClass() {
//         return presenterClass;
//     }
// 
//     public boolean isInjectablePresenterInView() {
//         return injectablePresenterInView;
//     }
// 
//     public ClassName getPresenterTypeInView() {
//         return presenterTypeInView;
//     }
// 
//     public void setPresenterTypeInView(String presenterTypeInView) {
//         this.presenterTypeInView = ClassName.bestGuess(presenterTypeInView);
//     }
// 
//     public String getPresenterFieldNameInView() {
//         return presenterFieldNameInView;
//     }
// 
//     public int getResourceID() {
//         return resourceID;
//     }
// 
//     public void setPresenterId(String presenterId) {
//         this.presenterId = presenterId;
//     }
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// static ClassName getLoader(boolean supportLibrary) {
//     return get(supportLibrary, SUPPORT_LOADER, LOADER);
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// public static ClassName getLoaderCallbacks() {
//     return LOADER_CALLBACKS;
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// public static ClassName getLoaderManager() {
//     return LOADER_MANAGER;
// }
// 
// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/AndroidLoaderUtils.java
// public static ClassName getPresenterLoader() {
//     return PRESENTER_LOADER;
// }


// Path: easymvp-compiler/src/main/java/easymvp/compiler/generator/decorator/FragmentDecorator.java
import com.squareup.javapoet.ClassName;
import com.squareup.javapoet.MethodSpec;
import easymvp.compiler.generator.DelegateClassGenerator;
import static easymvp.compiler.generator.AndroidLoaderUtils.getLoader;
import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderCallbacks;
import static easymvp.compiler.generator.AndroidLoaderUtils.getLoaderManager;
import static easymvp.compiler.generator.AndroidLoaderUtils.getPresenterLoader;

package easymvp.compiler.generator.decorator;




/**
 * @author Saeed Masoumi (saeed@6thsolution.com)
 */
public class FragmentDecorator extends BaseDecorator {

    public FragmentDecorator(DelegateClassGenerator delegateClassGenerator) {
        super(delegateClassGenerator);
    }

    @Override
    public MethodSpec getLoaderManagerMethod(MethodSpec.Builder methodSignature) {
        return methodSignature.addStatement("return view.getLoaderManager()")
                .returns(getLoaderManager())
                .build();
    }

    @Override
    public String createContextField(String viewField) {
        return "final $T context = " + viewField + ".getActivity().getApplicationContext()";
    }

    @Override
    protected void implementInitializer(MethodSpec.Builder method) {

    }

    @Override
    protected ClassName getPresenterLoaderClass() {
        return getPresenterLoader();
    }

    @Override
    protected ClassName getLoaderCallbacksClass() {
        return getLoaderCallbacks();