/**
  * Copyright 2017 JessYan
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
  *      http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
package com.jess.arms.di.module;

import android.app.Application;
import android.content.Context;
import android.support.annotation.Nullable;
import android.support.v4.app.FragmentManager;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;
import com.jess.arms.integration.ActivityLifecycle;
import com.jess.arms.integration.FragmentLifecycle;
import com.jess.arms.integration.IRepositoryManager;
import com.jess.arms.integration.RepositoryManager;
import com.jess.arms.integration.cache.Cache;
import com.jess.arms.integration.cache.CacheType;
import com.jess.arms.integration.lifecycle.ActivityLifecycleForRxLifecycle;

import java.util.ArrayList;
import java.util.List;

import javax.inject.Named;
import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;

/**
 * ================================================
 * 提供一些框架必须的实例的 {@link Module}
 * <p>
 * Created by JessYan on 8/4/2016.
 * <a href="mailto:jess.yan.effort@gmail.com">Contact me</a>
 * <a href="https://github.com/JessYanCoding">Follow me</a>
 * ================================================
 */
@Module
public class AppModule {

    @Singleton
    @Provides
    public Gson provideGson(Application application, @Nullable GsonConfiguration configuration) {
        GsonBuilder builder = new GsonBuilder();
        if (configuration != null)
            configuration.configGson(application, builder);
        return builder.create();
    }

    @Singleton
    @Provides
    public IRepositoryManager provideRepositoryManager(RepositoryManager repositoryManager) {
        return repositoryManager;
    }

    @Singleton
    @Provides
    public Cache<String, Object> provideExtras(Cache.Factory cacheFactory) {
        return cacheFactory.build(CacheType.EXTRAS);
    }

    @Singleton
    @Provides
    @Named("ActivityLifecycle")
    public Application.ActivityLifecycleCallbacks provideActivityLifecycle(ActivityLifecycle activityLifecycle) {
        return activityLifecycle;
    }

    @Singleton
    @Provides
    @Named("ActivityLifecycleForRxLifecycle")
    public Application.ActivityLifecycleCallbacks proviceActivityLifecycleForRxLifecycle(ActivityLifecycleForRxLifecycle activityLifecycleForRxLifecycle) {
        return activityLifecycleForRxLifecycle;
    }

    @Singleton
    @Provides
    public FragmentManager.FragmentLifecycleCallbacks provideFragmentLifecycle(FragmentLifecycle fragmentLifecycle) {
        return fragmentLifecycle;
    }

    @Singleton
    @Provides
    public List<FragmentManager.FragmentLifecycleCallbacks> provideFragmentLifecycles(){
        return new ArrayList<>();
    }

    public interface GsonConfiguration {
        void configGson(Context context, GsonBuilder builder);
    }

}

@@ -1348,16 +1348,37 @@
 leton;%0A%0A
+import dagger.Binds;%0A
 import d
@@ -1737,16 +1737,25 @@
 %0Apublic 
+abstract 
 class Ap
@@ -1805,16 +1805,23 @@
  public 
+static 
 Gson pro
@@ -2092,42 +2092,26 @@
    @
-Singleton%0A    @Provides%0A    public
+Binds%0A    abstract
  IRe
@@ -2126,23 +2126,20 @@
 Manager 
-provide
+bind
 Reposito
@@ -2188,50 +2188,9 @@
 ger)
- %7B%0A        return repositoryManager;%0A    %7D
+;
 %0A%0A  
@@ -2227,16 +2227,23 @@
  public 
+static 
 Cache%3CSt
@@ -2365,38 +2365,20 @@
 %7D%0A%0A    @
-Singleton%0A    @Provide
+Bind
 s%0A    @N
@@ -2399,38 +2399,40 @@
 Lifecycle%22)%0A    
-public
+abstract
  Application.Act
@@ -2455,23 +2455,20 @@
 llbacks 
-provide
+bind
 Activity
@@ -2517,79 +2517,20 @@
 cle)
- %7B%0A        return activityLifecycle;%0A    %7D
+;
 %0A%0A    @
-Singleton%0A    @Provide
+Bind
 s%0A  
@@ -2577,22 +2577,24 @@
 e%22)%0A    
-public
+abstract
  Applica
@@ -2629,15 +2629,12 @@
 cks 
-provice
+bind
 Acti
@@ -2729,105 +2729,34 @@
 cle)
- %7B%0A        return activityLifecycleForRxLifecycle;%0A    %7D
+;
 %0A%0A    @
-Singleton%0A    @Provides%0A    public
+Binds%0A    abstract
  Fra
@@ -2795,23 +2795,20 @@
 llbacks 
-provide
+bind
 Fragment
@@ -2857,50 +2857,9 @@
 cle)
- %7B%0A        return fragmentLifecycle;%0A    %7D
+;
 %0A%0A  
@@ -2896,16 +2896,23 @@
  public 
+static 
 List%3CFra
@@ -3132,11 +3132,10 @@
 ;%0A    %7D%0A
-%0A
 %7D%0A

Add @Binds on AppModule