Exemplo n.º 1
0
  protected void loadCustomEvent(String customEventClassName, Map<String, String> serverExtras) {
    if (mAdViewController == null) {
      return;
    }
    if (TextUtils.isEmpty(customEventClassName)) {
      MoPubLog.d("Couldn't invoke custom event because the server did not specify one.");
      loadFailUrl(ADAPTER_NOT_FOUND);
      return;
    }

    if (mCustomEventBannerAdapter != null) {
      mCustomEventBannerAdapter.invalidate();
    }

    MoPubLog.d("Loading custom event adapter.");

    mCustomEventBannerAdapter =
        CustomEventBannerAdapterFactory.create(
            this,
            customEventClassName,
            serverExtras,
            mAdViewController.getBroadcastIdentifier(),
            mAdViewController.getAdReport());
    mCustomEventBannerAdapter.loadAd();
  }
Exemplo n.º 2
0
  /**
   * Called upon user click. Attempts open mopubnativebrowser links in the device browser and all
   * other links in the MoPub in-app browser.
   */
  @VisibleForTesting
  void handleClick(final List<String> clickThroughTrackers, final String clickThroughUrl) {
    makeTrackingHttpRequest(clickThroughTrackers, getContext(), BaseEvent.Name.CLICK_REQUEST);

    if (clickThroughUrl == null) {
      return;
    }

    broadcastAction(ACTION_INTERSTITIAL_CLICK);

    if (Intents.isNativeBrowserScheme(clickThroughUrl)) {
      try {
        final Intent intent = Intents.intentForNativeBrowserScheme(clickThroughUrl);
        Intents.startActivity(getContext(), intent);
        return;
      } catch (UrlParseException e) {
        MoPubLog.d(e.getMessage());
      } catch (IntentNotResolvableException e) {
        MoPubLog.d("Could not handle intent for URI: " + clickThroughUrl + ". " + e.getMessage());
      }

      return;
    }

    Bundle bundle = new Bundle();
    bundle.putString(MoPubBrowser.DESTINATION_URL_KEY, clickThroughUrl);

    getBaseVideoViewControllerListener()
        .onStartActivityForResult(MoPubBrowser.class, MOPUB_BROWSER_REQUEST_CODE, bundle);
  }
Exemplo n.º 3
0
 private void unregisterScreenStateBroadcastReceiver() {
   try {
     mContext.unregisterReceiver(mScreenStateReceiver);
   } catch (Exception IllegalArgumentException) {
     MoPubLog.d("Failed to unregister screen state broadcast receiver (never registered).");
   }
 }
Exemplo n.º 4
0
 public boolean getTesting() {
   if (mAdViewController != null) return mAdViewController.getTesting();
   else {
     MoPubLog.d("Can't get testing status for destroyed MoPubView. " + "Returning false.");
     return false;
   }
 }
Exemplo n.º 5
0
 public boolean getAutorefreshEnabled() {
   if (mAdViewController != null) return mAdViewController.getAutorefreshEnabled();
   else {
     MoPubLog.d("Can't get autorefresh status for destroyed MoPubView. " + "Returning false.");
     return false;
   }
 }
 @Override
 public void didDismissRewardedVideo(String location) {
   // This is called before didCloseRewardedVideo and didClickRewardedVideo
   super.didDismissRewardedVideo(location);
   MoPubRewardedVideoManager.onRewardedVideoClosed(ChartboostRewardedVideo.class, location);
   MoPubLog.d("Chartboost rewarded video dismissed for location " + location + ".");
 }
 @Override
 public void showVideo() {
   if (hasVideoAvailable()) {
     Chartboost.showRewardedVideo(mLocation);
   } else {
     MoPubLog.d("Attempted to show Chartboost rewarded video before it was available.");
   }
 }
 @Override
 protected void performAction(
     @NonNull final Context context,
     @NonNull final Uri uri,
     @NonNull final UrlHandler urlHandler)
     throws IntentNotResolvableException {
   MoPubLog.d("Link to about page ignored.");
 }
Exemplo n.º 9
0
  protected void adLoaded() {
    MoPubLog.d("adLoaded");

    if (mBannerAdListener != null) {
      mBannerAdListener.onBannerLoaded(this);
    } else if (mOnAdLoadedListener != null) {
      mOnAdLoadedListener.OnAdLoaded(this);
    }
  }
