use of com.google.ads.interactivemedia.v3.api.AdsManagerLoadedEvent in project zype-android by zype.
the class PlayerFragment method onActivityCreated.
@Override
public void onActivityCreated(@Nullable Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
//
// IMA SDK
//
// Create an AdsLoader.
sdkFactory = ImaSdkFactory.getInstance();
adsLoader = sdkFactory.createAdsLoader(this.getActivity());
// Add listeners for when ads are loaded and for errors.
adsLoader.addAdErrorListener(this);
adsLoader.addAdsLoadedListener(new AdsLoader.AdsLoadedListener() {
@Override
public void onAdsManagerLoaded(AdsManagerLoadedEvent adsManagerLoadedEvent) {
// Ads were successfully loaded, so get the AdsManager instance. AdsManager has
// events for ad playback and errors.
adsManager = adsManagerLoadedEvent.getAdsManager();
// Attach event and error event listeners.
adsManager.addAdErrorListener(PlayerFragment.this);
adsManager.addAdEventListener(PlayerFragment.this);
adsManager.init();
}
});
sensorViewModel = ViewModelProviders.of(getActivity()).get(SensorViewModel.class);
videoDetailViewModel = ViewModelProviders.of(getActivity()).get(VideoDetailViewModel.class);
if (playerViewModel.isTrailer().getValue()) {
ImageButton buttonCloseTrailer = getView().findViewById(R.id.buttonCloseTrailer);
buttonCloseTrailer.setVisibility(View.VISIBLE);
buttonCloseTrailer.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
stop();
videoDetailViewModel.onVideoFinished(true);
playerViewModel.setTrailerVideoId(null);
}
});
}
setHasOptionsMenu(true);
}
Aggregations