admin
2025-02-26 daea6f9a47aae244b5fa02b5c790519934711760
BuWanVideo/src/com/weikou/beibeivideo/util/ad/AdUtil.java
@@ -73,9 +73,9 @@
                JSONObject object = new JSONObject(config);
                object = object.optJSONObject(position.getPositionName());
                if (object != null)
                    if (AndroidManifestUtil.isHuaWeiChannel(context)&&false){
                    if (AndroidManifestUtil.isHuaWeiChannel(context) && false) {
                        return AD_TYPE.hw;
                    }else {
                    } else {
                        return AD_TYPE.valueOf(object.optString("type"));
                    }
            } catch (JSONException e) {
@@ -84,7 +84,7 @@
                return null;
            }
        } else {
            if (AndroidManifestUtil.isHuaWeiChannel(context)&&false) {
            if (AndroidManifestUtil.isHuaWeiChannel(context) && false) {
                return AD_TYPE.hw;
            } else {
                return AD_TYPE.gdt;
@@ -183,8 +183,18 @@
    // 是否可以显示华为的广告
    public static boolean canShowAdHuaWei(Context context, AdPositionEnum position) {
        return canShowAd(context, "huawei", position);
    }
    public static void setAdHuaWeiShown(Context context, AdPositionEnum position) {
        setAdShown(context, "huawei", position);
    }
    // 是否可以显示华为的广告
    public static boolean canShowAd(Context context, String channel, AdPositionEnum position) {
        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
        Long lastTime = share.getLong("huawei_show_time_" + position.name(), 0);
        long lastTime = share.getLong(channel + "_show_time_" + position.name(), 0);
        if (TimeUtils.millisToStringDate(System.currentTimeMillis(), "yyyyMMdd").equalsIgnoreCase(TimeUtils.millisToStringDate(lastTime, "yyyyMMdd"))) {
            //同一天
            return false;
@@ -192,10 +202,10 @@
        return true;
    }
    public static void setAdHuaWeiShown(Context context, AdPositionEnum position) {
    public static void setAdShown(Context context, String channel, AdPositionEnum position) {
        SharedPreferences share = context.getSharedPreferences("adConfig", Context.MODE_PRIVATE);
        SharedPreferences.Editor editor = share.edit();
        editor.putLong("huawei_show_time_" + position.name(), System.currentTimeMillis());
        editor.putLong(channel + "_show_time_" + position.name(), System.currentTimeMillis());
        editor.commit();
    }