Java 类com.google.android.gms.ads.reward.RewardedVideoAdListener 实例源码

项目:TvAppRepo    文件:GenerateShortcutHelper.java   
static void showVideoAd(Activity activity) {
    final RewardedVideoAd ad = MobileAds.getRewardedVideoAdInstance(activity);
    ad.setRewardedVideoAdListener(new RewardedVideoAdListener() {
        @Override
        public void onRewardedVideoAdLoaded() {
            ad.show();
        }

        @Override
        public void onRewardedVideoAdOpened() {

        }

        @Override
        public void onRewardedVideoStarted() {

        }

        @Override
        public void onRewardedVideoAdClosed() {

        }

        @Override
        public void onRewarded(RewardItem rewardItem) {

        }

        @Override
        public void onRewardedVideoAdLeftApplication() {

        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int i) {

        }
    });
    ad.loadAd(activity.getString(R.string.reward_video_ad_unit_id), new AdRequest.Builder().build());
}
项目:GodotFireBase    文件:AdMob.java   
public RewardedVideoAd createRewardedVideo(final String unitid) {
    RewardedVideoAd mrv = MobileAds.getRewardedVideoAdInstance(activity);
    mrv.setRewardedVideoAdListener(new RewardedVideoAdListener() {

        @Override
        public void onRewardedVideoAdLoaded() {
            Utils.d("AdMob:Video:Loaded");
            Utils.callScriptFunc("AdMob", "AdMob_Video", buildStatus(unitid, "loaded"));
        }

        @Override
        public void onRewarded(RewardItem rewardItem) {
            Utils.d("AdMob:Rewarded:Success");

            Dictionary ret = new Dictionary();
            ret.put("RewardType", rewardItem.getType());
            ret.put("RewardAmount", rewardItem.getAmount());
            ret.put("unit_id", unitid);

            Utils.callScriptFunc("AdMob", "AdMobReward", ret);
            reloadRewardedVideo(unitid);
        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int errorCode) {
            Utils.d("AdMob:VideoLoad:Failed");
            Utils.callScriptFunc("AdMob", "AdMob_Video", buildStatus(unitid, "load_failed"));
            reloadRewardedVideo(unitid);
        }

        @Override
        public void onRewardedVideoAdClosed() {
            Utils.d("AdMob:VideoAd:Closed");
            Utils.callScriptFunc("AdMob", "AdMob_Video", buildStatus(unitid, "closed"));
            reloadRewardedVideo(unitid);
        }

        @Override
        public void onRewardedVideoAdLeftApplication() {
            Utils.d("AdMob:VideoAd:LeftApp");
        }

        @Override
        public void onRewardedVideoAdOpened() {
            Utils.d("AdMob:VideoAd:Opended");
            //Utils.callScriptFunc("AdMob", "AdMob_Video", buildStatus(unitid, "opened"));
        }

        @Override
        public void onRewardedVideoStarted() {
            Utils.d("Reward:VideoAd:Started");
            //Utils.callScriptFunc("AdMob", "AdMob_Video", buildStatus(unitid, "started"));
        }
    });

    return mrv;
}
项目:AdsManager    文件:AdsManager.java   
private Single<Boolean> loadAndshowRewardedVideo(final String id) {
    return Single.create(new SingleOnSubscribe<Boolean>() {
        @Override
        public void subscribe(@NonNull final SingleEmitter<Boolean> e) throws Exception {
            final RewardedVideoAd mAd = MobileAds.getRewardedVideoAdInstance(application);
            mAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {

                boolean rewarded = false;

                @Override
                public void onRewardedVideoAdLoaded() {
                    mAd.show();
                }

                @Override
                public void onRewardedVideoAdOpened() {

                }

                @Override
                public void onRewardedVideoStarted() {

                }

                @Override
                public void onRewardedVideoAdClosed() {
                    e.onSuccess(rewarded);
                }

                @Override
                public void onRewarded(RewardItem rewardItem) {
                    rewarded = true;
                }

                @Override
                public void onRewardedVideoAdLeftApplication() {

                }

                @Override
                public void onRewardedVideoAdFailedToLoad(int i) {
                    e.onError(new AdError());
                }
            });

            final AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
            adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
            if (debug) {
                adRequestBuilder.addTestDevice(DeviceIdFounder.getDeviceId(application));
            }

            mAd.loadAd(id, adRequestBuilder.build());
        }
    });
}
项目:GodotAds    文件:AdMob.java   
public void createRewardedVideo() {
    mrv = MobileAds.getRewardedVideoAdInstance(activity);
    mrv.setRewardedVideoAdListener(new RewardedVideoAdListener() {

        @Override
        public void onRewardedVideoAdLoaded() {
            Utils.d("AdMob:Video:Loaded");
            //emitRewardedVideoStatus();
            //Utils.call
        }

        @Override
        public void onRewarded(RewardItem rewardItem) {
            Utils.d("AdMob:Rewarded");

            JSONObject ret = new JSONObject();
            try {
                ret.put("RewardType", rewardItem.getType());
                ret.put("RewardAmount", rewardItem.getAmount());
            } catch (JSONException e) {
                Utils.d("AdMob:Reward:Error:" + e.toString());
            }

            Utils.callScriptFunc("AdMob", "AdMobReward", ret.toString());
        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int errorCode) {
            Utils.d("AdMob:VideoLoad:Failed");
            Utils.callScriptFunc("AdMob", "AdMob_Video", "load_failed");
        }

        @Override
        public void onRewardedVideoAdClosed() {
            Utils.d("AdMob:VideoAd:Closed");
        }

        @Override
        public void onRewardedVideoAdLeftApplication() {
            Utils.d("AdMob:VideoAd:LeftApp");
        }

        @Override
        public void onRewardedVideoAdOpened() {
            Utils.d("AdMon:VideoAd:Opended");
        }

        @Override
        public void onRewardedVideoStarted() {
            Utils.d("Reward:VideoAd:Started");
        }
    });

    requestNewRewardedVideo();
}
项目:admob-rewarded-video    文件:MainActivity.java   
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    // Initialize the Mobile Ads SDK.
    MobileAds.initialize(this, getString(R.string.admob_app_id));

    mRewardedVideoAd = MobileAds.getRewardedVideoAdInstance(this);

    // Create the "retry" button, which starts a new game.
    mRetryButton = ((Button) findViewById(R.id.retry_button));
    mRetryButton.setVisibility(View.INVISIBLE);
    mRetryButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View view) {
            startGame();
        }
    });

    // Hide the "watch video" until the end of a game.
    mShowVideoButton = ((Button) findViewById(R.id.watch_video));
    mShowVideoButton.setVisibility(View.INVISIBLE);

    mCoinCountText = ((TextView) findViewById(R.id.coin_count_text));

    mRewardedVideoAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {
        @Override
        public void onRewarded(RewardItem rewardItem) {
            Toast.makeText(getBaseContext(), "Ad triggered reward.", Toast.LENGTH_SHORT).show();
            addCoins(rewardItem.getAmount());
        }

        @Override
        public void onRewardedVideoAdLoaded() {
            Toast.makeText(getBaseContext(), "Ad loaded.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRewardedVideoAdOpened() {
            Toast.makeText(getBaseContext(), "Ad opened.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRewardedVideoStarted() {
            Toast.makeText(getBaseContext(), "Ad started.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRewardedVideoAdClosed() {
            Toast.makeText(getBaseContext(), "Ad closed.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRewardedVideoAdLeftApplication() {
            Toast.makeText(getBaseContext(), "Ad left application.", Toast.LENGTH_SHORT).show();
        }

        @Override
        public void onRewardedVideoAdFailedToLoad(int i) {
            Toast.makeText(getBaseContext(), "Ad failed to load.", Toast.LENGTH_SHORT).show();
        }
    });

    if (savedInstanceState == null) {
        mCoinCount = 0;
        mCoinCountText.setText("Coins: " + mCoinCount);

        startGame();
    }
}
项目:android-sdk-3.0    文件:InterstitialAdView.java   
public void setRewardedVideoAdListener(RewardedVideoAdListener rewardedVideoAdListener) {
    mInterstitialAd.setRewardedVideoAdListener(rewardedVideoAdListener);
}
项目:OCiney    文件:AdsManager.java   
public AdsManager showRewardedVideo(final int stringId, final AdVideoClosedListener adVideoClosedListener) {
    if (BuildConfig.DEBUG && !showAdsOnDebug) {
        adVideoClosedListener.onAdClosedWithReward();
    } else {
        final RewardedVideoAd mAd = MobileAds.getRewardedVideoAdInstance(context);
        mAd.setRewardedVideoAdListener(new RewardedVideoAdListener() {

            boolean rewarded = false;

            @Override
            public void onRewardedVideoAdLoaded() {
                mAd.show();
            }

            @Override
            public void onRewardedVideoAdOpened() {

            }

            @Override
            public void onRewardedVideoStarted() {

            }

            @Override
            public void onRewardedVideoAdClosed() {
                if (rewarded) {
                    adVideoClosedListener.onAdClosedWithReward();
                } else {
                    adVideoClosedListener.onAdClosedWithoutReward();
                }
            }

            @Override
            public void onRewarded(RewardItem rewardItem) {
                rewarded = true;
            }

            @Override
            public void onRewardedVideoAdLeftApplication() {

            }

            @Override
            public void onRewardedVideoAdFailedToLoad(int i) {

            }
        });

        final AdRequest.Builder adRequestBuilder = new AdRequest.Builder();
        adRequestBuilder.addTestDevice(AdRequest.DEVICE_ID_EMULATOR);
        if (BuildConfig.DEBUG) {
            adRequestBuilder.addTestDevice(DeviceIdFounder.getDeviceId(context));
        }

        mAd.loadAd(context.getString(stringId), adRequestBuilder.build());
    }
    return this;
}