Exemplo n.º 10
0
 Context getContextOrDestroy() {
   final Context context = mContext.get();
   if (context == null) {
     destroy();
     MoPubLog.d(
         "Weak reference to Activity Context in MoPubNative became null. This instance"
             + " of MoPubNative is destroyed and No more requests will be processed.");
   }
   return context;
 }
Exemplo n.º 11
0
 private void downloadCompanionAd() {
   if (mVastCompanionAd != null) {
     try {
       final HttpGet httpGet = initializeHttpGet(mVastCompanionAd.getImageUrl(), getContext());
       final DownloadTask downloadTask = new DownloadTask(this);
       AsyncTasks.safeExecuteOnExecutor(downloadTask, httpGet);
     } catch (Exception e) {
       MoPubLog.d("Failed to download companion ad", e);
     }
   }
 }
    @Override
    public void didFailToLoadRewardedVideo(String location, CBError.CBImpressionError error) {
      super.didFailToLoadRewardedVideo(location, error);

      if (mLocationsToLoad.contains(location)) {
        MoPubLog.d("Chartboost rewarded video cache failed for location " + location + ".");
        MoPubRewardedVideoManager.onRewardedVideoLoadFailure(
            ChartboostRewardedVideo.class, location, VIDEO_DOWNLOAD_ERROR);
        mLocationsToLoad.remove(location);
      }
    }
    @Override
    public void didCacheRewardedVideo(String location) {
      super.didCacheRewardedVideo(location);

      if (mLocationsToLoad.contains(location)) {
        MoPubLog.d("Chartboost rewarded video cached for location " + location + ".");
        MoPubRewardedVideoManager.onRewardedVideoLoadSuccess(
            ChartboostRewardedVideo.class, location);
        mLocationsToLoad.remove(location);
      }
    }
 public void handleUrl(
     UrlHandler urlHandler,
     @NonNull final Context context,
     @NonNull final Uri destinationUri,
     final boolean fromUserInteraction)
     throws IntentNotResolvableException {
   MoPubLog.d("Ad event URL: " + destinationUri);
   if (mRequiresUserInteraction && !fromUserInteraction) {
     throw new IntentNotResolvableException(
         "Attempted to handle action without user " + "interaction.");
   } else {
     performAction(context, destinationUri, urlHandler);
   }
 }
 @Override
 public void didCompleteRewardedVideo(String location, int reward) {
   super.didCompleteRewardedVideo(location, reward);
   MoPubLog.d(
       "Chartboost rewarded video completed for location "
           + location
           + " with "
           + "reward amount "
           + reward);
   MoPubRewardedVideoManager.onRewardedVideoCompleted(
       ChartboostRewardedVideo.class,
       location,
       MoPubReward.success(MoPubReward.NO_REWARD_LABEL, reward));
 }
    List getAbsoluteProgressTrackers()
    {
        ArrayList arraylist;
        Object obj;
        Iterator iterator1;
        arraylist = new ArrayList();
        for (Iterator iterator = getVideoTrackersByAttribute("start").iterator(); iterator.hasNext(); arraylist.add(new VastAbsoluteProgressTracker((String)iterator.next(), 2000))) { }
        obj = XmlUtils.getFirstMatchingChildNode(mLinearNode, "TrackingEvents");
        if (obj == null)
        {
            break MISSING_BLOCK_LABEL_263;
        }
        iterator1 = XmlUtils.getMatchingChildNodes(((Node) (obj)), "Tracking", "event", Collections.singletonList("progress")).iterator();
_L2:
        String s;
        Object obj1;
        if (!iterator1.hasNext())
        {
            break; /* Loop/switch isn't completed */
        }
        obj1 = (Node)iterator1.next();
        s = XmlUtils.getAttributeValue(((Node) (obj1)), "offset");
        if (s == null)
        {
            continue; /* Loop/switch isn't completed */
        }
        s = s.trim();
        if (!Strings.isAbsoluteTracker(s))
        {
            continue; /* Loop/switch isn't completed */
        }
        obj1 = XmlUtils.getNodeValue(((Node) (obj1)));
        Integer integer = Strings.parseAbsoluteOffset(s);
        if (integer != null)
        {
            try
            {
                arraylist.add(new VastAbsoluteProgressTracker(((String) (obj1)), integer.intValue()));
            }
            catch (NumberFormatException numberformatexception)
            {
                MoPubLog.d(String.format("Failed to parse VAST progress tracker %s", new Object[] {
                    s
                }));
            }
        }
        if (true) goto _L2; else goto _L1
 final void setStarRating(@Nullable final Double starRating) {
   if (starRating == null) {
     mStarRating = null;
   } else if (starRating >= MIN_STAR_RATING && starRating <= MAX_STAR_RATING) {
     mStarRating = starRating;
   } else {
     MoPubLog.d(
         "Ignoring attempt to set invalid star rating ("
             + starRating
             + "). Must be "
             + "between "
             + MIN_STAR_RATING
             + " and "
             + MAX_STAR_RATING
             + ".");
   }
 }
Exemplo n.º 18
0
  private void loadNativeAd(
      @Nullable final RequestParameters requestParameters, @Nullable final Integer sequenceNumber) {
    final Context context = getContextOrDestroy();
    if (context == null) {
      return;
    }

    final NativeUrlGenerator generator =
        new NativeUrlGenerator(context).withAdUnitId(mAdUnitId).withRequest(requestParameters);

    if (sequenceNumber != null) {
      generator.withSequenceNumber(sequenceNumber);
    }

    final String endpointUrl = generator.generateUrlString(Constants.HOST);

    if (endpointUrl != null) {
      MoPubLog.d("Loading ad from: " + endpointUrl);
    }

    requestNativeAd(endpointUrl);
  }
Exemplo n.º 19
0
 @VisibleForTesting
 void onAdError(@NonNull final VolleyError volleyError) {
   MoPubLog.d("Native ad request failed.", volleyError);
   if (volleyError instanceof MoPubNetworkError) {
     MoPubNetworkError error = (MoPubNetworkError) volleyError;
     switch (error.getReason()) {
       case BAD_BODY:
         mMoPubNativeNetworkListener.onNativeFail(INVALID_RESPONSE);
         return;
       case BAD_HEADER_DATA:
         mMoPubNativeNetworkListener.onNativeFail(INVALID_RESPONSE);
         return;
       case WARMING_UP:
         // Used for the sample app to signal a toast.
         // This is not customer-facing except in the sample app.
         MoPubLog.c(MoPubErrorCode.WARMUP.toString());
         mMoPubNativeNetworkListener.onNativeFail(EMPTY_AD_RESPONSE);
         return;
       case NO_FILL:
         mMoPubNativeNetworkListener.onNativeFail(EMPTY_AD_RESPONSE);
         return;
       case UNSPECIFIED:
       default:
         mMoPubNativeNetworkListener.onNativeFail(UNSPECIFIED);
         return;
     }
   } else {
     // Process our other status code errors.
     NetworkResponse response = volleyError.networkResponse;
     if (response != null && response.statusCode >= 500 && response.statusCode < 600) {
       mMoPubNativeNetworkListener.onNativeFail(SERVER_ERROR_RESPONSE_CODE);
     } else if (response == null && !DeviceUtils.isNetworkAvailable(mContext.get())) {
       MoPubLog.c(String.valueOf(MoPubErrorCode.NO_CONNECTION.toString()));
       mMoPubNativeNetworkListener.onNativeFail(CONNECTION_ERROR);
     } else {
       mMoPubNativeNetworkListener.onNativeFail(UNSPECIFIED);
     }
   }
 }
Exemplo n.º 20
0
 @Deprecated
 protected void adWillLoad(String url) {
   MoPubLog.d("adWillLoad: " + url);
   if (mOnAdWillLoadListener != null) mOnAdWillLoadListener.OnAdWillLoad(this, url);
 }
 @Override
 public void didCloseRewardedVideo(String location) {
   super.didCloseRewardedVideo(location);
   MoPubLog.d("Chartboost rewarded video closed for location " + location + ".");
 }
 @Override
 public void didClickRewardedVideo(String location) {
   super.didClickRewardedVideo(location);
   MoPubRewardedVideoManager.onRewardedVideoClicked(ChartboostRewardedVideo.class, location);
   MoPubLog.d("Chartboost rewarded video clicked for location " + location + ".");
 }
 @Override
 public void didDisplayRewardedVideo(String location) {
   super.didDisplayRewardedVideo(location);
   MoPubLog.d("Chartboost rewarded video displayed for location " + location + ".");
   MoPubRewardedVideoManager.onRewardedVideoStarted(ChartboostRewardedVideo.class, location);
 }
Exemplo n.º 24
0
 protected void trackNativeImpression() {
   MoPubLog.d("Tracking impression for native adapter.");
   if (mAdViewController != null) mAdViewController.trackImpression();
 }