| | |
| | | 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) { |
| | |
| | | return null; |
| | | } |
| | | } else { |
| | | if (AndroidManifestUtil.isHuaWeiChannel(context)&&false) { |
| | | if (AndroidManifestUtil.isHuaWeiChannel(context) && false) { |
| | | return AD_TYPE.hw; |
| | | } else { |
| | | return AD_TYPE.gdt; |
| | |
| | | |
| | | // 是否可以显示华为的广告 |
| | | 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; |
| | |
| | | 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(); |
| | | } |
| | | |