ServiceManager.java 965 字节
Newer Older
J
jessyan 已提交
1 2
package me.jessyan.mvparms.demo.mvp.model.api.service;

J
jessyan 已提交
3 4 5 6 7
import com.jess.arms.http.BaseServiceManager;

import javax.inject.Inject;
import javax.inject.Singleton;

J
jessyan 已提交
8 9 10 11
/**
 * Created by jess on 8/5/16 13:01
 * contact with jess.yan.effort@gmail.com
 */
J
jessyan 已提交
12
@Singleton
J
jessyan 已提交
13
public class ServiceManager implements BaseServiceManager {
J
jessyan 已提交
14 15
    private CommonService mCommonService;

J
jessyan 已提交
16 17 18 19 20
    /**
     * 如果需要添加service只需在构造方法中添加对应的service,在提供get方法返回出去,只要在ServiceModule提供了该service
     * Dagger2会自行注入
     * @param commonService
     */
J
jessyan 已提交
21
    @Inject public ServiceManager(CommonService commonService){
J
jessyan 已提交
22 23 24 25 26 27
        this.mCommonService = commonService;
    }

    public CommonService getCommonService() {
        return mCommonService;
    }
J
jessyan 已提交
28 29 30 31 32 33 34 35

    /**
     * 这里可以释放一些资源(注意这里是单例,即不需要在activity的生命周期调用)
     */
    @Override
    public void onDestory() {

    }
J
jessyan 已提交
36
}