public MoPubView(Context context, AttributeSet attrs) { super(context, attrs); ManifestUtils.checkWebViewActivitiesDeclared(context); mContext = context; mScreenVisibility = getVisibility(); setHorizontalScrollBarEnabled(false); setVerticalScrollBarEnabled(false); // There is a rare bug in Froyo/2.2 where creation of a WebView causes a // NullPointerException. (http://code.google.com/p/android/issues/detail?id=10789) // It happens when the WebView can't access the local file store to make a cache file. // Here, we'll work around it by trying to create a file store and then just go inert // if it's not accessible. if (WebViewDatabase.getInstance(context) == null) { MoPubLog.e( "Disabling MoPub. Local cache file is inaccessible so MoPub will " + "fail if we try to create a WebView. Details of this Android bug found at:" + "http://code.google.com/p/android/issues/detail?id=10789"); return; } mAdViewController = AdViewControllerFactory.create(context, this); registerScreenStateBroadcastReceiver(); }
/** * Substitutes each {@code %s} in {@code template} with an argument. These are matched by position * - the first {@code %s} gets {@code args[0]}, etc. */ private static String format(String template, Object... args) { template = String.valueOf(template); // null -> "null" try { return String.format(template, args); } catch (IllegalFormatException exception) { MoPubLog.e("MoPub preconditions had a format exception: " + exception.getMessage()); return template; } }
final void loadCustomEvent(Activity activity, Map map, Map map1) { try { if (checkAndInitializeSdk(activity, map, map1)) { MoPubLifecycleManager.getInstance(activity).addLifecycleListener(getLifecycleListener()); } loadWithSdkInitialized(activity, map, map1); return; } // Misplaced declaration of an exception variable catch (Activity activity) { MoPubLog.e(activity.getMessage()); } }
private static boolean checkUiThreadInternal( boolean allowThrow, String errorMessageTemplate, Object... errorMessageArgs) { // Check that the main looper is the current looper. if (Looper.getMainLooper().equals(Looper.myLooper())) { return true; } String errorMessage = format(errorMessageTemplate, errorMessageArgs); if (allowThrow) { throw new IllegalStateException(errorMessage); } MoPubLog.e(errorMessage); return false; }
private static boolean checkNotNullInternal( Object reference, boolean allowThrow, String errorMessageTemplate, Object... errorMessageArgs) { if (reference != null) { return true; } String errorMessage = format(errorMessageTemplate, errorMessageArgs); if (allowThrow) { throw new NullPointerException(errorMessage); } MoPubLog.e(errorMessage); return false; }
private static boolean checkStateInternal( boolean expression, boolean allowThrow, String errorMessageTemplate, Object... errorMessageArgs) { if (expression) { return true; } String errorMessage = format(errorMessageTemplate, errorMessageArgs); if (allowThrow) { throw new IllegalStateException(errorMessage); } MoPubLog.e(errorMessage); return false; }