package com.yyrh.advertisement;

import android.content.Context;



import com.yyrh.utils.Utils;


import java.lang.reflect.Constructor;




public class AdvertiseFactory {




    private AdvertiseFactory(){}



    public static Advertise GetAdvertise(Context context) {

        return AdvertiseFactory.GetAdvertise(context, "YyrhAdParam.cnf");
    }

    public static Advertise GetAdvertise(Context context, String adParamPath) {
        String adClassName = Utils.getParamCnfValuebyKey(context, adParamPath, "CLASSNAME");
        if (adClassName == null || adClassName.equals("")) {
            return null;

        }

        Advertise advertise = null;
        try {
            Class clz = Class.forName(adClassName);
            Constructor constructor = clz.getDeclaredConstructor();
            constructor.setAccessible(true);
            advertise = (Advertise)clz.newInstance();
        } catch (ClassNotFoundException e) {
            e.printStackTrace();
        } catch (NoSuchMethodException e) {
            e.printStackTrace();
        } catch (IllegalAccessException e) {
            e.printStackTrace();
        } catch (InstantiationException e) {
            e.printStackTrace();
        }

        return advertise;
    }


}
