package com.yyrh.advertisement;

import android.app.Activity;
import android.app.Application;
import android.content.Context;

import com.yyrh.constant.RoleInfo;

import org.json.JSONObject;

import java.util.HashMap;


public class AdvertiseManager {

    private static AdvertiseManager manager = null;

    private Advertise advertise;

    private AdvertiseManager(Context context) {
        advertise = AdvertiseFactory.GetAdvertise(context);
    }

    public static AdvertiseManager defaultManager(Context context) {
        if (manager == null) {
            synchronized (AdvertiseManager.class) {
                if (manager == null) {
                    manager = new AdvertiseManager(context);
                }
            }
        }
        return manager;
    }

    public void advertiseInitInApplication(Application application) {
        if (advertise != null)
            advertise.advertiseInitInApplication(application);
    }

    public void advertiseInit(Activity activity) {
        if (advertise != null)
            advertise.advertiseInit(activity);
    }

    public void login(Activity activity,String account) {
        if (advertise != null) {
            advertise.login(activity,account);
        }
    }

    public void active(Activity activity) {
        if (advertise != null) {
            advertise.active(activity);
        }
    }
    public void upLoadRoleInfo(Activity activity,String type, RoleInfo roleInfo){
        if (advertise != null) {
            advertise.uploadRoleInfo(activity,type,roleInfo);
        }
    }
    public void registration(Activity activity,String account) {
        if (advertise != null) {
            advertise.registration(activity,account);
        }
    }

    public void callPayment(Activity activity, HashMap<String, Object> info) {
        if (advertise != null) {
            advertise.callPayment(activity, info);
        }
    }

    public void paymentFinish(Activity activity, HashMap<String, Object> info) {
        if (advertise != null) {
            advertise.paymentFinish(activity, info);
        }
    }

    public void onResume(Activity activity) {
        if (advertise != null) {
            advertise.onResume(activity);
        }
    }

    public void onPause(Activity activity) {
        if (advertise != null) {
            advertise.onPause(activity);
        }
    }

    public void onDestroy(Activity activity) {
        if (advertise != null) {
            advertise.onDestory(activity);
        }
    }

    public void onExitGame(Activity activity){
        if (advertise != null) {
            advertise.onExitGame(activity);
        }
    }

    public void reportAdEvent(String event, JSONObject json){
        if (advertise != null) {
            advertise.reportAdEvent(event,json);
        }
    }
    public void onRequestPermissionsResult(int requestCode,String[] permissions,int[] grantResults){
        if (advertise != null) {
            advertise.onRequestPermissionsResult(requestCode,permissions,grantResults);
        }
    }

}
