package com.jachdev.consumerprotection;

import android.app.Application;

import com.jachdev.consumerprotection.network.AppService;

/**
 * Created by prabuddhaon 9/20/2021.
 */
public class AppApplication extends Application {

    public static volatile AppApplication mApplication;
    private AppService mAppService;
    private AppService mBotService;
    private AppService mCatService;

    @Override
    public void onCreate() {
        super.onCreate();

        mApplication = this;

        mAppService = AppService.getInstance();
        mBotService = AppService.getBotInstance();
        mCatService = AppService.getCalInstance();
    }

    /**
     * this is Singleton class
     * @return : application class
     */
    public static AppApplication getInstance() {
        //Double check locking pattern
        if (mApplication == null) { //Check for the first time
            synchronized (AppApplication.class) {   //Check for the second time.
                //if there is no instance available... create new one
                if (mApplication == null)
                    mApplication = new AppApplication();
            }
        }
        return mApplication;
    }

    public AppService getAppService() {
        return mAppService;
    }

    public AppService getBotService() {
        return mBotService;
    }

    public AppService getCalService() {
        return mCatService;
    }
}
