Showing preview only (869K chars total). Download the full file or copy to clipboard to get everything.
Repository: fbsamples/audience-network
Branch: main
Commit: bdd83086d558
Files: 236
Total size: 788.9 KB
Directory structure:
gitextract_zu2obygx/
├── .github/
│ └── workflows/
│ └── main.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── samples/
├── android/
│ ├── .gitignore
│ ├── AdUnitsSample/
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── build.gradle
│ │ ├── libs/
│ │ │ ├── AudienceNetwork.aar
│ │ │ └── DebugSettings.aar
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── AndroidManifestVariables.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── facebook/
│ │ │ └── samples/
│ │ │ └── AdUnitsSample/
│ │ │ ├── AdUnitsSampleActivity.java
│ │ │ ├── AdUnitsSampleApplication.java
│ │ │ ├── AdUnitsSampleType.java
│ │ │ ├── AudienceNetworkInitializeHelper.java
│ │ │ ├── SampleListActivity.java
│ │ │ ├── SplashActivity.java
│ │ │ ├── adapters/
│ │ │ │ ├── NativeAdRecyclerAdapter.java
│ │ │ │ └── SampleAdapter.java
│ │ │ ├── fragments/
│ │ │ │ ├── BannerFragment.java
│ │ │ │ ├── InterstitialFragment.java
│ │ │ │ ├── MultiLoadInterstitialFragment.java
│ │ │ │ ├── NativeAdHScrollFragment.java
│ │ │ │ ├── NativeAdRecyclerFragment.java
│ │ │ │ ├── NativeAdSampleFragment.java
│ │ │ │ ├── NativeAdTemplateFragment.java
│ │ │ │ ├── NativeBannerAdFragment.java
│ │ │ │ ├── NativeBannerAdTemplateFragment.java
│ │ │ │ ├── RectangleFragment.java
│ │ │ │ ├── RewardedInterstitialFragment.java
│ │ │ │ └── RewardedVideoFragment.java
│ │ │ ├── models/
│ │ │ │ └── RecyclerPostItem.java
│ │ │ └── thirdparty/
│ │ │ └── DividerItemDecoration/
│ │ │ └── DividerItemDecoration.java
│ │ └── res/
│ │ ├── layout/
│ │ │ ├── activity_ad_sample.xml
│ │ │ ├── activity_sample_list.xml
│ │ │ ├── activity_splash.xml
│ │ │ ├── fragment_banner.xml
│ │ │ ├── fragment_interstitial.xml
│ │ │ ├── fragment_multi_load_interstitial.xml
│ │ │ ├── fragment_native_ad_hscroll.xml
│ │ │ ├── fragment_native_ad_recycler.xml
│ │ │ ├── fragment_native_ad_sample.xml
│ │ │ ├── fragment_native_ad_template.xml
│ │ │ ├── fragment_native_banner_ad.xml
│ │ │ ├── fragment_native_banner_ad_template.xml
│ │ │ ├── fragment_rectangle.xml
│ │ │ ├── fragment_rewarded_interstitial.xml
│ │ │ ├── fragment_rewarded_video.xml
│ │ │ ├── list_item_section.xml
│ │ │ ├── native_ad_unit.xml
│ │ │ ├── native_banner_ad_unit.xml
│ │ │ └── recycler_post_item.xml
│ │ ├── layout-land/
│ │ │ └── fragment_rectangle.xml
│ │ ├── menu/
│ │ │ └── ad_units_sample_menu.xml
│ │ ├── values/
│ │ │ ├── layouts.xml
│ │ │ └── strings.xml
│ │ ├── values-large/
│ │ │ └── layout.xml
│ │ ├── values-sw600dp/
│ │ │ └── layout.xml
│ │ └── xml/
│ │ ├── locales_config.xml
│ │ └── network_security_config.xml
│ ├── KotlinAdUnitsSample/
│ │ ├── .gitignore
│ │ ├── KotlinAdUnitsSample/
│ │ │ └── .gitignore
│ │ ├── LICENSE
│ │ ├── build.gradle
│ │ ├── libs/
│ │ │ ├── AudienceNetwork.aar
│ │ │ └── DebugSettings.aar
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── facebook/
│ │ │ └── samples/
│ │ │ └── adunitssamplekotlin/
│ │ │ ├── AdUnitsSampleActivity.kt
│ │ │ ├── AdUnitsSampleApplication.kt
│ │ │ ├── AdUnitsSampleType.kt
│ │ │ ├── AudienceNetworkInitializeHelper.kt
│ │ │ ├── SampleListActivity.kt
│ │ │ ├── SplashActivity.kt
│ │ │ ├── adapters/
│ │ │ │ ├── NativeAdRecyclerAdapter.kt
│ │ │ │ └── SampleAdapter.kt
│ │ │ ├── fragments/
│ │ │ │ ├── BannerFragment.kt
│ │ │ │ ├── InterstitialFragment.kt
│ │ │ │ ├── NativeAdHScrollFragment.kt
│ │ │ │ ├── NativeAdRecyclerFragment.kt
│ │ │ │ ├── NativeAdSampleFragment.kt
│ │ │ │ ├── NativeAdTemplateFragment.kt
│ │ │ │ ├── NativeBannerAdFragment.kt
│ │ │ │ ├── NativeBannerAdTemplateFragment.kt
│ │ │ │ ├── RectangleFragment.kt
│ │ │ │ ├── RewardedInterstitialFragment.kt
│ │ │ │ ├── RewardedVideoFragment.kt
│ │ │ │ └── SampleListFragment.kt
│ │ │ └── models/
│ │ │ └── RecyclerPostItem.kt
│ │ └── res/
│ │ ├── layout/
│ │ │ ├── activity_ad_sample.xml
│ │ │ ├── activity_sample_list.xml
│ │ │ ├── activity_splash.xml
│ │ │ ├── fragment_banner.xml
│ │ │ ├── fragment_interstitial.xml
│ │ │ ├── fragment_native_ad_hscroll.xml
│ │ │ ├── fragment_native_ad_recycler.xml
│ │ │ ├── fragment_native_ad_sample.xml
│ │ │ ├── fragment_native_ad_template.xml
│ │ │ ├── fragment_native_banner_ad.xml
│ │ │ ├── fragment_native_banner_ad_template.xml
│ │ │ ├── fragment_rectangle.xml
│ │ │ ├── fragment_rewarded_interstitial.xml
│ │ │ ├── fragment_rewarded_video.xml
│ │ │ ├── list_item_section.xml
│ │ │ ├── native_ad_unit.xml
│ │ │ ├── native_banner_ad_unit.xml
│ │ │ └── recycler_post_item.xml
│ │ ├── menu/
│ │ │ └── ad_units_sample_menu.xml
│ │ └── values/
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── README.md
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios/
│ ├── AdUnitsSample/
│ │ ├── .gitignore
│ │ ├── AdUnitsSample/
│ │ │ ├── AdUnitsSample-Prefix.pch
│ │ │ ├── AdUnitsSample.entitlements
│ │ │ ├── AdUnitsSampleStoryboard.storyboard
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── BannerViewController.h
│ │ │ ├── BannerViewController.m
│ │ │ ├── CollectionViewController.h
│ │ │ ├── CollectionViewController.m
│ │ │ ├── DebugLogsViewController.h
│ │ │ ├── DebugLogsViewController.m
│ │ │ ├── Images.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ ├── InfoPlist.strings
│ │ │ ├── InstreamViewController.h
│ │ │ ├── InstreamViewController.m
│ │ │ ├── InterstitialViewController.h
│ │ │ ├── InterstitialViewController.m
│ │ │ ├── LaunchScreen.storyboard
│ │ │ ├── MediumRectViewController.h
│ │ │ ├── MediumRectViewController.m
│ │ │ ├── MenuTableViewController.h
│ │ │ ├── MenuTableViewController.m
│ │ │ ├── NativeAdTemplateViewController.h
│ │ │ ├── NativeAdTemplateViewController.m
│ │ │ ├── NativeBannerAdTemplateViewController.h
│ │ │ ├── NativeBannerAdTemplateViewController.m
│ │ │ ├── NativeBannerViewController.h
│ │ │ ├── NativeBannerViewController.m
│ │ │ ├── NativeViewController.h
│ │ │ ├── NativeViewController.m
│ │ │ ├── NavigationController.h
│ │ │ ├── NavigationController.m
│ │ │ ├── RewardedVideoViewController.h
│ │ │ ├── RewardedVideoViewController.m
│ │ │ ├── ScrollViewController.h
│ │ │ ├── ScrollViewController.m
│ │ │ ├── SettingsLogLevelCell.h
│ │ │ ├── SettingsLogLevelCell.m
│ │ │ ├── SettingsSandboxCell.h
│ │ │ ├── SettingsSandboxCell.m
│ │ │ ├── SettingsTableViewController.h
│ │ │ ├── SettingsTableViewController.m
│ │ │ ├── SettingsTestAdCell.h
│ │ │ ├── SettingsTestAdCell.m
│ │ │ ├── SettingsTestModeCell.h
│ │ │ ├── SettingsTestModeCell.m
│ │ │ ├── TableViewController.h
│ │ │ ├── TableViewController.m
│ │ │ └── main.m
│ │ ├── AdUnitsSample.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcshareddata/
│ │ │ └── xcschemes/
│ │ │ └── AdUnitsSample.xcscheme
│ │ ├── AdUnitsSample.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ ├── Podfile
│ │ ├── ReadMe.txt
│ │ └── VERSION.bzl
│ ├── FANSample/
│ │ ├── .gitignore
│ │ ├── FANSample/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ └── fan.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Extensions/
│ │ │ │ ├── NSObject+ClassName.swift
│ │ │ │ ├── UIView+NibContent.swift
│ │ │ │ └── UIViewController+Storyboard.swift
│ │ │ ├── Info.plist
│ │ │ ├── Samples/
│ │ │ │ ├── BannerSampleViewController.swift
│ │ │ │ ├── FullscreenAdSampleViewController.swift
│ │ │ │ ├── Native/
│ │ │ │ │ ├── NativeAdScreenViewController.swift
│ │ │ │ │ ├── NativeAdView.swift
│ │ │ │ │ └── NativeAdView.xib
│ │ │ │ ├── NativeBanner/
│ │ │ │ │ ├── NativeBannerAdScreenViewController.swift
│ │ │ │ │ ├── NativeBannerAdView.swift
│ │ │ │ │ └── NativeBannerAdView.xib
│ │ │ │ ├── NativeBannerTemplate/
│ │ │ │ │ ├── NativeBannerTemplateAdScreenViewController.swift
│ │ │ │ │ └── NativeBannerTemplateAdView.swift
│ │ │ │ └── NativeTemplate/
│ │ │ │ ├── NativeTemplateAdView.swift
│ │ │ │ └── NativeTemplateScreenViewController.swift
│ │ │ ├── SamplesViewController.swift
│ │ │ ├── SceneDelegate.swift
│ │ │ ├── Settings/
│ │ │ │ ├── Picker/
│ │ │ │ │ ├── PickerTableViewCell.swift
│ │ │ │ │ ├── PickerTableViewCell.xib
│ │ │ │ │ └── ViewModels.swift
│ │ │ │ ├── SettingScreenViewController.swift
│ │ │ │ └── TestMode/
│ │ │ │ ├── TestModeTableViewCell.swift
│ │ │ │ └── TestModeTableViewCell.xib
│ │ │ └── Utils/
│ │ │ ├── AdUtils.swift
│ │ │ ├── BottomBarView.swift
│ │ │ ├── BottomBarView.xib
│ │ │ └── NavigationController.swift
│ │ ├── FANSample.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcshareddata/
│ │ │ └── xcschemes/
│ │ │ └── FANSample.xcscheme
│ │ ├── FANSample.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ ├── Podfile
│ │ └── README.md
│ └── README.md
└── python/
└── ReportingAPISamples/
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.md
├── PATENTS.md
├── README.md
├── adnw_examples.py
├── adnw_exception.py
├── adnw_params.py
├── adnw_requests.py
├── adnw_response.py
└── adnw_utils.py
================================================
FILE CONTENTS
================================================
================================================
FILE: .github/workflows/main.yml
================================================
name: Close new issues with template
on:
issues:
types: [opened]
jobs:
close-new-issues:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/github-script@v3
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
msg = `Dear developers. You will not be able to create new bug reports on GitHub after 28 April, and existing tickets will be automatically closed.\n
Instead, please use the bug report (https://developers.facebook.com/support/bugs/) tool to report a bug on Audience Network. Our engineers will get back to you as soon as possible.\n
If you have any other questions or suggestions relating to Facebook Audience Network, please use the online publisher support portal (https://www.facebook.com/business/publishersupport?hc_location=ufi) to submit a request.`
issue = await github.issues.get({
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: context.issue.number,
});
await github.issues.createComment({
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: context.issue.number,
body: msg,
});
await github.issues.update({
owner: context.issue.owner,
repo: context.issue.repo,
issue_number: context.issue.number,
state: "closed"
});
================================================
FILE: .gitignore
================================================
.DS_Store
xcuserdata/
*.xcuserdatad
*.xcuserstate
*.hmap
*.ipa
*.dSYM.zip
*.dSYM
Pods/
build/
DerivedData/
================================================
FILE: CONTRIBUTING.md
================================================
<H1>Contributing to audience-network-support</H1>
We want to make contributing to this project as easy and transparent as possible.
<h2>Pull Requests</h2>
We actively welcome your pull requests.
<ul>
<li>Fork the repo and create your branch from master.</li>
<li>If you've changed APIs, update the documentation.</li>
<li>If you haven't already, complete the Contributor License Agreement ("CLA").</li>
</ul>
<h2>Contributor License Agreement ("CLA")</h2>
In order to accept your pull request, we need you to submit a CLA. You only need to do this once to work on any of Facebook's open source projects.
Complete your CLA here: <a href="https://code.facebook.com/cla">https://code.facebook.com/cla</a>
<h2>Issues</h2>
We use GitHub issues to track public bugs. Please ensure your description is clear and has sufficient instructions to be able to reproduce the issue.
Facebook has a <a href="https://www.facebook.com/whitehat">bounty program</a> for the safe disclosure of security bugs. In those cases, please go through the process outlined on that page and do not file a public issue.
================================================
FILE: LICENSE
================================================
Copyright (c) 2016-present, Facebook, Inc. All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.
As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Developer Principles and Policies
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: README.md
================================================
# Audience Network Samples
In this repository there are sample code that demonstrates how to use Facebook [Audience Network](https://developers.facebook.com/docs/audience-network).
## Samples
* [Android](./samples/android)
* [iOS](./samples/ios)
* [Facebook Audience Reporting API Samples](./samples/python)
## Support
You can see our [developers' site][1] for documentation on using the SDK.
From 28 April 2021, if you are having technical issues or experiencing bugs, please use the [bug report][2] tool to report a bug on `Audience Network`. Our engineers will get back to you as soon as possible.
If you have any other questions or suggestions relating to Facebook Audience Network, please use the online [publisher support portal][3] to submit a request.
[1]: https://developers.facebook.com/docs/audience-network
[2]: https://developers.facebook.com/support/bugs/
[3]: https://www.facebook.com/business/publishersupport?hc_location=ufi
================================================
FILE: samples/android/.gitignore
================================================
admob.xml
# Built application files
*.apk
*.ap_
# Files for the ART/Dalvik VM
*.dex
# Java class files
*.class
# Generated files
bin/
gen/
out/
# Gradle files
.gradle/
gradle/
build/
# Local configuration file (sdk path, etc)
local.properties
# Proguard folder generated by Eclipse
proguard/
# Log Files
*.log
# Android Studio Navigation editor temp files
.navigation/
# Android Studio captures folder
captures/
# Intellij
*.iml
.idea
# Keystore files
*.jks
# External native build folder generated in Android Studio 2.2 and later
.externalNativeBuild
google-services.json
================================================
FILE: samples/android/AdUnitsSample/.gitignore
================================================
BUCK
*.iml
.gradle
/local.properties
/.idea/caches
/.idea/libraries
/.idea/modules.xml
/.idea/workspace.xml
/.idea/navEditor.xml
/.idea/assetWizardSettings.xml
.DS_Store
/build
/captures
.externalNativeBuild
================================================
FILE: samples/android/AdUnitsSample/LICENSE
================================================
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.
As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Platform Policy
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: samples/android/AdUnitsSample/build.gradle
================================================
apply plugin: 'com.android.application'
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation(name: 'AudienceNetwork', ext: 'aar')
implementation(name: 'DebugSettings', ext: 'aar')
implementation "androidx.legacy:legacy-support-v4:$project.ANDROIDX_VERSION"
implementation "androidx.recyclerview:recyclerview:$project.ANDROIDX_VERSION"
implementation "androidx.appcompat:appcompat:$project.ANDROIDX_VERSION"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.google.android.gms:play-services-basement:$project.ANDROID_GOOGLE_PLAY_SERVICES_VERSION"
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'com.facebook.samples.AdUnitsSample'
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 1
versionName '1.0'
rootProject.ext.variantRelease = false
}
lintOptions {
abortOnError false
}
}
================================================
FILE: samples/android/AdUnitsSample/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in /Users/songqian/android-sdk-macosx/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# Add any project specific keep options here:
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
================================================
FILE: samples/android/AdUnitsSample/src/main/AndroidManifest.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.facebook.samples.AdUnitsSample"
xmlns:android="http://schemas.android.com/apk/res/android">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<application
android:name=".AdUnitsSampleApplication"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:networkSecurityConfig="@xml/network_security_config"
android:localeConfig="@xml/locales_config"
>
<activity
android:name=".AdUnitsSampleActivity"
android:label="@string/app_name"
android:exported="false"
/>
<activity
android:name=".SampleListActivity"
android:exported="false"
/>
<activity
android:name=".SplashActivity"
android:noHistory="true"
android:exported="true"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.facebook.samples.ads.debugsettings.DebugSettingsActivity"
android:exported="false"
/>
</application>
</manifest>
================================================
FILE: samples/android/AdUnitsSample/src/main/AndroidManifestVariables.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.facebook.samples.AdUnitsSample">
<!-- Fake manifest file to define list of BUCK variables -->
<uses-sdk
android:minSdkVersion="21"
android:targetSdkVersion="36" />
</manifest>
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleActivity.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.widget.LinearLayout;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentActivity;
import com.facebook.common.preconditions.Preconditions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.fragments.BannerFragment;
import com.facebook.samples.AdUnitsSample.fragments.InterstitialFragment;
import com.facebook.samples.AdUnitsSample.fragments.MultiLoadInterstitialFragment;
import com.facebook.samples.AdUnitsSample.fragments.NativeAdHScrollFragment;
import com.facebook.samples.AdUnitsSample.fragments.NativeAdRecyclerFragment;
import com.facebook.samples.AdUnitsSample.fragments.NativeAdSampleFragment;
import com.facebook.samples.AdUnitsSample.fragments.NativeAdTemplateFragment;
import com.facebook.samples.AdUnitsSample.fragments.NativeBannerAdFragment;
import com.facebook.samples.AdUnitsSample.fragments.NativeBannerAdTemplateFragment;
import com.facebook.samples.AdUnitsSample.fragments.RectangleFragment;
import com.facebook.samples.AdUnitsSample.fragments.RewardedInterstitialFragment;
import com.facebook.samples.AdUnitsSample.fragments.RewardedVideoFragment;
import com.facebook.samples.ads.debugsettings.DebugSettingsActivity;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class AdUnitsSampleActivity extends FragmentActivity {
public static final String SAMPLE_TYPE = "SAMPLE_TYPE";
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If you call AudienceNetworkAds.buildInitSettings(Context).initialize()
// in Application.onCreate() this call is not really necessary.
// Otherwise call initialize() onCreate() of all Activities that contain ads or
// from onCreate() of your Splash Activity.
AudienceNetworkInitializeHelper.initialize(this);
setContentView(R.layout.activity_ad_sample);
LinearLayout rootLayout = findViewById(R.id.activity_ad_sample);
// added check for Android 35 to fix system toolbar issue
// used hard coded value, as VANILLA_ICE_CREAM won't be available for older versions
if (rootLayout != null && android.os.Build.VERSION.SDK_INT >= 35) {
rootLayout.setFitsSystemWindows(true);
}
if (savedInstanceState != null) {
return;
}
Intent intent = getIntent();
String sampleType = intent.getStringExtra(SAMPLE_TYPE);
Fragment fragment = null;
if (sampleType == null) {
return;
}
// Basic ad unit sample types
AdUnitsSampleType type = AdUnitsSampleType.getSampleTypeFromName(sampleType);
if (type != null) {
switch (type) {
case BANNER:
fragment = new BannerFragment();
break;
case RECTANGLE:
fragment = new RectangleFragment();
break;
case INTERSTITIAL:
fragment = new InterstitialFragment();
break;
case MULTI_LOAD_INTERSTITIAL:
fragment = new MultiLoadInterstitialFragment();
break;
case REWARDED_VIDEO:
fragment = new RewardedVideoFragment();
break;
case REWARDED_INTERSTITIAL:
fragment = new RewardedInterstitialFragment();
break;
case NATIVE:
fragment = new NativeAdSampleFragment();
break;
case NATIVE_BANNER:
fragment = NativeBannerAdFragment.newInstance(false);
break;
case NATIVE_BANNER_WITH_IMAGE_VIEW:
fragment = NativeBannerAdFragment.newInstance(true);
break;
case RECYCLERVIEW:
fragment = new NativeAdRecyclerFragment();
break;
case HSCROLL:
fragment = new NativeAdHScrollFragment();
break;
case TEMPLATE:
fragment = new NativeAdTemplateFragment();
break;
case BANNER_TEMPLATE:
fragment = new NativeBannerAdTemplateFragment();
break;
}
Preconditions.checkNotNull(fragment).setRetainInstance(true);
setTitle(type.getName());
getSupportFragmentManager()
.beginTransaction()
.add(R.id.fragment_container, fragment)
.commit();
}
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.ad_units_sample_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int i = item.getItemId();
if (i == R.id.debug_settings) {
startActivity(new Intent(getApplicationContext(), DebugSettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleApplication.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample;
import android.app.Application;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.ads.debugsettings.DebugSettings;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class AdUnitsSampleApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
DebugSettings.initialize(this);
AudienceNetworkInitializeHelper.initialize(this);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleType.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample;
import androidx.annotation.Nullable;
import com.facebook.infer.annotation.Nullsafe;
@Nullsafe(Nullsafe.Mode.LOCAL)
public enum AdUnitsSampleType {
BANNER("Banner"),
RECTANGLE("Rectangle"),
INTERSTITIAL("Interstitial"),
MULTI_LOAD_INTERSTITIAL("Multiple Interstitials"),
REWARDED_VIDEO("Rewarded Video"),
REWARDED_INTERSTITIAL("Rewarded Interstitial"),
NATIVE("Native Ad"),
NATIVE_BANNER("Native Banner Ad"),
RECYCLERVIEW("Native Ad in RecyclerView"),
HSCROLL("Native Ad in H-Scroll"),
TEMPLATE("Native Ad Template"),
BANNER_TEMPLATE("Native Banner Ad Template"),
NATIVE_BANNER_WITH_IMAGE_VIEW("Native Banner Ad With ImageView");
private final String mName;
AdUnitsSampleType(String mName) {
this.mName = mName;
}
public String getName() {
return this.mName;
}
public static @Nullable AdUnitsSampleType getSampleTypeFromName(String name) {
for (AdUnitsSampleType type : AdUnitsSampleType.values()) {
if (type.getName().contentEquals(name)) {
return type;
}
}
return null;
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AudienceNetworkInitializeHelper.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample;
import static com.facebook.ads.BuildConfig.DEBUG;
import android.content.Context;
import android.util.Log;
import com.facebook.ads.AdSettings;
import com.facebook.ads.AudienceNetworkAds;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.ads.debugsettings.DebugSettings;
/** Sample class that shows how to call initialize() method of Audience Network SDK. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class AudienceNetworkInitializeHelper implements AudienceNetworkAds.InitListener {
private final Context mContext;
private AudienceNetworkInitializeHelper(Context context) {
mContext = context;
}
/**
* It's recommended to call this method from Application.onCreate(). Otherwise you can call it
* from all Activity.onCreate() methods for Activities that contain ads.
*
* @param context Application or Activity.
*/
static void initialize(Context context) {
if (!AudienceNetworkAds.isInitialized(context)) {
if (DEBUG) {
AdSettings.turnOnSDKDebugger(context);
}
AudienceNetworkAds.buildInitSettings(context)
.withInitListener(new AudienceNetworkInitializeHelper(context))
.initialize();
}
}
@Override
public void onInitialized(AudienceNetworkAds.InitResult result) {
Log.d(AudienceNetworkAds.TAG, result.getMessage());
DebugSettings.onSDKInitialized(mContext);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/SampleListActivity.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.widget.AdapterView;
import androidx.fragment.app.Fragment;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.adapters.SampleAdapter;
import com.facebook.samples.ads.debugsettings.DebugSettingsActivity;
/** A simple {@link Fragment} subclass. */
@Nullsafe(Nullsafe.Mode.LOCAL)
public class SampleListActivity extends ListActivity {
private static final String TAG = SampleListActivity.class.getSimpleName();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setTitle(R.string.select_sample);
final SampleAdapter adapter = new SampleAdapter(SampleListActivity.this);
// Bind to our new adapter.
setListAdapter(adapter);
// added check for Android 35 to fix system toolbar issue
// used hard coded value, as VANILLA_ICE_CREAM won't be available for older versions
if (android.os.Build.VERSION.SDK_INT >= 35) {
getListView().setFitsSystemWindows(true);
}
getListView()
.setOnItemClickListener(
new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.e(TAG, "List item clicked: " + position);
SampleAdapter.Item item = (SampleAdapter.Item) adapter.getItem(position);
// NULLSAFE_FIXME[Nullable Dereference]
String sampleName = item.getTitle();
AdUnitsSampleType type = AdUnitsSampleType.getSampleTypeFromName(sampleName);
if (type != null) {
Intent intent = new Intent(SampleListActivity.this, AdUnitsSampleActivity.class);
intent.putExtra(AdUnitsSampleActivity.SAMPLE_TYPE, type.getName());
startActivity(intent);
}
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
MenuInflater inflater = getMenuInflater();
inflater.inflate(R.menu.ad_units_sample_menu, menu);
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
int i = item.getItemId();
if (i == R.id.debug_settings) {
startActivity(new Intent(getApplicationContext(), DebugSettingsActivity.class));
return true;
}
return super.onOptionsItemSelected(item);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/SplashActivity.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.view.Window;
import android.view.WindowManager;
import com.facebook.infer.annotation.Nullsafe;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class SplashActivity extends Activity {
private static final int SPLASH_TIME = 2000;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// If you call AudienceNetworkAds.buildInitSettings(Context).initialize()
// in Application.onCreate() this call is not really necessary.
// Otherwise call initialize() onCreate() of all Activities that contain ads or
// from onCreate() of your Splash Activity.
AudienceNetworkInitializeHelper.initialize(this);
// Hide title and nav bar, must be done before setContentView.
requestWindowFeature(Window.FEATURE_NO_TITLE);
getWindow()
// NULLSAFE_FIXME[Nullable Dereference]
.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
setContentView(R.layout.activity_splash);
final Handler handler = new Handler(Looper.getMainLooper());
handler.postDelayed(
new Runnable() {
@Override
public void run() {
Intent intent = new Intent(SplashActivity.this, SampleListActivity.class);
startActivity(intent);
}
},
SPLASH_TIME);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/adapters/NativeAdRecyclerAdapter.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.adapters;
import android.app.Activity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.AdOptionsView;
import com.facebook.ads.MediaView;
import com.facebook.ads.NativeAd;
import com.facebook.ads.NativeAdLayout;
import com.facebook.ads.NativeAdListener;
import com.facebook.ads.NativeAdsManager;
import com.facebook.common.preconditions.Preconditions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.AdUnitsSample.models.RecyclerPostItem;
import java.util.ArrayList;
import java.util.List;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeAdRecyclerAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> {
private List<RecyclerPostItem> mPostItems;
private List<NativeAd> mAdItems;
private NativeAdsManager mNativeAdsManager;
private Activity mActivity;
private static final int AD_DISPLAY_FREQUENCY = 5;
private static final int POST_TYPE = 0;
private static final int AD_TYPE = 1;
private static final String TAG = "NativeAdsManager";
public NativeAdRecyclerAdapter(
Activity activity, List<RecyclerPostItem> postItems, NativeAdsManager nativeAdsManager) {
mNativeAdsManager = nativeAdsManager;
mPostItems = postItems;
mAdItems = new ArrayList<>();
mActivity = activity;
}
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
if (viewType == AD_TYPE) {
NativeAdLayout inflatedView =
(NativeAdLayout)
LayoutInflater.from(parent.getContext())
.inflate(R.layout.native_ad_unit, parent, false);
return new AdHolder(inflatedView);
} else {
View inflatedView =
LayoutInflater.from(parent.getContext())
.inflate(R.layout.recycler_post_item, parent, false);
return new PostHolder(inflatedView);
}
}
@Override
public int getItemViewType(int position) {
return position % AD_DISPLAY_FREQUENCY == 0 ? AD_TYPE : POST_TYPE;
}
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
if (holder.getItemViewType() == AD_TYPE) {
NativeAd ad;
if (mAdItems.size() > position / AD_DISPLAY_FREQUENCY) {
ad = mAdItems.get(position / AD_DISPLAY_FREQUENCY);
} else {
ad =
mNativeAdsManager.nextNativeAd(
new NativeAdListener() {
@Override
public void onMediaDownloaded(Ad ad) {
// ignore
}
@Override
public void onError(Ad ad, AdError error) {
// ignore
}
@Override
public void onAdLoaded(Ad ad) {
// ignore
}
@Override
public void onAdClicked(Ad ad) {
Log.i(TAG, ((NativeAd) ad).getAdvertiserName() + " Ad Clicked");
}
@Override
public void onLoggingImpression(Ad ad) {
Log.i(TAG, ((NativeAd) ad).getAdvertiserName() + " Ad Impression");
}
});
if (!Preconditions.checkNotNull(ad).isAdInvalidated()) {
mAdItems.add(ad);
} else {
Log.w(NativeAdRecyclerAdapter.class.getSimpleName(), "Ad is invalidated!");
}
}
AdHolder adHolder = (AdHolder) holder;
adHolder.adChoicesContainer.removeAllViews();
if (ad != null) {
adHolder.tvAdTitle.setText(ad.getAdvertiserName());
adHolder.tvAdBody.setText(ad.getAdBodyText());
adHolder.tvAdSocialContext.setText(ad.getAdSocialContext());
adHolder.tvAdSponsoredLabel.setText(R.string.sponsored);
adHolder.btnAdCallToAction.setText(ad.getAdCallToAction());
adHolder.btnAdCallToAction.setVisibility(
ad.hasCallToAction() ? View.VISIBLE : View.INVISIBLE);
AdOptionsView adOptionsView = new AdOptionsView(mActivity, ad, adHolder.nativeAdLayout);
adHolder.adChoicesContainer.addView(adOptionsView, 0);
List<View> clickableViews = new ArrayList<>();
clickableViews.add(adHolder.ivAdIcon);
clickableViews.add(adHolder.mvAdMedia);
clickableViews.add(adHolder.btnAdCallToAction);
ad.registerViewForInteraction(
adHolder.nativeAdLayout, adHolder.mvAdMedia, adHolder.ivAdIcon, clickableViews);
}
} else {
PostHolder postHolder = (PostHolder) holder;
// Calculate where the next postItem index is by subtracting ads we've shown.
int index = position - (position / AD_DISPLAY_FREQUENCY) - 1;
RecyclerPostItem postItem = mPostItems.get(index);
postHolder.tvPostContent.setText(postItem.getPostContent());
}
}
@Override
public int getItemCount() {
return mPostItems.size() + mAdItems.size();
}
private static class PostHolder extends RecyclerView.ViewHolder {
TextView tvPostContent;
PostHolder(View view) {
super(view);
// NULLSAFE_FIXME[Field Not Nullable]
tvPostContent = view.findViewById(R.id.tvPostContent);
}
}
private static class AdHolder extends RecyclerView.ViewHolder {
NativeAdLayout nativeAdLayout;
MediaView mvAdMedia;
MediaView ivAdIcon;
TextView tvAdTitle;
TextView tvAdBody;
TextView tvAdSocialContext;
TextView tvAdSponsoredLabel;
Button btnAdCallToAction;
LinearLayout adChoicesContainer;
AdHolder(NativeAdLayout adLayout) {
super(adLayout);
nativeAdLayout = adLayout;
// NULLSAFE_FIXME[Field Not Nullable]
mvAdMedia = adLayout.findViewById(R.id.native_ad_media);
// NULLSAFE_FIXME[Field Not Nullable]
tvAdTitle = adLayout.findViewById(R.id.native_ad_title);
// NULLSAFE_FIXME[Field Not Nullable]
tvAdBody = adLayout.findViewById(R.id.native_ad_body);
// NULLSAFE_FIXME[Field Not Nullable]
tvAdSocialContext = adLayout.findViewById(R.id.native_ad_social_context);
// NULLSAFE_FIXME[Field Not Nullable]
tvAdSponsoredLabel = adLayout.findViewById(R.id.native_ad_sponsored_label);
// NULLSAFE_FIXME[Field Not Nullable]
btnAdCallToAction = adLayout.findViewById(R.id.native_ad_call_to_action);
// NULLSAFE_FIXME[Field Not Nullable]
ivAdIcon = adLayout.findViewById(R.id.native_ad_icon);
// NULLSAFE_FIXME[Field Not Nullable]
adChoicesContainer = adLayout.findViewById(R.id.ad_choices_container);
}
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/adapters/SampleAdapter.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.adapters;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;
import com.facebook.common.preconditions.Preconditions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.AdUnitsSampleType;
import com.facebook.samples.AdUnitsSample.R;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class SampleAdapter extends ArrayAdapter<SampleAdapter.Item> {
public static class Item {
private String title;
private boolean isSection;
public Item(String title, boolean isSection) {
this.title = title;
this.isSection = isSection;
}
public Item(String title) {
this(title, false);
}
public String getTitle() {
return title;
}
}
private Context context;
private LayoutInflater inflater;
public SampleAdapter(Context context) {
super(context, 0);
this.context = context;
// Add the samples and section headers
add(new Item("Basic Samples", true));
add(new Item(AdUnitsSampleType.BANNER.getName()));
add(new Item(AdUnitsSampleType.RECTANGLE.getName()));
add(new Item(AdUnitsSampleType.INTERSTITIAL.getName()));
add(new Item(AdUnitsSampleType.MULTI_LOAD_INTERSTITIAL.getName()));
add(new Item(AdUnitsSampleType.REWARDED_VIDEO.getName()));
add(new Item(AdUnitsSampleType.REWARDED_INTERSTITIAL.getName()));
// Native ad samples
add(new Item("Native Ad Samples", true));
add(new Item(AdUnitsSampleType.NATIVE.getName()));
add(new Item(AdUnitsSampleType.NATIVE_BANNER.getName()));
add(new Item(AdUnitsSampleType.RECYCLERVIEW.getName()));
add(new Item(AdUnitsSampleType.HSCROLL.getName()));
add(new Item(AdUnitsSampleType.TEMPLATE.getName()));
add(new Item(AdUnitsSampleType.BANNER_TEMPLATE.getName()));
add(new Item(AdUnitsSampleType.NATIVE_BANNER_WITH_IMAGE_VIEW.getName()));
// NULLSAFE_FIXME[Field Not Nullable]
this.inflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
}
@Override
public View getView(int position, View convertView, ViewGroup parent) {
View v = convertView;
final Item item = (Item) getItem(position);
if (item != null) {
if (item.isSection) {
v = inflater.inflate(R.layout.list_item_section, parent, false);
v.setOnClickListener(null);
v.setOnLongClickListener(null);
v.setLongClickable(false);
final TextView title = (TextView) v.findViewById(R.id.list_item_section_text);
Preconditions.checkNotNull(title).setText(item.title);
} else {
v = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);
final TextView title = (TextView) v.findViewById(android.R.id.text1);
Preconditions.checkNotNull(title).setText(item.title);
}
}
return v;
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/BannerFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.AdListener;
import com.facebook.ads.AdSize;
import com.facebook.ads.AdView;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
public class BannerFragment extends Fragment implements AdListener {
private static final String TAG = BannerFragment.class.getSimpleName();
private RelativeLayout bannerAdContainer;
private Button refreshBannerButton;
private TextView bannerStatusLabel;
private @Nullable AdView bannerAdView;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_banner, container, false);
bannerStatusLabel = (TextView) view.findViewById(R.id.bannerStatusLabel);
bannerAdContainer = (RelativeLayout) view.findViewById(R.id.bannerAdContainer);
refreshBannerButton = (Button) view.findViewById(R.id.refreshBannerButton);
refreshBannerButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
loadAdView();
}
});
loadAdView();
return view;
}
@Override
public void onDestroyView() {
bannerAdContainer.removeView(bannerAdView);
super.onDestroyView();
}
@Override
public void onDestroy() {
if (bannerAdView != null) {
bannerAdView.destroy();
bannerAdView = null;
}
super.onDestroy();
}
private void loadAdView() {
if (bannerAdView != null) {
bannerAdView.destroy();
bannerAdView = null;
}
// Update progress message
setLabel(getString(R.string.loading_status));
// Create a banner's ad view with a unique placement ID (generate your own on the Facebook
// app settings). Use different ID for each ad placement in your app.
boolean isTablet = getResources().getBoolean(R.bool.is_tablet);
bannerAdView =
new AdView(
this.getActivity(),
"YOUR_PLACEMENT_ID",
isTablet ? AdSize.BANNER_HEIGHT_90 : AdSize.BANNER_HEIGHT_50);
// Reposition the ad and add it to the view hierarchy.
bannerAdContainer.addView(bannerAdView);
// Initiate a request to load an ad.
bannerAdView.loadAd(bannerAdView.buildLoadAdConfig().withAdListener(this).build());
}
@Override
public void onError(Ad ad, AdError error) {
if (ad == bannerAdView) {
setLabel("Ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdLoaded(Ad ad) {
if (ad == bannerAdView) {
setLabel("");
}
}
@Override
public void onAdClicked(Ad ad) {
DebugToast.show(requireActivity(), "Ad Clicked", Toast.LENGTH_SHORT);
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
}
private void setLabel(String status) {
bannerStatusLabel.setText(status);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/InterstitialFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.CacheFlag;
import com.facebook.ads.InterstitialAd;
import com.facebook.ads.InterstitialAdExtendedListener;
import com.facebook.ads.RewardData;
import com.facebook.common.preconditions.Preconditions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
import java.util.EnumSet;
import javax.annotation.Nullable;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class InterstitialFragment extends Fragment implements InterstitialAdExtendedListener {
private static final String TAG = InterstitialFragment.class.getSimpleName();
private TextView interstitialAdStatusLabel;
private Button loadInterstitialButton;
private Button showInterstitialButton;
@Nullable private InterstitialAd interstitialAd;
private String statusLabel = "";
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_interstitial, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
interstitialAdStatusLabel = (TextView) view.findViewById(R.id.interstitialAdStatusLabel);
// NULLSAFE_FIXME[Field Not Nullable]
loadInterstitialButton = (Button) view.findViewById(R.id.loadInterstitialButton);
// NULLSAFE_FIXME[Field Not Nullable]
showInterstitialButton = (Button) view.findViewById(R.id.showInterstitialButton);
loadInterstitialButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (interstitialAd != null) {
interstitialAd.destroy();
interstitialAd = null;
}
setLabel("Loading interstitial ad...");
// Create the interstitial unit with a placement ID (generate your own on the Facebook
// app settings).
// Use different ID for each ad placement in your app.
interstitialAd =
// NULLSAFE_FIXME[Parameter Not Nullable]
new InterstitialAd(InterstitialFragment.this.getActivity(), "YOUR_PLACEMENT_ID");
// Load a new interstitial.
InterstitialAd.InterstitialLoadAdConfig loadAdConfig =
interstitialAd
.buildLoadAdConfig()
// Set a listener to get notified on changes
// or when the user interact with the ad.
.withAdListener(InterstitialFragment.this)
.withCacheFlags(EnumSet.of(CacheFlag.VIDEO))
.withRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD", 10))
.build();
interstitialAd.loadAd(loadAdConfig);
}
});
showInterstitialButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (interstitialAd == null
|| !interstitialAd.isAdLoaded()
|| interstitialAd.isAdInvalidated()) {
// Ad not ready to show.
setLabel("Ad not loaded. Click load to request an ad.");
} else {
// Ad was loaded, show it!
setLabel("");
interstitialAd.show();
}
}
});
return view;
}
@Override
public void onDestroy() {
if (interstitialAd != null) {
interstitialAd.destroy();
interstitialAd = null;
}
super.onDestroy();
}
@Override
public void onError(Ad ad, AdError error) {
if (ad == interstitialAd) {
setLabel("Interstitial ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdLoaded(Ad ad) {
if (ad == interstitialAd) {
setLabel("Ad loaded. Click show to present!");
}
}
@Override
public void onInterstitialDisplayed(Ad ad) {
showToast("Interstitial Displayed");
}
@Override
public void onInterstitialDismissed(Ad ad) {
showToast("Interstitial Dismissed");
// Cleanup.
Preconditions.checkNotNull(interstitialAd).destroy();
interstitialAd = null;
}
@Override
public void onAdClicked(Ad ad) {
showToast("Interstitial Clicked");
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
showToast("Interstitial Impression");
}
private void setLabel(String label) {
statusLabel = label;
if (interstitialAdStatusLabel != null) {
interstitialAdStatusLabel.setText(statusLabel);
}
}
@Override
public void onRewardedAdCompleted() {
showToast("Reward Received");
}
@Override
public void onRewardedAdServerSucceeded() {
showToast("Server success!");
}
@Override
public void onRewardedAdServerFailed() {
showToast("Server failure");
}
@Override
public void onInterstitialActivityDestroyed() {
showToast("Activity destroyed");
}
private void showToast(String message) {
Log.d(TAG, message);
if (isAdded()) {
DebugToast.show(requireActivity(), message, Toast.LENGTH_SHORT);
}
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/MultiLoadInterstitialFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.CacheFlag;
import com.facebook.ads.InterstitialAd;
import com.facebook.ads.InterstitialAdExtendedListener;
import com.facebook.ads.RewardData;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
import java.util.EnumSet;
public class MultiLoadInterstitialFragment extends Fragment
implements InterstitialAdExtendedListener {
private static final String TAG = MultiLoadInterstitialFragment.class.getSimpleName();
@Nullable private TextView mInterstitialAdStatusLabel;
@Nullable private Button mLoadInterstitialButton;
@Nullable private Button mShowInterstitialButton;
@Nullable private InterstitialAd mInterstitialAd;
@Nullable private TextView mInterstitialAdStatusLabel2;
@Nullable private Button mLoadInterstitialButton2;
@Nullable private Button mShowInterstitialButton2;
@Nullable private InterstitialAd mInterstitialAd2;
@Nullable private TextView mInterstitialAdStatusLabel3;
@Nullable private Button mLoadInterstitialButton3;
@Nullable private Button mShowInterstitialButton3;
@Nullable private InterstitialAd mInterstitialAd3;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_multi_load_interstitial, container, false);
mInterstitialAdStatusLabel = (TextView) view.findViewById(R.id.interstitialAdStatusLabel);
mLoadInterstitialButton = (Button) view.findViewById(R.id.loadInterstitialButton);
mShowInterstitialButton = (Button) view.findViewById(R.id.showInterstitialButton);
if (mInterstitialAdStatusLabel == null
|| mLoadInterstitialButton == null
|| mShowInterstitialButton == null) {
return view;
}
mLoadInterstitialButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd != null) {
mInterstitialAd.destroy();
mInterstitialAd = null;
}
setLabel(mInterstitialAdStatusLabel, "Loading interstitial ad...");
// Create the interstitial unit with a placement ID (generate your own on the Facebook
// app settings).
// Use different ID for each ad placement in your app.
mInterstitialAd =
new InterstitialAd(
MultiLoadInterstitialFragment.this.requireActivity(), "YOUR_PLACEMENT_ID");
// Load a new interstitial.
InterstitialAd.InterstitialLoadAdConfig loadAdConfig =
mInterstitialAd
.buildLoadAdConfig()
// Set a listener to get notified on changes
// or when the user interact with the ad.
.withAdListener(MultiLoadInterstitialFragment.this)
.withCacheFlags(EnumSet.of(CacheFlag.VIDEO))
.withRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD", 10))
.build();
mInterstitialAd.loadAd(loadAdConfig);
}
});
mShowInterstitialButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd == null
|| !mInterstitialAd.isAdLoaded()
|| mInterstitialAd.isAdInvalidated()) {
// Ad not ready to show.
setLabel(mInterstitialAdStatusLabel, "Ad not loaded. Click load to request an ad.");
} else {
// Ad was loaded, show it!
mInterstitialAd.show();
setLabel(mInterstitialAdStatusLabel, "");
}
}
});
mInterstitialAdStatusLabel2 = (TextView) view.findViewById(R.id.interstitialAdStatusLabel2);
mLoadInterstitialButton2 = (Button) view.findViewById(R.id.loadInterstitialButton2);
mShowInterstitialButton2 = (Button) view.findViewById(R.id.showInterstitialButton2);
if (mInterstitialAdStatusLabel2 == null
|| mLoadInterstitialButton2 == null
|| mShowInterstitialButton2 == null) {
return view;
}
mLoadInterstitialButton2.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd2 != null) {
mInterstitialAd2.destroy();
mInterstitialAd2 = null;
}
setLabel(mInterstitialAdStatusLabel2, "Loading interstitial ad...");
// Create the interstitial unit with a placement ID (generate your own on the Facebook
// app settings).
// Use different ID for each ad placement in your app.
mInterstitialAd2 =
new InterstitialAd(
MultiLoadInterstitialFragment.this.requireActivity(), "YOUR_PLACEMENT_ID");
// Load a new interstitial.
InterstitialAd.InterstitialLoadAdConfig loadAdConfig =
mInterstitialAd2
.buildLoadAdConfig()
// Set a listener to get notified on changes
// or when the user interact with the ad.
.withAdListener(MultiLoadInterstitialFragment.this)
.withCacheFlags(EnumSet.of(CacheFlag.VIDEO))
.withRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD", 10))
.build();
mInterstitialAd2.loadAd(loadAdConfig);
}
});
mShowInterstitialButton2.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd2 == null
|| !mInterstitialAd2.isAdLoaded()
|| mInterstitialAd2.isAdInvalidated()) {
// Ad not ready to show.
setLabel(mInterstitialAdStatusLabel2, "Ad not loaded. Click load to request an ad.");
} else {
// Ad was loaded, show it!
mInterstitialAd2.show();
setLabel(mInterstitialAdStatusLabel2, "");
}
}
});
mInterstitialAdStatusLabel3 = (TextView) view.findViewById(R.id.interstitialAdStatusLabel3);
mLoadInterstitialButton3 = (Button) view.findViewById(R.id.loadInterstitialButton3);
mShowInterstitialButton3 = (Button) view.findViewById(R.id.showInterstitialButton3);
if (mInterstitialAdStatusLabel3 == null
|| mLoadInterstitialButton3 == null
|| mShowInterstitialButton3 == null) {
return view;
}
mLoadInterstitialButton3.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd3 != null) {
mInterstitialAd3.destroy();
mInterstitialAd3 = null;
}
setLabel(mInterstitialAdStatusLabel3, "Loading interstitial ad...");
// Create the interstitial unit with a placement ID (generate your own on the Facebook
// app settings).
// Use different ID for each ad placement in your app.
mInterstitialAd3 =
new InterstitialAd(
MultiLoadInterstitialFragment.this.requireActivity(), "YOUR_PLACEMENT_ID");
// Load a new interstitial.
InterstitialAd.InterstitialLoadAdConfig loadAdConfig =
mInterstitialAd3
.buildLoadAdConfig()
// Set a listener to get notified on changes
// or when the user interact with the ad.
.withAdListener(MultiLoadInterstitialFragment.this)
.withCacheFlags(EnumSet.of(CacheFlag.VIDEO))
.withRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD", 10))
.build();
mInterstitialAd3.loadAd(loadAdConfig);
}
});
mShowInterstitialButton3.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (mInterstitialAd3 == null
|| !mInterstitialAd3.isAdLoaded()
|| mInterstitialAd3.isAdInvalidated()) {
// Ad not ready to show.
setLabel(mInterstitialAdStatusLabel3, "Ad not loaded. Click load to request an ad.");
} else {
// Ad was loaded, show it!
mInterstitialAd3.show();
setLabel(mInterstitialAdStatusLabel3, "");
}
}
});
return view;
}
private void destroy(@Nullable InterstitialAd interstitialAd) {
if (interstitialAd != null) {
interstitialAd.destroy();
interstitialAd = null;
}
}
@Override
public void onDestroy() {
super.onDestroy();
}
@Override
public void onDestroyView() {
super.onDestroyView();
destroy(mInterstitialAd);
destroy(mInterstitialAd2);
destroy(mInterstitialAd3);
mInterstitialAdStatusLabel = null;
mInterstitialAdStatusLabel2 = null;
mInterstitialAdStatusLabel3 = null;
mLoadInterstitialButton = null;
mLoadInterstitialButton2 = null;
mLoadInterstitialButton3 = null;
mShowInterstitialButton = null;
mShowInterstitialButton2 = null;
mShowInterstitialButton3 = null;
}
@Override
public void onError(Ad ad, AdError error) {
if (ad == mInterstitialAd) {
setLabel(
mInterstitialAdStatusLabel, "Interstitial ad failed to load: " + error.getErrorMessage());
} else if (ad == mInterstitialAd2) {
setLabel(
mInterstitialAdStatusLabel2,
"Interstitial ad failed to load: " + error.getErrorMessage());
} else if (ad == mInterstitialAd3) {
setLabel(
mInterstitialAdStatusLabel3,
"Interstitial ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdLoaded(Ad ad) {
if (ad == mInterstitialAd) {
setLabel(mInterstitialAdStatusLabel, "Ad loaded. Click show to present!");
} else if (ad == mInterstitialAd2) {
setLabel(mInterstitialAdStatusLabel2, "Ad loaded. Click show to present!");
} else if (ad == mInterstitialAd3) {
setLabel(mInterstitialAdStatusLabel3, "Ad loaded. Click show to present!");
}
}
@Override
public void onInterstitialDisplayed(Ad ad) {
showToast("Interstitial Displayed");
}
@Override
public void onInterstitialDismissed(Ad ad) {
showToast("Interstitial Dismissed");
// Cleanup.
if (ad == mInterstitialAd) {
destroy(mInterstitialAd);
} else if (ad == mInterstitialAd2) {
destroy(mInterstitialAd2);
} else if (ad == mInterstitialAd3) {
destroy(mInterstitialAd3);
}
}
@Override
public void onAdClicked(Ad ad) {
showToast("Interstitial Clicked");
}
/** showing toast for tracking impression for manual testing */
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
showToast("Interstitial Impression");
}
private void setLabel(@Nullable TextView interstitialAdStatusLabel, String label) {
if (interstitialAdStatusLabel != null) {
interstitialAdStatusLabel.setText(label);
}
}
@Override
public void onRewardedAdCompleted() {}
@Override
public void onRewardedAdServerSucceeded() {}
@Override
public void onRewardedAdServerFailed() {}
@Override
public void onInterstitialActivityDestroyed() {
showToast("Activity destroyed");
}
private void showToast(String message) {
Log.d(TAG, message);
if (isAdded()) {
DebugToast.show(requireActivity(), message, Toast.LENGTH_SHORT);
}
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdHScrollFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.AdError;
import com.facebook.ads.NativeAd;
import com.facebook.ads.NativeAdScrollView;
import com.facebook.ads.NativeAdsManager;
import com.facebook.common.preconditions.Preconditions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeAdHScrollFragment extends Fragment implements NativeAdsManager.Listener {
private static final int NATIVE_AD_VIEW_HEIGHT_DP = 300;
private NativeAdsManager manager;
private @Nullable NativeAdScrollView scrollView;
private LinearLayout scrollViewContainer;
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_native_ad_hscroll, container, false);
// Create native options to enable or disable the different options on media
NativeAd.NativeOptions nativeOptions =
new NativeAd.NativeOptions()
.setDisableFullScreen(false)
.setHideMediaControls(false)
.setUnMuteVolume(false);
manager = new NativeAdsManager(requireActivity(), "YOUR_PLACEMENT_ID", 5, nativeOptions);
manager.setListener(this);
manager.loadAds(NativeAd.MediaCacheFlag.ALL);
Button reloadButton = (Button) view.findViewById(R.id.reload_hscroll);
Preconditions.checkNotNull(reloadButton)
.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
manager.loadAds();
}
});
// NULLSAFE_FIXME[Field Not Nullable]
scrollViewContainer = (LinearLayout) view.findViewById(R.id.hscroll_container);
return view;
}
@Override
public void onAdsLoaded() {
if (getActivity() == null) {
return;
}
DebugToast.show(getActivity(), "Ads loaded", Toast.LENGTH_SHORT);
if (scrollView != null) {
scrollViewContainer.removeView(scrollView);
}
scrollView = new NativeAdScrollView(getActivity(), manager, NATIVE_AD_VIEW_HEIGHT_DP);
scrollViewContainer.addView(scrollView);
}
@Override
public void onAdError(AdError error) {
DebugToast.show(requireActivity(), "Ad error: " + error.getErrorMessage(), Toast.LENGTH_SHORT);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdRecyclerFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.ads.AdError;
import com.facebook.ads.NativeAd;
import com.facebook.ads.NativeAdsManager;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.AdUnitsSample.adapters.NativeAdRecyclerAdapter;
import com.facebook.samples.AdUnitsSample.models.RecyclerPostItem;
import com.facebook.samples.AdUnitsSample.thirdparty.DividerItemDecoration.DividerItemDecoration;
import java.util.ArrayList;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeAdRecyclerFragment extends Fragment implements NativeAdsManager.Listener {
private ArrayList<RecyclerPostItem> mPostItemList;
private NativeAdsManager mNativeAdsManager;
private RecyclerView mRecyclerView;
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
// Create some dummy post items
mPostItemList = new ArrayList<>();
for (int i = 1; i <= 100; i++) {
mPostItemList.add(new RecyclerPostItem("RecyclerView Item #" + i));
}
String placement_id = "YOUR_PLACEMENT_ID";
// Create native options to enable or disable the different options on media
NativeAd.NativeOptions nativeOptions =
new NativeAd.NativeOptions()
.setDisableFullScreen(false)
.setHideMediaControls(false)
.setUnMuteVolume(false);
mNativeAdsManager = new NativeAdsManager(requireActivity(), placement_id, 5, nativeOptions);
mNativeAdsManager.loadAds();
mNativeAdsManager.setListener(this);
// Inflate the layout for this fragment
View view = inflater.inflate(R.layout.fragment_native_ad_recycler, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
mRecyclerView = (RecyclerView) view.findViewById(R.id.recyclerView);
return view;
}
@Override
public void onAdsLoaded() {
if (getActivity() == null) {
return;
}
mRecyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
RecyclerView.ItemDecoration itemDecoration =
new DividerItemDecoration(getActivity(), DividerItemDecoration.VERTICAL_LIST);
mRecyclerView.addItemDecoration(itemDecoration);
NativeAdRecyclerAdapter adapter =
new NativeAdRecyclerAdapter(getActivity(), mPostItemList, mNativeAdsManager);
mRecyclerView.setAdapter(adapter);
}
@Override
public void onAdError(AdError error) {}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdSampleFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.LinearLayout;
import android.widget.Switch;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdClosedListener;
import com.facebook.ads.AdError;
import com.facebook.ads.AdOptionsView;
import com.facebook.ads.MediaView;
import com.facebook.ads.MediaViewListener;
import com.facebook.ads.NativeAd;
import com.facebook.ads.NativeAdBase.NativeComponentTag;
import com.facebook.ads.NativeAdLayout;
import com.facebook.ads.NativeAdListener;
import com.facebook.common.preconditions.Preconditions;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
import java.util.ArrayList;
import java.util.List;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeAdSampleFragment extends Fragment implements NativeAdListener {
protected static final String TAG = NativeAdSampleFragment.class.getSimpleName();
private @Nullable TextView nativeAdStatus;
private @Nullable LinearLayout adChoicesContainer;
private @Nullable NativeAdLayout nativeAdLayout;
private @Nullable NativeAd nativeAd;
private @Nullable AdOptionsView adOptionsView;
// NULLSAFE_FIXME[Field Not Initialized]
private MediaView nativeAdMedia;
private NativeAd.NativeOptions mNativeOptions;
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_native_ad_sample, container, false);
nativeAdLayout = view.findViewById(R.id.native_ad_container);
nativeAdStatus = view.findViewById(R.id.native_ad_status);
adChoicesContainer = view.findViewById(R.id.ad_choices_container);
// Create native options to enable or disable the different options on media
mNativeOptions = new NativeAd.NativeOptions();
Switch disableFullScreenSwitch = view.findViewById(R.id.switch_fullscreen);
if (disableFullScreenSwitch != null) {
disableFullScreenSwitch.setOnCheckedChangeListener(
(compoundButton, isChecked) -> mNativeOptions.setDisableFullScreen(isChecked));
}
Switch unMuteSwitch = view.findViewById(R.id.switch_unmute);
if (unMuteSwitch != null) {
unMuteSwitch.setOnCheckedChangeListener(
(compoundButton, isChecked) -> mNativeOptions.setUnMuteVolume(isChecked));
}
Switch hideMediaControlsSwitch = view.findViewById(R.id.switch_hide_media_controls);
if (hideMediaControlsSwitch != null) {
hideMediaControlsSwitch.setOnCheckedChangeListener(
(compoundButton, isChecked) -> mNativeOptions.setHideMediaControls(isChecked));
}
Button showNativeAdButton = view.findViewById(R.id.load_native_ad_button);
Preconditions.checkNotNull(showNativeAdButton)
.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View view) {
if (nativeAdStatus != null) {
nativeAdStatus.setText(R.string.loading_status);
}
if (nativeAd != null) {
nativeAd.destroy();
}
// Create a native ad request with a unique placement ID (generate your own on the
// Facebook app settings). Use different ID for each ad placement in your app.
nativeAd = new NativeAd(requireActivity(), "YOUR_PLACEMENT_ID", mNativeOptions);
// When testing on a device, add its hashed ID to force test ads.
// The hash ID is printed to log cat when running on a device and loading an ad.
// AdSettings.addTestDevice("THE HASHED ID AS PRINTED TO LOG CAT");
// Initiate a request to load an ad.
nativeAd.loadAd(
nativeAd
.buildLoadAdConfig()
.withAdListener(NativeAdSampleFragment.this)
.build());
}
});
// if we already have loaded ad, render it
if (nativeAd != null) {
onAdLoaded(nativeAd);
}
return view;
}
@Override
public void onDestroyView() {
adChoicesContainer = null;
nativeAdLayout = null;
adOptionsView = null;
nativeAdStatus = null;
super.onDestroyView();
}
@Override
public void onError(Ad ad, AdError error) {
if (nativeAdStatus != null) {
nativeAdStatus.setText("Ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdClicked(Ad ad) {
showToast("Ad Clicked");
}
@Override
public void onLoggingImpression(Ad ad) {
showToast("Native Impression");
}
@Override
public void onMediaDownloaded(Ad ad) {
if (nativeAd == ad) {
Log.d(TAG, "onMediaDownloaded");
}
}
@Override
public void onAdLoaded(Ad ad) {
if (nativeAd == null || nativeAd != ad) {
// Race condition, load() called again before last ad was displayed
return;
}
if (nativeAdLayout == null) {
return;
}
// Unregister last ad
nativeAd.unregisterView();
if (nativeAdStatus != null) {
nativeAdStatus.setText("");
}
if (!nativeAd.isAdLoaded() || nativeAd.isAdInvalidated()) {
if (nativeAdStatus != null) {
nativeAdStatus.setText("Ad is not loaded or invalidated.");
}
return;
}
if (adChoicesContainer != null) {
// NULLSAFE_FIXME[Parameter Not Nullable]
adOptionsView = new AdOptionsView(getActivity(), nativeAd, nativeAdLayout);
adOptionsView.setOnAdClosedListener(
new AdClosedListener() {
@Override
public void onAdClosed() {
// Ad closed by user move to next ad
showToast("Ad closed by user!");
}
});
adChoicesContainer.removeAllViews();
adChoicesContainer.addView(adOptionsView, 0);
}
inflateAd(nativeAd, nativeAdLayout);
// Registering a touch listener to log which ad component receives the touch event.
// We always return false from onTouch so that we don't swallow the touch event (which
// would prevent click events from reaching the NativeAd control).
// The touch listener could be used to do animations.
nativeAd.setOnTouchListener(
new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int i = view.getId();
if (i == R.id.native_ad_call_to_action) {
Log.d(TAG, "Call to action button clicked");
} else if (i == R.id.native_ad_media) {
Log.d(TAG, "Main image clicked");
} else {
Log.d(TAG, "Other ad component clicked");
}
}
return false;
}
});
}
private void inflateAd(NativeAd nativeAd, View adView) {
Log.d(TAG, "Aspect ratio of ad: " + nativeAd.getAspectRatio());
// Create native UI using the ad metadata.
MediaView nativeAdIcon = adView.findViewById(R.id.native_ad_icon);
TextView nativeAdTitle = adView.findViewById(R.id.native_ad_title);
TextView nativeAdBody = adView.findViewById(R.id.native_ad_body);
TextView sponsoredLabel = adView.findViewById(R.id.native_ad_sponsored_label);
TextView nativeAdSocialContext = adView.findViewById(R.id.native_ad_social_context);
Button nativeAdCallToAction = adView.findViewById(R.id.native_ad_call_to_action);
// NULLSAFE_FIXME[Field Not Nullable]
nativeAdMedia = adView.findViewById(R.id.native_ad_media);
nativeAdMedia.setListener(getMediaViewListener());
// Setting the Text
Preconditions.checkNotNull(nativeAdSocialContext).setText(nativeAd.getAdSocialContext());
// NULLSAFE_FIXME[Nullable Dereference]
nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
// NULLSAFE_FIXME[Nullable Dereference]
nativeAdCallToAction.setVisibility(nativeAd.hasCallToAction() ? View.VISIBLE : View.INVISIBLE);
// NULLSAFE_FIXME[Nullable Dereference]
nativeAdTitle.setText(nativeAd.getAdvertiserName());
// NULLSAFE_FIXME[Nullable Dereference]
nativeAdBody.setText(nativeAd.getAdBodyText());
// NULLSAFE_FIXME[Nullable Dereference]
sponsoredLabel.setText(R.string.sponsored);
// You can use the following to specify the clickable areas.
List<View> clickableViews = new ArrayList<>();
clickableViews.add(nativeAdIcon);
clickableViews.add(nativeAdMedia);
clickableViews.add(nativeAdCallToAction);
nativeAd.registerViewForInteraction(
// NULLSAFE_FIXME[Parameter Not Nullable]
nativeAdLayout, nativeAdMedia, nativeAdIcon, clickableViews);
if (nativeAdMedia.isVideoContent()) {
showToast("This is video content!!!");
showToast("Video duration: " + nativeAdMedia.getVideoDuration());
}
// Optional: tag views
// NULLSAFE_FIXME[Parameter Not Nullable]
NativeComponentTag.tagView(nativeAdIcon, NativeComponentTag.AD_ICON);
// NULLSAFE_FIXME[Parameter Not Nullable]
NativeComponentTag.tagView(nativeAdTitle, NativeComponentTag.AD_TITLE);
// NULLSAFE_FIXME[Parameter Not Nullable]
NativeComponentTag.tagView(nativeAdBody, NativeComponentTag.AD_BODY);
NativeComponentTag.tagView(nativeAdSocialContext, NativeComponentTag.AD_SOCIAL_CONTEXT);
// NULLSAFE_FIXME[Parameter Not Nullable]
NativeComponentTag.tagView(nativeAdCallToAction, NativeComponentTag.AD_CALL_TO_ACTION);
}
@Override
public void onDestroy() {
if (nativeAdMedia != null) {
nativeAdMedia.destroy();
}
if (nativeAd != null) {
nativeAd.unregisterView();
nativeAd.destroy();
}
super.onDestroy();
}
private static MediaViewListener getMediaViewListener() {
return new MediaViewListener() {
@Override
public void onVolumeChange(MediaView mediaView, float volume) {
Log.i(TAG, "MediaViewEvent: Volume " + volume);
}
@Override
public void onPause(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: Paused");
}
@Override
public void onPlay(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: Play");
}
@Override
public void onFullscreenBackground(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: FullscreenBackground");
}
@Override
public void onFullscreenForeground(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: FullscreenForeground");
}
@Override
public void onExitFullscreen(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: ExitFullscreen");
}
@Override
public void onEnterFullscreen(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: EnterFullscreen");
}
@Override
public void onComplete(MediaView mediaView) {
Log.i(TAG, "MediaViewEvent: Completed");
}
};
}
private void showToast(String message) {
if (isAdded()) {
DebugToast.show(requireActivity(), message, Toast.LENGTH_SHORT);
}
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdTemplateFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import static android.view.ViewGroup.LayoutParams.MATCH_PARENT;
import android.app.Activity;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.SeekBar;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.NativeAd;
import com.facebook.ads.NativeAdListener;
import com.facebook.ads.NativeAdView;
import com.facebook.ads.NativeAdViewAttributes;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeAdTemplateFragment extends Fragment implements NativeAdListener {
private static final String TAG = NativeAdTemplateFragment.class.getSimpleName();
private static final int COLOR_LIGHT_GRAY = 0xff90949c;
private static final int COLOR_DARK_GRAY = 0xff4e5665;
private static final int COLOR_CTA_BLUE_BG = 0xff4080ff;
private static final int MIN_HEIGHT_DP = 200;
private static final int MAX_HEIGHT_DP = 500;
private static final int DEFAULT_HEIGHT_DP = 350;
private static final int DEFAULT_PROGRESS_DP = 50;
private @Nullable NativeAd mNativeAd;
private int mLayoutHeightDp = DEFAULT_HEIGHT_DP;
private int mAdBackgroundColor, mTitleColor, mCtaTextColor, mContentColor, mCtaBgColor;
private TextView mStatusText;
private ViewGroup mNativeAdContainer;
private Spinner mBackgroundColorSpinner;
private Button mShowCodeButton, mReloadButton;
private SeekBar mSeekBar;
@Nullable private View mAdView;
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_native_ad_template, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
mStatusText = view.findViewById(R.id.status);
// NULLSAFE_FIXME[Field Not Nullable]
mNativeAdContainer = view.findViewById(R.id.templateContainer);
// NULLSAFE_FIXME[Field Not Nullable]
mShowCodeButton = view.findViewById(R.id.showCodeButton);
// NULLSAFE_FIXME[Field Not Nullable]
mReloadButton = view.findViewById(R.id.reloadAdButton);
// NULLSAFE_FIXME[Field Not Nullable]
mBackgroundColorSpinner = view.findViewById(R.id.backgroundColorSpinner);
// NULLSAFE_FIXME[Field Not Nullable]
mSeekBar = view.findViewById(R.id.seekBar);
setUpLayoutBuilders();
setUpButtons();
createAndLoadNativeAd();
return view;
}
@Override
public void onAdLoaded(Ad ad) {
if (mNativeAd == null || mNativeAd != ad) {
// Race condition, load() called again before last ad was displayed
return;
}
mStatusText.setText(R.string.ad_loaded);
reloadAdContainer();
}
@Override
public void onError(Ad ad, AdError error) {
String msg = getResources().getString(R.string.ad_load_failed, error.getErrorMessage());
mStatusText.setText(msg);
}
@Override
public void onAdClicked(Ad ad) {
mStatusText.setText(R.string.ad_clicked);
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
}
@Override
public void onMediaDownloaded(Ad ad) {
Log.d(TAG, "onMediaDownloaded");
}
@Override
public void onDestroy() {
mNativeAd = null;
super.onDestroy();
}
private void createAndLoadNativeAd() {
// Create a native ad request with a unique placement ID
// (generate your own on the Facebook app settings).
// Use different ID for each ad placement in your app.
// NULLSAFE_FIXME[Parameter Not Nullable]
mNativeAd = new NativeAd(getActivity(), "YOUR_PLACEMENT_ID");
// Initiate a request to load an ad.
mNativeAd.loadAd(mNativeAd.buildLoadAdConfig().withAdListener(this).build());
mStatusText.setText(R.string.ad_loading);
}
private void reloadAdContainer() {
Activity activity = getActivity();
if (activity != null
&& mNativeAd != null
&& mNativeAd.isAdLoaded()
&& !mNativeAd.isAdInvalidated()) {
mNativeAdContainer.removeAllViews();
// Create a NativeAdViewAttributes object and set the attributes
NativeAdViewAttributes attributes =
new NativeAdViewAttributes()
.setBackgroundColor(mAdBackgroundColor)
.setTitleTextColor(mTitleColor)
.setDescriptionTextColor(mContentColor)
.setButtonBorderColor(mCtaTextColor)
.setButtonTextColor(mCtaTextColor)
.setButtonColor(mCtaBgColor);
// Use NativeAdView.render to generate the ad View
mAdView = NativeAdView.render(activity, mNativeAd, attributes);
mNativeAdContainer.addView(mAdView, new ViewGroup.LayoutParams(MATCH_PARENT, 0));
updateAdViewParams();
mShowCodeButton.setText(R.string.show_code);
}
}
private void setUpLayoutBuilders() {
ArrayAdapter<CharSequence> backgroundColorSpinnerAdapter =
ArrayAdapter.createFromResource(
// NULLSAFE_FIXME[Parameter Not Nullable]
getActivity(), R.array.background_color_array, android.R.layout.simple_spinner_item);
backgroundColorSpinnerAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
mBackgroundColorSpinner.setAdapter(backgroundColorSpinnerAdapter);
mBackgroundColorSpinner.setOnItemSelectedListener(
new android.widget.AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) {
int item = mBackgroundColorSpinner.getSelectedItemPosition();
switch (item) {
case 0:
mAdBackgroundColor = Color.WHITE;
mTitleColor = COLOR_DARK_GRAY;
mCtaTextColor = COLOR_CTA_BLUE_BG;
mContentColor = COLOR_LIGHT_GRAY;
mCtaBgColor = Color.WHITE;
break;
case 1:
mAdBackgroundColor = Color.BLACK;
mTitleColor = Color.WHITE;
mContentColor = Color.LTGRAY;
mCtaTextColor = Color.BLACK;
mCtaBgColor = Color.WHITE;
break;
}
reloadAdContainer();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
mSeekBar.setProgress(DEFAULT_PROGRESS_DP);
mSeekBar.setOnSeekBarChangeListener(
new SeekBar.OnSeekBarChangeListener() {
@Override
public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
mLayoutHeightDp = progress * ((MAX_HEIGHT_DP - MIN_HEIGHT_DP) / 100) + MIN_HEIGHT_DP;
updateAdViewParams();
}
@Override
public void onStartTrackingTouch(SeekBar seekBar) {}
@Override
public void onStopTrackingTouch(SeekBar seekBar) {}
});
}
private void updateAdViewParams() {
if (mAdView == null) {
return;
}
ViewGroup.LayoutParams params = mAdView.getLayoutParams();
params.height = (int) (Resources.getSystem().getDisplayMetrics().density * mLayoutHeightDp);
mAdView.setLayoutParams(params);
mAdView.requestLayout();
}
private void setUpButtons() {
mShowCodeButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mShowCodeButton.getText() == getResources().getString(R.string.show_ad)) {
reloadAdContainer();
} else {
showCodeInAdContainer();
}
}
});
mReloadButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
createAndLoadNativeAd();
}
});
}
private void showCodeInAdContainer() {
String[] lines = getResources().getStringArray(R.array.code_snippet_mediumrect_template);
StringBuilder codeSnippet = new StringBuilder();
for (String line : lines) {
codeSnippet.append(line).append("\r\n");
}
mNativeAdContainer.removeAllViews();
// NULLSAFE_FIXME[Parameter Not Nullable]
TextView code = new TextView(getActivity());
code.setText(codeSnippet);
code.setBackgroundColor(Color.WHITE);
code.setTextColor(Color.BLACK);
mNativeAdContainer.addView(code, 0);
mShowCodeButton.setText(R.string.show_ad);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeBannerAdFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.AdOptionsView;
import com.facebook.ads.MediaView;
import com.facebook.ads.NativeAdBase;
import com.facebook.ads.NativeAdLayout;
import com.facebook.ads.NativeAdListener;
import com.facebook.ads.NativeBannerAd;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
import java.util.ArrayList;
import java.util.List;
public class NativeBannerAdFragment extends Fragment implements NativeAdListener {
public static final String USE_IMAGE_VIEW = "useImageView";
private static final String TAG = NativeBannerAdFragment.class.getSimpleName();
private LinearLayout mAdView;
private FrameLayout mAdChoicesContainer;
private NativeAdLayout mNativeBannerAdContainer;
private @Nullable NativeBannerAd mNativeBannerAd;
private TextView mNativeBannerAdStatusLabel;
private boolean isAdViewAdded;
private boolean mUseImageView;
public static NativeBannerAdFragment newInstance(boolean useImageView) {
NativeBannerAdFragment myFragment = new NativeBannerAdFragment();
Bundle args = new Bundle();
args.putBoolean(USE_IMAGE_VIEW, useImageView);
myFragment.setArguments(args);
return myFragment;
}
@Override
public void onCreate(@Nullable Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Bundle arguments = getArguments();
if (arguments != null) {
mUseImageView = arguments.getBoolean(USE_IMAGE_VIEW, false);
}
}
@Nullable
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_native_banner_ad, container, false);
mNativeBannerAdContainer = view.findViewById(R.id.native_banner_ad_container);
mNativeBannerAdStatusLabel = view.findViewById(R.id.native_banner_status_label);
mAdView =
(LinearLayout)
inflater.inflate(R.layout.native_banner_ad_unit, mNativeBannerAdContainer, false);
mAdChoicesContainer = mAdView.findViewById(R.id.ad_choices_container);
Button showNativeBannerAdButton = view.findViewById(R.id.refresh_native_banner_button);
showNativeBannerAdButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
mNativeBannerAdStatusLabel.setText(getString(R.string.loading_status));
// Create a native ad request with a unique placement ID (generate your own on the
// Facebook app settings). Use different ID for each ad placement in your app.
mNativeBannerAd = new NativeBannerAd(getContext(), "YOUR_PLACEMENT_ID");
// When testing on a device, add its hashed ID to force test ads.
// The hash ID is printed to log cat when running on a device and loading an ad.
// AdSettings.addTestDevice("THE HASHED ID AS PRINTED TO LOG CAT");
// Initiate a request to load an ad.
mNativeBannerAd.loadAd(
mNativeBannerAd
.buildLoadAdConfig()
.withMediaCacheFlag(NativeAdBase.MediaCacheFlag.ALL)
.withAdListener(NativeBannerAdFragment.this)
.build());
}
});
// load the Native Banner when this fragment is created
// as the Banner in BannerFragment does.
showNativeBannerAdButton.performClick();
return view;
}
@Override
public void onError(Ad ad, AdError error) {
mNativeBannerAdStatusLabel.setText("Ad Failed to Load: " + error.getErrorMessage());
}
@Override
public void onAdLoaded(Ad ad) {
if (mNativeBannerAd == null || mNativeBannerAd != ad) {
// Race condition, load() called again before last ad was displayed
return;
}
if (!isAdViewAdded) {
isAdViewAdded = true;
mNativeBannerAdContainer.addView(mAdView);
}
// Unregister last ad
mNativeBannerAd.unregisterView();
mNativeBannerAdStatusLabel.setText("");
if (!mNativeBannerAd.isAdLoaded() || mNativeBannerAd.isAdInvalidated()) {
mNativeBannerAdStatusLabel.setText("Ad is not loaded or invalidated.");
return;
}
// Using the AdOptionsView is optional, but your native ad unit should
// be clearly delineated from the rest of your app content. See
// https://developers.facebook.com/docs/audience-network/guidelines/native-ads#native
// for details. We recommend using the AdOptionsView.
AdOptionsView adOptionsView =
new AdOptionsView(
getActivity(),
mNativeBannerAd,
mNativeBannerAdContainer,
AdOptionsView.Orientation.HORIZONTAL,
20);
mAdChoicesContainer.removeAllViews();
mAdChoicesContainer.addView(adOptionsView);
inflateAd(mNativeBannerAd, mAdView);
// Registering a touch listener to log which ad component receives the touch event.
// We always return false from onTouch so that we don't swallow the touch event (which
// would prevent click events from reaching the NativeAd control).
// The touch listener could be used to do animations.
mNativeBannerAd.setOnTouchListener(
new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN) {
int i = view.getId();
if (i == R.id.native_ad_call_to_action) {
Log.d(TAG, "Call to action button clicked");
} else if (i == R.id.native_icon_view) {
Log.d(TAG, "Main image clicked");
} else {
Log.d(TAG, "Other ad component clicked");
}
}
return false;
}
});
}
@Override
public void onAdClicked(Ad ad) {
DebugToast.show(requireActivity(), "Ad Clicked", Toast.LENGTH_SHORT);
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
}
@Override
public void onMediaDownloaded(Ad ad) {
Log.d(TAG, "onMediaDownloaded");
}
private void inflateAd(NativeBannerAd nativeBannerAd, View adView) {
// Create native UI using the ad metadata.
TextView nativeAdTitle = adView.findViewById(R.id.native_ad_title);
TextView nativeAdSocialContext = adView.findViewById(R.id.native_ad_social_context);
TextView sponsoredLabel = adView.findViewById(R.id.native_ad_sponsored_label);
Button nativeAdCallToAction = adView.findViewById(R.id.native_ad_call_to_action);
// Setting the Text
nativeAdCallToAction.setText(nativeBannerAd.getAdCallToAction());
nativeAdCallToAction.setVisibility(
nativeBannerAd.hasCallToAction() ? View.VISIBLE : View.INVISIBLE);
nativeAdTitle.setText(nativeBannerAd.getAdvertiserName());
nativeAdSocialContext.setText(nativeBannerAd.getAdSocialContext());
// You can use the following to specify the clickable areas.
List<View> clickableViews = new ArrayList<>();
clickableViews.add(nativeAdCallToAction);
MediaView nativeAdIconView = adView.findViewById(R.id.native_icon_view);
ImageView nativeImageViewAdIconView = adView.findViewById(R.id.image_view_icon_view);
if (mUseImageView) {
nativeAdIconView.setVisibility(View.GONE);
nativeImageViewAdIconView.setVisibility(View.VISIBLE);
nativeBannerAd.registerViewForInteraction(
mNativeBannerAdContainer, nativeImageViewAdIconView, clickableViews);
} else { // use MediaView
nativeAdIconView.setVisibility(View.VISIBLE);
nativeImageViewAdIconView.setVisibility(View.GONE);
nativeBannerAd.registerViewForInteraction(
mNativeBannerAdContainer, nativeAdIconView, clickableViews);
}
sponsoredLabel.setText(R.string.sponsored);
}
@Override
public void onDestroy() {
if (mNativeBannerAd != null) {
mNativeBannerAd.unregisterView();
mNativeBannerAd = null;
}
super.onDestroy();
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeBannerAdTemplateFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.TextView;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.NativeAdListener;
import com.facebook.ads.NativeAdViewAttributes;
import com.facebook.ads.NativeBannerAd;
import com.facebook.ads.NativeBannerAdView;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class NativeBannerAdTemplateFragment extends Fragment implements NativeAdListener {
private static final String TAG = NativeBannerAdTemplateFragment.class.getSimpleName();
private static final int COLOR_LIGHT_GRAY = 0xff90949c;
private static final int COLOR_DARK_GRAY = 0xff4e5665;
private static final int COLOR_CTA_BLUE_BG = 0xff4080ff;
private @Nullable NativeBannerAd mNativeBannerAd;
private NativeBannerAdView.Type mViewType = NativeBannerAdView.Type.HEIGHT_100;
private int mAdBackgroundColor, mTitleColor, mLinkColor, mContentColor, mCtaBgColor;
private TextView mStatusText;
private ViewGroup mNativeAdContainer;
private Spinner mBackgroundColorSpinner;
private Spinner mAdViewTypeSpinner;
private Button mShowCodeButton;
@Override
public View onCreateView(
LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_native_banner_ad_template, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
mStatusText = view.findViewById(R.id.status);
// NULLSAFE_FIXME[Field Not Nullable]
mNativeAdContainer = view.findViewById(R.id.templateContainer);
// NULLSAFE_FIXME[Field Not Nullable]
mShowCodeButton = view.findViewById(R.id.showCodeButton);
// NULLSAFE_FIXME[Field Not Nullable]
mBackgroundColorSpinner = view.findViewById(R.id.backgroundColorSpinner);
// NULLSAFE_FIXME[Field Not Nullable]
mAdViewTypeSpinner = view.findViewById(R.id.adViewTypeSpinner);
ArrayAdapter<CharSequence> backgroundColorSpinnerAdapter =
ArrayAdapter.createFromResource(
// NULLSAFE_FIXME[Parameter Not Nullable]
getActivity(), R.array.background_color_array, android.R.layout.simple_spinner_item);
backgroundColorSpinnerAdapter.setDropDownViewResource(
android.R.layout.simple_spinner_dropdown_item);
mBackgroundColorSpinner.setAdapter(backgroundColorSpinnerAdapter);
ArrayAdapter<CharSequence> adViewTypeSpinnerAdapter =
ArrayAdapter.createFromResource(
// NULLSAFE_FIXME[Parameter Not Nullable]
getActivity(), R.array.ad_bannerview_type_array, android.R.layout.simple_spinner_item);
adViewTypeSpinnerAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mAdViewTypeSpinner.setAdapter(adViewTypeSpinnerAdapter);
setSpinnerListeners();
setButtonListeners();
createAndLoadNativeAd();
return view;
}
protected void createAndLoadNativeAd() {
// Create a native banner ad request with a unique placement ID
// (generate your own on the Facebook app settings).
// Use different ID for each ad placement in your app.
// NULLSAFE_FIXME[Parameter Not Nullable]
mNativeBannerAd = new NativeBannerAd(getContext(), "YOUR_PLACEMENT_ID");
// Initiate a request to load an ad.
mNativeBannerAd.loadAd(mNativeBannerAd.buildLoadAdConfig().withAdListener(this).build());
mStatusText.setText(R.string.ad_loading);
}
private void reloadAdContainer() {
Activity activity = getActivity();
if (activity != null
&& mNativeBannerAd != null
&& mNativeBannerAd.isAdLoaded()
&& !mNativeBannerAd.isAdInvalidated()) {
mNativeAdContainer.removeAllViews();
// Create a NativeAdViewAttributes object and set the attributes
NativeAdViewAttributes attributes =
new NativeAdViewAttributes(activity)
.setBackgroundColor(mAdBackgroundColor)
.setTitleTextColor(mTitleColor)
.setDescriptionTextColor(mContentColor)
.setButtonBorderColor(mCtaBgColor)
.setButtonTextColor(mLinkColor)
.setButtonColor(mCtaBgColor);
// Use NativeAdView.render to generate the ad View
View adView = NativeBannerAdView.render(activity, mNativeBannerAd, mViewType, attributes);
// Add adView to the container showing Ads
mNativeAdContainer.addView(adView, 0);
mNativeAdContainer.setBackgroundColor(Color.TRANSPARENT);
mShowCodeButton.setText(R.string.show_code);
}
}
private void setSpinnerListeners() {
mBackgroundColorSpinner.setOnItemSelectedListener(
new android.widget.AdapterView.OnItemSelectedListener() {
@Override
public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) {
int item = mBackgroundColorSpinner.getSelectedItemPosition();
switch (item) {
case 0:
mAdBackgroundColor = Color.WHITE;
mTitleColor = COLOR_DARK_GRAY;
mLinkColor = Color.WHITE;
mContentColor = COLOR_LIGHT_GRAY;
mCtaBgColor = COLOR_CTA_BLUE_BG;
break;
case 1:
mAdBackgroundColor = Color.BLACK;
mTitleColor = Color.WHITE;
mContentColor = Color.LTGRAY;
mLinkColor = Color.BLACK;
mCtaBgColor = Color.WHITE;
break;
}
reloadAdContainer();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
mAdViewTypeSpinner.setOnItemSelectedListener(
new android.widget.AdapterView.OnItemSelectedListener() {
public void onItemSelected(AdapterView<?> arg0, View view, int position, long id) {
int item = mAdViewTypeSpinner.getSelectedItemPosition();
if (item == 0) {
mViewType = NativeBannerAdView.Type.HEIGHT_50;
} else if (item == 1) {
mViewType = NativeBannerAdView.Type.HEIGHT_100;
} else if (item == 2) {
mViewType = NativeBannerAdView.Type.HEIGHT_120;
}
reloadAdContainer();
}
@Override
public void onNothingSelected(AdapterView<?> parent) {}
});
}
private void setButtonListeners() {
mShowCodeButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (mShowCodeButton.getText() == getResources().getString(R.string.show_ad)) {
reloadAdContainer();
} else {
showCodeInAdContainer();
}
}
});
}
private void showCodeInAdContainer() {
String[] lines = getResources().getStringArray(R.array.code_snippet_banner_template);
StringBuilder codeSnippet = new StringBuilder();
for (String line : lines) {
codeSnippet.append(line).append("\r\n");
}
mNativeAdContainer.removeAllViews();
// NULLSAFE_FIXME[Parameter Not Nullable]
TextView code = new TextView(getActivity());
code.setText(codeSnippet);
code.setBackgroundColor(Color.WHITE);
code.setTextColor(Color.BLACK);
mNativeAdContainer.addView(code, 0);
mShowCodeButton.setText(R.string.show_ad);
}
@Override
public void onAdLoaded(Ad ad) {
if (mNativeBannerAd == null || mNativeBannerAd != ad) {
// Race condition, load() called again before last ad was displayed
return;
}
mStatusText.setText(R.string.ad_loaded);
reloadAdContainer();
}
@Override
public void onError(Ad ad, AdError error) {
String msg = getResources().getString(R.string.ad_load_failed, error.getErrorMessage());
mStatusText.setText(msg);
}
@Override
public void onAdClicked(Ad ad) {
mStatusText.setText(R.string.ad_clicked);
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
}
@Override
public void onMediaDownloaded(Ad ad) {
Log.d(TAG, "onMediaDownloaded");
}
@Override
public void onDestroy() {
mNativeBannerAd = null;
super.onDestroy();
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RectangleFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.AdListener;
import com.facebook.ads.AdSize;
import com.facebook.ads.AdView;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class RectangleFragment extends Fragment implements AdListener {
private static final String TAG = RectangleFragment.class.getSimpleName();
private RelativeLayout rectangleAdContainer;
private Button refreshRectangleButton;
private TextView rectangleStatusLabel;
private @Nullable AdView rectangleAdView;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_rectangle, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
rectangleStatusLabel = (TextView) view.findViewById(R.id.rectangleStatusLabel);
// NULLSAFE_FIXME[Field Not Nullable]
rectangleAdContainer = (RelativeLayout) view.findViewById(R.id.rectangleAdContainer);
// NULLSAFE_FIXME[Field Not Nullable]
refreshRectangleButton = (Button) view.findViewById(R.id.refreshRectangleButton);
refreshRectangleButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
loadAdView();
}
});
loadAdView();
return view;
}
@Override
public void onDestroyView() {
rectangleAdContainer.removeView(rectangleAdView);
super.onDestroyView();
}
@Override
public void onDestroy() {
if (rectangleAdView != null) {
rectangleAdView.destroy();
rectangleAdView = null;
}
super.onDestroy();
}
private void loadAdView() {
if (rectangleAdView != null) {
rectangleAdView.destroy();
rectangleAdView = null;
}
// Update progress message
setLabel(getString(R.string.loading_status));
// Create a banner's ad view with a unique placement ID (generate your own on the Facebook
// app settings). Use different ID for each ad placement in your app.
// NULLSAFE_FIXME[Parameter Not Nullable]
rectangleAdView = new AdView(getActivity(), "YOUR_PLACEMENT_ID", AdSize.RECTANGLE_HEIGHT_250);
// Reposition the ad and add it to the view hierarchy.
rectangleAdContainer.addView(rectangleAdView);
// Initiate a request to load an ad.
rectangleAdView.loadAd(rectangleAdView.buildLoadAdConfig().withAdListener(this).build());
}
@Override
public void onError(Ad ad, AdError error) {
if (ad == rectangleAdView) {
setLabel("Ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdLoaded(Ad ad) {
if (ad == rectangleAdView) {
setLabel("");
}
}
@Override
public void onAdClicked(Ad ad) {
DebugToast.show(requireActivity(), "Ad Clicked", Toast.LENGTH_SHORT);
}
@Override
public void onLoggingImpression(Ad ad) {
Log.d(TAG, "onLoggingImpression");
}
private void setLabel(String status) {
rectangleStatusLabel.setText(status);
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RewardedInterstitialFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.RewardData;
import com.facebook.ads.RewardedInterstitialAd;
import com.facebook.ads.S2SRewardedInterstitialAdListener;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
import javax.annotation.Nullable;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class RewardedInterstitialFragment extends Fragment
implements S2SRewardedInterstitialAdListener {
private TextView rewardedInterstitialAdStatusLabel;
private Button loadRewardedInterstitialButton;
private Button showRewardedInterstitialButton;
@Nullable private RewardedInterstitialAd rewardedInterstitialAd;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_rewarded_interstitial, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
rewardedInterstitialAdStatusLabel =
(TextView) view.findViewById(R.id.rewardedInterstitialAdStatusLabel);
// NULLSAFE_FIXME[Field Not Nullable]
loadRewardedInterstitialButton =
(Button) view.findViewById(R.id.loadRewardedInterstitialButton);
// NULLSAFE_FIXME[Field Not Nullable]
showRewardedInterstitialButton =
(Button) view.findViewById(R.id.showRewardedInterstitialButton);
loadRewardedInterstitialButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rewardedInterstitialAd != null) {
rewardedInterstitialAd.destroy();
rewardedInterstitialAd = null;
}
rewardedInterstitialAd =
new RewardedInterstitialAd(
// NULLSAFE_FIXME[Parameter Not Nullable]
RewardedInterstitialFragment.this.getActivity(), "YOUR_PLACEMENT_ID");
RewardedInterstitialAd.RewardedInterstitialLoadAdConfig loadAdConfig =
rewardedInterstitialAd
.buildLoadAdConfig()
.withAdListener(RewardedInterstitialFragment.this)
.withFailOnCacheFailureEnabled(true)
.withRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD", 10))
.build();
rewardedInterstitialAd.loadAd(loadAdConfig);
setStatusLabelText("Loading rewarded interstitial ad...");
}
});
showRewardedInterstitialButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rewardedInterstitialAd == null
|| !rewardedInterstitialAd.isAdLoaded()
|| rewardedInterstitialAd.isAdInvalidated()) {
setStatusLabelText("Ad not loaded. Click load to request an ad.");
} else {
rewardedInterstitialAd.show();
setStatusLabelText("");
}
}
});
return view;
}
@Override
public void onError(Ad ad, AdError error) {
if (ad == rewardedInterstitialAd) {
setStatusLabelText("Rewarded interstitial ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdLoaded(Ad ad) {
if (ad == rewardedInterstitialAd) {
setStatusLabelText("Ad loaded. Click show to present!");
}
}
@Override
public void onAdClicked(Ad ad) {
showToast("Rewarded Interstitial Clicked");
}
private void setStatusLabelText(String label) {
if (rewardedInterstitialAdStatusLabel != null) {
rewardedInterstitialAdStatusLabel.setText(label);
}
}
private void showToast(String message) {
if (isAdded()) {
DebugToast.show(requireActivity(), message, Toast.LENGTH_SHORT);
}
}
@Override
public void onRewardedInterstitialCompleted() {
showToast("Rewarded Interstitial View Complete");
}
@Override
public void onLoggingImpression(Ad ad) {
showToast("Rewarded Interstitial Impression");
}
@Override
public void onRewardedInterstitialClosed() {
showToast("Rewarded Interstitial Closed");
}
@Override
public void onRewardServerFailed() {
showToast("Reward Video Server Failed");
}
@Override
public void onRewardServerSuccess() {
showToast("Reward Video Server Succeeded");
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RewardedVideoFragment.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.fragments;
import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import androidx.fragment.app.Fragment;
import com.facebook.ads.Ad;
import com.facebook.ads.AdError;
import com.facebook.ads.RewardData;
import com.facebook.ads.RewardedVideoAd;
import com.facebook.ads.S2SRewardedVideoAdListener;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.samples.AdUnitsSample.R;
import com.facebook.samples.ads.debugsettings.DebugToast;
import javax.annotation.Nullable;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class RewardedVideoFragment extends Fragment implements S2SRewardedVideoAdListener {
private static final String TAG = "RewardedVideoFragment";
private TextView rewardedVideoAdStatusLabel;
private Button loadRewardedVideoButton;
private Button showRewardedVideoButton;
@Nullable private RewardedVideoAd rewardedVideoAd;
@Override
public View onCreateView(
LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_rewarded_video, container, false);
// NULLSAFE_FIXME[Field Not Nullable]
rewardedVideoAdStatusLabel = (TextView) view.findViewById(R.id.rewardedVideoAdStatusLabel);
// NULLSAFE_FIXME[Field Not Nullable]
loadRewardedVideoButton = (Button) view.findViewById(R.id.loadRewardedVideoButton);
// NULLSAFE_FIXME[Field Not Nullable]
showRewardedVideoButton = (Button) view.findViewById(R.id.showRewardedVideoButton);
loadRewardedVideoButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rewardedVideoAd != null) {
rewardedVideoAd.destroy();
rewardedVideoAd = null;
}
rewardedVideoAd =
// NULLSAFE_FIXME[Parameter Not Nullable]
new RewardedVideoAd(RewardedVideoFragment.this.getActivity(), "YOUR_PLACEMENT_ID");
RewardedVideoAd.RewardedVideoLoadAdConfig loadAdConfig =
rewardedVideoAd
.buildLoadAdConfig()
.withAdListener(RewardedVideoFragment.this)
.withFailOnCacheFailureEnabled(true)
.withRewardData(new RewardData("YOUR_USER_ID", "YOUR_REWARD", 10))
.build();
rewardedVideoAd.loadAd(loadAdConfig);
setStatusLabelText("Loading rewarded video ad...");
}
});
showRewardedVideoButton.setOnClickListener(
new View.OnClickListener() {
@Override
public void onClick(View v) {
if (rewardedVideoAd == null
|| !rewardedVideoAd.isAdLoaded()
|| rewardedVideoAd.isAdInvalidated()) {
setStatusLabelText("Ad not loaded. Click load to request an ad.");
} else {
setStatusLabelText("");
rewardedVideoAd.show();
}
}
});
return view;
}
@Override
public void onError(Ad ad, AdError error) {
if (ad == rewardedVideoAd) {
setStatusLabelText("Rewarded video ad failed to load: " + error.getErrorMessage());
}
}
@Override
public void onAdLoaded(Ad ad) {
if (ad == rewardedVideoAd) {
setStatusLabelText("Ad loaded. Click show to present!");
}
}
@Override
public void onAdClicked(Ad ad) {
showToast("Rewarded Video Clicked");
}
private void setStatusLabelText(String label) {
if (rewardedVideoAdStatusLabel != null) {
rewardedVideoAdStatusLabel.setText(label);
}
}
private void showToast(String message) {
Log.d(TAG, message);
if (isAdded()) {
DebugToast.show(requireActivity(), message, Toast.LENGTH_SHORT);
}
}
@Override
public void onRewardedVideoCompleted() {
showToast("Rewarded Video View Complete");
}
@Override
public void onLoggingImpression(Ad ad) {
showToast("Rewarded Video Impression");
}
@Override
public void onRewardedVideoClosed() {
showToast("Rewarded Video Closed");
}
@Override
public void onRewardServerFailed() {
showToast("Reward Video Server Failed");
}
@Override
public void onRewardServerSuccess() {
showToast("Reward Video Server Succeeded");
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/models/RecyclerPostItem.java
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.AdUnitsSample.models;
import com.facebook.infer.annotation.Nullsafe;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class RecyclerPostItem {
// NULLSAFE_FIXME[Field Not Initialized]
private String postContent;
public RecyclerPostItem(String postContent) {
setPostContent(postContent);
}
public String getPostContent() {
return postContent;
}
public void setPostContent(String postContent) {
this.postContent = postContent;
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/thirdparty/DividerItemDecoration/DividerItemDecoration.java
================================================
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.facebook.samples.AdUnitsSample.thirdparty.DividerItemDecoration;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.view.View;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import com.facebook.infer.annotation.Nullsafe;
@Nullsafe(Nullsafe.Mode.LOCAL)
public class DividerItemDecoration extends RecyclerView.ItemDecoration {
private static final int[] ATTRS = new int[] {android.R.attr.listDivider};
public static final int HORIZONTAL_LIST = LinearLayoutManager.HORIZONTAL;
public static final int VERTICAL_LIST = LinearLayoutManager.VERTICAL;
private Drawable mDivider;
private int mOrientation;
public DividerItemDecoration(Context context, int orientation) {
final TypedArray a = context.obtainStyledAttributes(ATTRS);
// NULLSAFE_FIXME[Field Not Nullable]
mDivider = a.getDrawable(0);
a.recycle();
setOrientation(orientation);
}
public void setOrientation(int orientation) {
if (orientation != HORIZONTAL_LIST && orientation != VERTICAL_LIST) {
throw new IllegalArgumentException("invalid orientation");
}
mOrientation = orientation;
}
@Override
public void onDraw(Canvas c, RecyclerView parent) {
if (mOrientation == VERTICAL_LIST) {
drawVertical(c, parent);
} else {
drawHorizontal(c, parent);
}
}
public void drawVertical(Canvas c, RecyclerView parent) {
final int left = parent.getPaddingLeft();
final int right = parent.getWidth() - parent.getPaddingRight();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int top = child.getBottom() + params.bottomMargin;
final int bottom = top + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
public void drawHorizontal(Canvas c, RecyclerView parent) {
final int top = parent.getPaddingTop();
final int bottom = parent.getHeight() - parent.getPaddingBottom();
final int childCount = parent.getChildCount();
for (int i = 0; i < childCount; i++) {
final View child = parent.getChildAt(i);
final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
final int left = child.getRight() + params.rightMargin;
final int right = left + mDivider.getIntrinsicHeight();
mDivider.setBounds(left, top, right, bottom);
mDivider.draw(c);
}
}
@Override
public void getItemOffsets(Rect outRect, int itemPosition, RecyclerView parent) {
if (mOrientation == VERTICAL_LIST) {
outRect.set(0, 0, 0, mDivider.getIntrinsicHeight());
} else {
outRect.set(0, 0, mDivider.getIntrinsicWidth(), 0);
}
}
}
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/activity_ad_sample.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-present Facebook.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_ad_sample"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E4E5E8"
>
<LinearLayout
android:id="@+id/fragment_container"
android:layout_height="match_parent"
android:layout_width="match_parent"
android:orientation="vertical"
>
</LinearLayout>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/activity_sample_list.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/activity_sample_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#E4E5E8"
android:orientation="vertical"
>
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="@string/select_sample"
android:textColor="?android:attr/textColorPrimary"
android:textSize="24sp"
/>
<ListView
android:id="@android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/activity_splash.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/activity_splash"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#3B5998"
tools:context="com.facebook.samples.AdUnitsSample.SplashActivity"
>
<TextView
android:id="@+id/app_name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:text="@string/app_name"
android:textColor="@android:color/white"
android:textSize="36sp"
android:gravity="center"
/>
<TextView
android:id="@+id/copy_right"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:text="@string/copy_right"
android:textColor="@android:color/white"
android:textSize="12sp"
/>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_banner.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:id="@+id/bannerAdContainer"
android:layout_height="wrap_content"
android:layout_width="wrap_content"
android:layout_alignParentBottom="true"
/>
<Button
android:id="@+id/refreshBannerButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/refresh_now"
android:textSize="15sp"
android:layout_marginBottom="16dp"
android:layout_above="@id/bannerAdContainer"
android:layout_centerHorizontal="true"
/>
<TextView
android:id="@+id/bannerStatusLabel"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_width="match_parent"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
android:layout_above="@id/refreshBannerButton"
tools:text="@string/loading_status"
/>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_interstitial.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:id="@+id/interstitialAdStatusLabel"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
<LinearLayout
android:id="@+id/interstitialAdControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="50dp">
<Button
android:id="@+id/loadInterstitialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_interstitial"
android:textSize="15sp"
/>
<Button
android:id="@+id/showInterstitialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_ad"
android:textSize="15sp"
/>
</LinearLayout>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_multi_load_interstitial.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center_vertical"
>
<TextView
android:id="@+id/interstitialAdStatusLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
<LinearLayout
android:id="@+id/interstitialAdControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/loadInterstitialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_interstitial"
android:textSize="15sp"
/>
<Button
android:id="@+id/showInterstitialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_ad"
android:textSize="15sp"
/>
</LinearLayout>
<TextView
android:id="@+id/interstitialAdStatusLabel2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
<LinearLayout
android:id="@+id/interstitialAdControls2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/loadInterstitialButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_interstitial"
android:textSize="15sp"
/>
<Button
android:id="@+id/showInterstitialButton2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_ad"
android:textSize="15sp"
/>
</LinearLayout>
<TextView
android:id="@+id/interstitialAdStatusLabel3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
<LinearLayout
android:id="@+id/interstitialAdControls3"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/loadInterstitialButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_interstitial"
android:textSize="15sp"
/>
<Button
android:id="@+id/showInterstitialButton3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_ad"
android:textSize="15sp"
/>
</LinearLayout>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_hscroll.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:gravity="center"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="50dp"
>
<LinearLayout
android:id="@+id/hscroll_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
</LinearLayout>
</ScrollView>
<Button
android:id="@+id/reload_hscroll"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_margin="2dp"
android:gravity="center"
android:text="@string/reload_native_ads_hscroll"
android:textSize="15sp"
/>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_recycler.xml
================================================
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context="com.facebook.samples.AdUnitsSample.fragments.NativeAdRecyclerFragment"
>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recyclerView"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="8dp"
android:paddingRight="8dp"
/>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_sample.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="8dp"
android:background="@android:color/white"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/bottom_container">
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="10dp"
>
<include layout="@layout/native_ad_unit"
android:id="@+id/native_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:paddingBottom="5dp"/>
</ScrollView>
</LinearLayout>
<LinearLayout
android:id="@+id/bottom_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@android:color/background_light"
android:orientation="vertical"
android:paddingBottom="2dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<Button
android:id="@+id/load_native_ad_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_native_ad"
android:textSize="12sp"
/>
<TextView
android:id="@+id/native_ad_status"
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:gravity="center"
android:textColor="@android:color/darker_gray"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<Switch
android:id="@+id/switch_fullscreen"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Disable fullscreen"
android:textSize="12sp"
/>
<Switch
android:id="@+id/switch_unmute"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Unmute video"
android:textSize="12sp"
/>
<Switch
android:id="@+id/switch_hide_media_controls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:text="Hide media controls"
android:textSize="12sp"
/>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_template.xml
================================================
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nativeAdTemplateContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame"
android:clickable="true"
android:gravity="end"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/footer"
android:background="@android:color/transparent"
android:padding="8dp"
>
<LinearLayout
android:id="@+id/templateContainer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:background="@android:color/transparent"
/>
</ScrollView>
<LinearLayout
android:id="@+id/footer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="vertical"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="2dp"
android:text="@string/style"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1"
android:padding="2dp"
android:text="@string/adview_type"
android:gravity="center_horizontal"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Spinner
android:id="@+id/backgroundColorSpinner"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
<SeekBar
android:id="@+id/seekBar"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="8dp">
<Button
android:id="@+id/reloadAdButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/refresh_now"
android:padding="8dp"
/>
<Button
android:id="@+id/showCodeButton"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/show_code"
android:padding="8dp"
/>
</LinearLayout>
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp"
android:textAlignment="center"
android:gravity="start"
/>
</LinearLayout>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_native_banner_ad.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<com.facebook.ads.NativeAdLayout
android:id="@+id/native_banner_ad_container"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
/>
<Button
android:id="@+id/refresh_native_banner_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:layout_above="@id/native_banner_ad_container"
android:layout_centerHorizontal="true"
android:text="@string/refresh_now"
android:textSize="15sp"
/>
<TextView
android:id="@+id/native_banner_status_label"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_above="@id/refresh_native_banner_button"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_native_banner_ad_template.xml
================================================
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/nativeAdTemplateContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:ignore="MergeRootFrame"
android:clickable="true"
android:gravity="end"
>
<ScrollView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_above="@+id/bottomBarDes"
android:background="@android:color/transparent"
android:padding="8dp"
>
<LinearLayout
android:id="@+id/templateContainer"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="top"
android:orientation="vertical"
android:background="@android:color/transparent"
/>
</ScrollView>
<LinearLayout
android:id="@+id/bottomBarDes"
android:layout_width="match_parent"
android:layout_height="25dp"
android:layout_above="@+id/bottomBar"
android:orientation="horizontal"
>
<TextView
android:layout_width="120dp"
android:layout_height="match_parent"
android:padding="2dp"
android:text="@string/style"
android:gravity="center_horizontal"
/>
<TextView
android:layout_width="120dp"
android:layout_height="match_parent"
android:padding="2dp"
android:text="@string/adview_type"
android:textAlignment="center"
android:gravity="center_horizontal"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/bottomBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/statusBar"
android:orientation="horizontal"
android:paddingBottom="0dp"
android:paddingTop="0dp"
android:minHeight="30dp"
android:gravity="center_vertical"
>
<Spinner
android:id="@+id/backgroundColorSpinner"
android:layout_width="120dp"
android:layout_height="wrap_content"
/>
<Spinner
android:id="@+id/adViewTypeSpinner"
android:layout_width="120dp"
android:layout_height="wrap_content"
/>
<Button
android:id="@+id/showCodeButton"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_gravity="end"
android:layout_marginLeft="10dp"
android:layout_marginStart="10dp"
android:text="@string/show_code"
android:padding="8dp"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/statusBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal"
>
<TextView
android:id="@+id/status"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:padding="2dp"
android:textAlignment="center"
android:gravity="start"
/>
</LinearLayout>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_rectangle.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="1500dp"
android:orientation="vertical"
android:paddingTop="16dp"
>
<RelativeLayout
android:id="@+id/rectangleAdContainer"
android:layout_width="300dp"
android:layout_height="250dp"
android:layout_gravity="center_horizontal"
android:background="#000000"
/>
<Button
android:id="@+id/refreshRectangleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:text="@string/refresh_now"
android:textSize="15sp"
/>
<TextView
android:id="@+id/rectangleStatusLabel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="16dp"
android:layout_marginBottom="1500dp"
android:textSize="15sp"
tools:text="@string/loading_status"
/>
</LinearLayout>
</ScrollView>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_rewarded_interstitial.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical"
>
<TextView
android:id="@+id/rewardedInterstitialAdStatusLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
<LinearLayout
android:id="@+id/rewardedInterstitialAdControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="50dp"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:gravity="center"
>
<Button
android:id="@+id/loadRewardedInterstitialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_rewarded_interstitial"
android:textSize="15sp"
/>
<Button
android:id="@+id/showRewardedInterstitialButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_ad"
android:textSize="15sp"
/>
</LinearLayout>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/fragment_rewarded_video.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_vertical">
<TextView
android:id="@+id/rewardedVideoAdStatusLabel"
android:gravity="center"
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
/>
<LinearLayout
android:id="@+id/rewardedVideoAdControls"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:orientation="horizontal"
android:gravity="center"
android:layout_marginTop="50dp">
<Button
android:id="@+id/loadRewardedVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/load_rewarded_video"
android:textSize="15sp"
/>
<Button
android:id="@+id/showRewardedVideoButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="@string/show_ad"
android:textSize="15sp"
/>
</LinearLayout>
</RelativeLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/list_item_section.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include
android:id="@+id/list_item_section_text"
layout="@android:layout/preference_category"
/>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/native_ad_unit.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<com.facebook.ads.NativeAdLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingTop="10dp"
android:paddingBottom="10dp"
android:orientation="horizontal"
android:weightSum="1"
>
<com.facebook.ads.MediaView
android:id="@+id/native_ad_icon"
android:layout_width="35dp"
android:layout_height="35dp"
android:contentDescription="@string/icon_desc"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:orientation="vertical"
android:layout_weight="0.7"
>
<TextView
android:id="@+id/native_ad_title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/black"
android:textSize="15sp"
/>
<TextView
android:id="@+id/native_ad_sponsored_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/darker_gray"
android:textSize="12sp"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/ad_choices_container"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:gravity="end"
android:orientation="horizontal"
android:layout_weight="0.3"
/>
</LinearLayout>
<com.facebook.ads.MediaView
android:id="@+id/native_ad_media"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/image_desc"
android:gravity="center"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="5dp"
>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="3"
android:orientation="vertical"
>
<TextView
android:id="@+id/native_ad_social_context"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/darker_gray"
android:textSize="12sp"
/>
<TextView
android:id="@+id/native_ad_body"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="end"
android:gravity="center_vertical"
android:lines="2"
android:textColor="@android:color/black"
android:textSize="12sp"
/>
</LinearLayout>
<Button
android:id="@+id/native_ad_call_to_action"
android:layout_width="100dp"
android:layout_height="30dp"
android:layout_weight="1"
android:layout_gravity="center_vertical"
android:background="#4286F4"
android:textSize="12sp"
android:textColor="@android:color/white"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout>
</com.facebook.ads.NativeAdLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/native_banner_ad_unit.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright 2004-present Facebook. All Rights Reserved. -->
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
>
<TextView
android:id="@+id/native_ad_sponsored_label"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:padding="2dp"
android:ellipsize="end"
android:lines="1"
android:textColor="@android:color/darker_gray"
android:textSize="12sp"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="50dp"
android:background="@android:color/white"
android:orientation="horizontal"
>
<com.facebook.ads.MediaView
android:id="@+id/native_icon_view"
android:layout_width="50dp"
android:layout_height="50dp"
/>
<ImageView
android:id="@+id/image_view_icon_view"
android:layout_width="50dp"
android:layout_height="50dp"
android:visibility="gone"
/>
<LinearLayout
android:layout_width="0dp"
android:layout_height="50dp"
android:layout_weight="1"
android:orientation="vertical"
android:gravity="center_vertical"
android:padding="4dp"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:gravity="center_vertical"
>
<TextView
android:id="@+id/native_ad_title"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:textColor="@android:color/black"
android:textSize="15sp"
android:textStyle="bold"
android:ellipsize="end"
android:lines="1"
/>
<FrameLayout
android:id="@+id/ad_choices_container"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="2dp"
/>
</LinearLayout>
<TextView
android:id="@+id/native_ad_social_context"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textSize="12sp"
android:ellipsize="end"
android:lines="1"
/>
</LinearLayout>
<Button
android:id="@+id/native_ad_call_to_action"
android:layout_width="80dp"
android:layout_height="50dp"
android:gravity="center"
android:background="#4286F4"
android:textSize="12sp"
android:textColor="@android:color/white"
android:paddingLeft="3dp"
android:paddingRight="3dp"
android:visibility="gone"
/>
</LinearLayout>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout/recycler_post_item.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/white"
android:orientation="vertical"
>
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/tvPostContent"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="@android:color/white"
android:gravity="start|center"
android:padding="10dp"
android:textColor="@android:color/black"
android:textSize="18sp"
/>
</LinearLayout>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/layout-land/fragment_rectangle.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fillViewport="true"
>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:orientation="vertical"
>
<TextView
android:id="@+id/rectangleStatusLabel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:gravity="center"
android:textColor="@android:color/darker_gray"
android:textSize="15sp"
tools:text="@string/loading_status"
/>
<Button
android:id="@+id/refreshRectangleButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="16dp"
android:text="@string/refresh_now"
android:textSize="15sp"
/>
<RelativeLayout
android:id="@+id/rectangleAdContainer"
android:layout_width="300dp"
android:layout_height="wrap_content"
/>
</LinearLayout>
</ScrollView>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/menu/ad_units_sample_menu.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:id="@+id/debug_settings"
android:title="@string/debug_settings"
/>
</menu>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/values/layouts.xml
================================================
<resources>
<item name="main" type="layout">@layout/activity_ad_sample</item>
<bool name="is_tablet">false</bool>
</resources>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/values/strings.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2010-present Facebook.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<resources>
<string name="copy_right">Copyright © Meta Platforms, Inc. and affiliates. All rights reserved.</string>
<string name="app_name">Ad Units Sample</string>
<string name="select_sample">Select an option</string>
<string name="debug_settings">Debug Settings</string>
<string name="loading_status">Requesting an ad…</string>
<string name="load_interstitial">Load Interstitial</string>
<string name="refresh_now">Refresh Now</string>
<string name="show_ad">Show!</string>
<string name="destroy_ad">Destroy Ad</string>
<string name="load_rewarded_video">Load Rewarded Video</string>
<string name="load_rewarded_interstitial">Load Rewarded Interstitial</string>
<string name="enable_rewarded_interstitial">Enable Rewarded Interstitial</string>
<!-- Native samples -->
<string name="load_native_ad">Load Native Ad</string>
<string name="load_other_native_ads">Check out more Native Ads examples in </string>
<string name="load_native_ads_hscroll">hScroll</string>
<string name="load_native_ads_template">Template</string>
<string name="load_native_ads_recycler">RecyclerView</string>
<string name="icon_desc">Ad icon</string>
<string name="image_desc">Ad image</string>
<string name="sponsored">Sponsored</string>
<string name="reload_native_ads_hscroll">Reload ads</string>
<string name="ad_loading">Loading an ad…</string>
<string name="ad_loaded">Ad loaded</string>
<string name="ad_load_failed">Ad failed to load: %s</string>
<string name="ad_clicked">Ad clicked</string>
<string name="style">Style</string>
<string name="adview_type">Height</string>
<string name="show_code">Show Code</string>
<string-array name="code_snippet_mediumrect_template">
<item>protected void onCreate(Bundle savedInstanceState) {</item>
<item>\t…</item>
<item>\tnativeAdContainer = (LinearLayout) findViewById(R.id.nativeAdContainer);</item>
<item>\tnativeAd = new NativeAd(NativeTemplateActivity.this, "YOUR_PLACEMENT_ID");</item>
<item>\tnativeAd.setAdListener(NativeTemplateActivity.this);</item>
<item>\tnativeAd.loadAd();</item>
<item>\t…</item>
<item>}</item>
<item> </item>
<item>public void onAdLoaded(Ad ad) {</item>
<item>\t…</item>
<item>\tNativeAdViewAttributes adViewAttributes = new NativeAdViewAttributes();</item>
<item>\tadViewAttributes.setBackgroundColor(adBackgroundColor);</item>
<item>\tadViewAttributes.setTitleTextColor(adTitleColor);</item>
<item>\t…</item>
<item>\tView adView = NativeAdView.render(this, nativeAd, adViewAttributes);</item>
<item>\tnativeAdContainer.addView(adView, 0);</item>
<item>\t…</item>
<item>}</item>
</string-array>
<string-array name="code_snippet_banner_template">
<item>protected void onCreate(Bundle savedInstanceState) {</item>
<item>\t…</item>
<item>\tnativeAdContainer = (LinearLayout) findViewById(R.id.nativeAdContainer);</item>
<item>\tnativeBannerAd = new NativeBannerAd(getContext(), "YOUR_PLACEMENT_ID");</item>
<item>\tnativeBannerAd.setAdListener(this);</item>
<item>\tnativeBannerAd.loadAd();</item>
<item>\t…</item>
<item>}</item>
<item> </item>
<item>public void onAdLoaded(Ad ad) {</item>
<item>\t…</item>
<item>\tNativeAdViewAttributes adViewAttributes = new NativeAdViewAttributes();</item>
<item>\tadViewAttributes.setBackgroundColor(adBackgroundColor);</item>
<item>\tadViewAttributes.setTitleTextColor(adTitleColor);</item>
<item>\t…</item>
<item>\tNativeBannerAdView.Type viewType = NativeBannerAdView.Type.HEIGHT_100;</item>
<item>\tView adView = NativeBannerAdView.render(this, nativeBannerAd, viewType, adViewAttributes);</item>
<item>\tnativeAdContainer.addView(adView, 0);</item>
<item>\t…</item>
<item>}</item>
</string-array>
<string-array name="background_color_array">
<item>White</item>
<item>Black</item>
</string-array>
<string-array name="ad_bannerview_type_array">
<item>50 DP</item>
<item>100 DP</item>
<item>120 DP</item>
</string-array>
</resources>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/values-large/layout.xml
================================================
<resources>
<item name="main" type="layout">@layout/activity_ad_sample</item>
<bool name="is_tablet">true</bool>
</resources>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/values-sw600dp/layout.xml
================================================
<resources>
<item name="main" type="layout">@layout/activity_ad_sample</item>
<bool name="is_tablet">true</bool>
</resources>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/xml/locales_config.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<locale-config xmlns:android="http://schemas.android.com/apk/res/android">
<locale android:name="af"/> <!-- Afrikaans -->
<locale android:name="am"/> <!-- Amharic -->
<locale android:name="ar"/> <!-- Arabic -->
<locale android:name="as"/> <!-- Assamese -->
<locale android:name="az"/> <!-- Azerbaijani -->
<locale android:name="be"/> <!-- Belarusian -->
<locale android:name="bg"/> <!-- Bulgarian -->
<locale android:name="bn"/> <!-- Bengali -->
<locale android:name="bs"/> <!-- Bosnian -->
<locale android:name="ca"/> <!-- Catalan -->
<locale android:name="cs"/> <!-- Czech -->
<locale android:name="da"/> <!-- Danish -->
<locale android:name="de"/> <!-- German -->
<locale android:name="el"/> <!-- Greek -->
<locale android:name="en-AU"/> <!-- English (Australia) -->
<locale android:name="en-CA"/> <!-- English (Canada) -->
<locale android:name="en-GB"/> <!-- English (United Kingdom) -->
<locale android:name="en-IN"/> <!-- English (India) -->
<locale android:name="en-US"/> <!-- English (United States) -->
<locale android:name="en-XA"/> <!-- English (Pseudo-Accents) -->
<locale android:name="es"/> <!-- Spanish (Spain) -->
<locale android:name="es-US"/> <!-- Spanish (United States) -->
<locale android:name="et"/> <!-- Estonian -->
<locale android:name="eu"/> <!-- Basque -->
<locale android:name="fa"/> <!-- Farsi -->
<locale android:name="fi"/> <!-- Finnish -->
<locale android:name="fr"/> <!-- French (France) -->
<locale android:name="fr-CA"/> <!-- French (Canada) -->
<locale android:name="gl"/> <!-- Galician -->
<locale android:name="gu"/> <!-- Gujarati -->
<locale android:name="hi"/> <!-- Hindi -->
<locale android:name="hr"/> <!-- Croatian -->
<locale android:name="hu"/> <!-- Hungarian -->
<locale android:name="hy"/> <!-- Armenian -->
<locale android:name="in"/> <!-- Indonesian -->
<locale android:name="is"/> <!-- Icelandic -->
<locale android:name="it"/> <!-- Italian -->
<locale android:name="iw"/> <!-- Hebrew -->
<locale android:name="ja"/> <!-- Japanese -->
<locale android:name="ka"/> <!-- Georgian -->
<locale android:name="kk"/> <!-- Kazakh -->
<locale android:name="km"/> <!-- Khmer -->
<locale android:name="kn"/> <!-- Kannada -->
<locale android:name="ko"/> <!-- Korean -->
<locale android:name="ky"/> <!-- Kyrgyz -->
<locale android:name="lo"/> <!-- Lao -->
<locale android:name="lt"/> <!-- Lithuanian -->
<locale android:name="lv"/> <!-- Latvian -->
<locale android:name="mk"/> <!-- Macedonian -->
<locale android:name="ml"/> <!-- Malayalam -->
<locale android:name="mn"/> <!-- Mongolian -->
<locale android:name="mr"/> <!-- Marathi -->
<locale android:name="ms"/> <!-- Malay -->
<locale android:name="my"/> <!-- Burmese -->
<locale android:name="my-MM"/> <!-- Burmese (Myanmar) -->
<locale android:name="nb"/> <!-- Norwegian -->
<locale android:name="ne"/> <!-- Nepali -->
<locale android:name="nl"/> <!-- Dutch -->
<locale android:name="or"/> <!-- Odia -->
<locale android:name="pa"/> <!-- Punjabi -->
<locale android:name="pl"/> <!-- Polish -->
<locale android:name="pt-BR"/> <!-- Portuguese (Brazil) -->
<locale android:name="pt-PT"/> <!-- Portuguese (Portugal) -->
<locale android:name="ro"/> <!-- Romanian -->
<locale android:name="ru"/> <!-- Russian -->
<locale android:name="si"/> <!-- Sinhala -->
<locale android:name="sk"/> <!-- Slovak -->
<locale android:name="sl"/> <!-- Slovenian -->
<locale android:name="sq"/> <!-- Albanian -->
<locale android:name="sr"/> <!-- Serbian (Cyrillic) -->
<locale android:name="sr-Latn"/> <!-- Serbian (Latin) -->
<locale android:name="sv"/> <!-- Swedish -->
<locale android:name="sw"/> <!-- Swahili -->
<locale android:name="ta"/> <!-- Tamil -->
<locale android:name="te"/> <!-- Telugu -->
<locale android:name="th"/> <!-- Thai -->
<locale android:name="tl"/> <!-- Filipino -->
<locale android:name="tr"/> <!-- Turkish -->
<locale android:name="uk"/> <!-- Ukrainian -->
<locale android:name="ur"/> <!-- Urdu -->
<locale android:name="uz"/> <!-- Uzbek -->
<locale android:name="vi"/> <!-- Vietnamese -->
<locale android:name="zh-CN"/> <!-- Chinese (Simplified) -->
<locale android:name="zh-HK"/> <!-- Chinese (Hong Kong) -->
<locale android:name="zh-TW"/> <!-- Chinese (Traditional) -->
<locale android:name="zu"/> <!-- Zulu -->
</locale-config>
================================================
FILE: samples/android/AdUnitsSample/src/main/res/xml/network_security_config.xml
================================================
<?xml version="1.0" encoding="utf-8"?>
<network-security-config>
<!-- Must be included for proper work of the cache. -->
<domain-config cleartextTrafficPermitted="true">
<domain includeSubdomains="true">127.0.0.1</domain>
</domain-config>
<!-- For internal use only. -->
<domain-config>
<domain includeSubdomains="true">facebook.com</domain>
<trust-anchors>
<certificates src="system"/>
<certificates src="user"/>
</trust-anchors>
</domain-config>
</network-security-config>
================================================
FILE: samples/android/KotlinAdUnitsSample/.gitignore
================================================
/build
================================================
FILE: samples/android/KotlinAdUnitsSample/KotlinAdUnitsSample/.gitignore
================================================
/build
================================================
FILE: samples/android/KotlinAdUnitsSample/LICENSE
================================================
Copyright (c) Meta Platforms, Inc. and affiliates.
All rights reserved.
You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
copy, modify, and distribute this software in source code or binary form for use
in connection with the web services and APIs provided by Facebook.
As with any software that integrates with the Facebook platform, your use of
this software is subject to the Facebook Platform Policy
[http://developers.facebook.com/policy/]. This copyright notice shall be
included in all copies or substantial portions of the software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
================================================
FILE: samples/android/KotlinAdUnitsSample/build.gradle
================================================
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
repositories {
flatDir {
dirs 'libs'
}
}
dependencies {
implementation(name: 'AudienceNetwork', ext: 'aar')
implementation(name: 'DebugSettings', ext: 'aar')
implementation "androidx.legacy:legacy-support-v4:$project.ANDROIDX_VERSION"
implementation "androidx.recyclerview:recyclerview:$project.ANDROIDX_VERSION"
implementation "androidx.appcompat:appcompat:$project.ANDROIDX_VERSION"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.google.android.gms:play-services-basement:$project.ANDROID_GOOGLE_PLAY_SERVICES_VERSION"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$project.KOTLIN_VERSION"
}
android {
compileSdkVersion Integer.parseInt(project.ANDROID_BUILD_SDK_VERSION)
buildToolsVersion project.ANDROID_BUILD_TOOLS_VERSION
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId 'com.facebook.samples.AdUnitsSample'
minSdkVersion Integer.parseInt(project.ANDROID_BUILD_MIN_SDK_VERSION)
targetSdkVersion Integer.parseInt(project.ANDROID_BUILD_TARGET_SDK_VERSION)
versionCode 1
versionName '1.0'
rootProject.ext.variantRelease = false
}
lintOptions {
abortOnError false
}
buildFeatures {
viewBinding true
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/proguard-rules.pro
================================================
# Add project specific ProGuard rules here.
# You can control the set of applied configuration files using the
# proguardFiles setting in build.gradle.
#
# For more details, see
# http://developer.android.com/guide/developing/tools/proguard.html
# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
# public *;
#}
# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable
# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/AndroidManifest.xml
================================================
<manifest package="com.facebook.samples.adunitssamplekotlin"
xmlns:android="http://schemas.android.com/apk/res/android">
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme"
android:name="com.facebook.samples.adunitssamplekotlin.AdUnitsSampleApplication"
>
<activity android:name="com.facebook.samples.adunitssamplekotlin.SplashActivity"
android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.facebook.samples.adunitssamplekotlin.SampleListActivity" />
<activity android:name="com.facebook.samples.adunitssamplekotlin.AdUnitsSampleActivity" />
</application>
</manifest>
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AdUnitsSampleActivity.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.Fragment
import com.facebook.samples.ads.debugsettings.DebugSettingsActivity
import com.facebook.samples.adunitssamplekotlin.fragments.*
class AdUnitsSampleActivity : AppCompatActivity() {
companion object {
val TAG: String = AdUnitsSampleActivity::class.java.simpleName
const val SAMPLE_TYPE: String = "SAMPLE_TYPE"
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_ad_sample)
if (savedInstanceState != null) {
return
}
val sampleType = intent.getStringExtra(SAMPLE_TYPE)
if (sampleType != null) {
val type: AdUnitsSampleType? = AdUnitsSampleType.getSampleTypeFromName(sampleType)
if (type != null) {
val fragment: Fragment? =
when (type) {
AdUnitsSampleType.BANNER -> BannerFragment()
AdUnitsSampleType.INTERSTITIAL -> InterstitialFragment()
AdUnitsSampleType.RECTANGLE -> RectangleFragment()
AdUnitsSampleType.REWARDED_VIDEO -> RewardedVideoFragment()
AdUnitsSampleType.REWARDED_INTERSTITIAL -> RewardedInterstitialFragment()
AdUnitsSampleType.NATIVE -> NativeAdSampleFragment()
AdUnitsSampleType.NATIVE_BANNER -> NativeBannerAdFragment()
AdUnitsSampleType.RECYCLERVIEW -> NativeAdRecyclerFragment()
AdUnitsSampleType.HSCROLL -> NativeAdHScrollFragment()
AdUnitsSampleType.TEMPLATE -> NativeAdTemplateFragment()
AdUnitsSampleType.BANNER_TEMPLATE -> NativeBannerAdTemplateFragment()
}
if (fragment != null) {
fragment.setRetainInstance(true)
title = type.sampleType
supportFragmentManager.beginTransaction().add(R.id.fragment_container, fragment).commit()
}
}
}
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
val inflater = menuInflater
inflater.inflate(R.menu.ad_units_sample_menu, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
val i = item.itemId
if (i == R.id.debug_settings) {
startActivity(Intent(applicationContext, DebugSettingsActivity::class.java))
return true
}
return super.onOptionsItemSelected(item)
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AdUnitsSampleApplication.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin
import android.app.Application
import android.os.StrictMode
import com.facebook.samples.ads.debugsettings.DebugSettings
import com.facebook.samples.adunitssamplekotlin.BuildConfig.DEBUG
class AdUnitsSampleApplication : Application() {
override fun onCreate() {
super.onCreate()
DebugSettings.initialize(this)
AudienceNetworkInitializeHelper.initialize(this)
if (DEBUG) {
StrictMode.setThreadPolicy(StrictMode.ThreadPolicy.Builder().detectAll().penaltyLog().build())
StrictMode.setVmPolicy(StrictMode.VmPolicy.Builder().detectAll().penaltyLog().build())
}
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AdUnitsSampleType.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin
enum class AdUnitsSampleType(val sampleType: String) {
BANNER("Banner"),
RECTANGLE("Rectangle"),
INTERSTITIAL("Interstitial"),
REWARDED_VIDEO("Rewarded Video"),
REWARDED_INTERSTITIAL("Rewarded Interstitial"),
NATIVE("Native Ad"),
NATIVE_BANNER("Native Banner Ad"),
RECYCLERVIEW("Native Ad in RecyclerView"),
HSCROLL("Native Ad in H-Scroll"),
TEMPLATE("Native Ad Template"),
BANNER_TEMPLATE("Native Banner Ad Template");
companion object {
fun getSampleTypeFromName(name: String): AdUnitsSampleType? {
for (type in values()) {
if (type.sampleType.contentEquals(name)) {
return type
}
}
return null
}
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AudienceNetworkInitializeHelper.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin
import android.content.Context
import android.util.Log
import com.facebook.ads.AdSettings
import com.facebook.ads.AudienceNetworkAds
import com.facebook.samples.adunitssamplekotlin.BuildConfig.DEBUG
/** Sample class that shows how to call initialize() method of Audience Network SDK. */
class AudienceNetworkInitializeHelper : AudienceNetworkAds.InitListener {
override fun onInitialized(result: AudienceNetworkAds.InitResult) {
Log.d(AudienceNetworkAds.TAG, result.message)
}
companion object {
/**
* It's recommended to call this method from Application.onCreate(). Otherwise you can call it
* from all Activity.onCreate() methods for Activities that contain ads.
*
* @param context Application or Activity.
*/
internal fun initialize(context: Context) {
if (!AudienceNetworkAds.isInitialized(context)) {
if (DEBUG) {
AdSettings.turnOnSDKDebugger(context)
}
AudienceNetworkAds.buildInitSettings(context)
.withInitListener(AudienceNetworkInitializeHelper())
.initialize()
}
}
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/SampleListActivity.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin
import android.content.Intent
import android.os.Bundle
import android.view.Menu
import android.view.MenuItem
import androidx.appcompat.app.AppCompatActivity
import com.facebook.samples.ads.debugsettings.DebugSettingsActivity
import com.facebook.samples.adunitssamplekotlin.fragments.SampleListFragment
class SampleListActivity : AppCompatActivity() {
companion object {
val TAG = SampleListActivity::class.java.simpleName
}
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_sample_list)
supportFragmentManager
.beginTransaction()
.add(R.id.list_fragment_container, SampleListFragment())
.commit()
}
override fun onCreateOptionsMenu(menu: Menu): Boolean {
menuInflater.inflate(R.menu.ad_units_sample_menu, menu)
return true
}
override fun onOptionsItemSelected(item: MenuItem): Boolean {
if (item.itemId == R.id.debug_settings) {
// Start debug settings
startActivity(Intent(this, DebugSettingsActivity::class.java))
return true
}
return super.onOptionsItemSelected(item)
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/SplashActivity.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin
import android.app.Activity
import android.content.Intent
import android.os.Bundle
import android.os.Handler
import android.os.Looper
import android.view.Window
import android.view.WindowManager
class SplashActivity : Activity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
// If you call AudienceNetworkAds.buildInitSettings(Context).initialize()
// in Application.onCreate() this call is not really necessary.
// Otherwise call initialize() onCreate() of all Activities that contain ads or
// from onCreate() of your Splash Activity.
AudienceNetworkInitializeHelper.initialize(this)
// Hide title and nav bar, must be done before setContentView.
requestWindowFeature(Window.FEATURE_NO_TITLE)
window.setFlags(
WindowManager.LayoutParams.FLAG_FULLSCREEN,
WindowManager.LayoutParams.FLAG_FULLSCREEN,
)
setContentView(R.layout.activity_splash)
val handler = Handler(Looper.getMainLooper())
handler.postDelayed(
{
val intent = Intent(this@SplashActivity, SampleListActivity::class.java)
startActivity(intent)
},
SPLASH_TIME.toLong(),
)
}
companion object {
private const val SPLASH_TIME = 2000
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/adapters/NativeAdRecyclerAdapter.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin.adapters
import android.app.Activity
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.Button
import android.widget.LinearLayout
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.facebook.ads.*
import com.facebook.samples.adunitssamplekotlin.R
import com.facebook.samples.adunitssamplekotlin.models.RecyclerPostItem
import java.util.ArrayList
class NativeAdRecyclerAdapter(
private val activity: Activity,
private val postItems: List<RecyclerPostItem>,
private val nativeAdsManager: NativeAdsManager,
) : RecyclerView.Adapter<RecyclerView.ViewHolder>() {
private val adItems: MutableList<NativeAd>
init {
adItems = ArrayList()
}
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return if (viewType == AD_TYPE) {
val inflatedView =
LayoutInflater.from(parent.context).inflate(R.layout.native_ad_unit, parent, false)
as NativeAdLayout
AdHolder(inflatedView)
} else {
val inflatedView =
LayoutInflater.from(parent.context).inflate(R.layout.recycler_post_item, parent, false)
PostHolder(inflatedView)
}
}
override fun getItemViewType(position: Int): Int {
return if (position % AD_DISPLAY_FREQUENCY == 0) AD_TYPE else POST_TYPE
}
override fun onBindViewHolder(holder: RecyclerView.ViewHolder, position: Int) {
if (holder.itemViewType == AD_TYPE) {
val ad: NativeAd?
if (adItems.size > position / AD_DISPLAY_FREQUENCY) {
ad = adItems[position / AD_DISPLAY_FREQUENCY]
} else {
ad = nativeAdsManager.nextNativeAd()
if (ad != null && !ad.isAdInvalidated) {
adItems.add(ad)
} else {
Log.w(NativeAdRecyclerAdapter::class.java.simpleName, "Ad is invalidated!")
}
}
val adHolder = holder as AdHolder
adHolder.adChoicesContainer.removeAllViews()
ad?.let { nonNullAd ->
adHolder.tvAdTitle.text = nonNullAd.advertiserName
adHolder.tvAdBody.text = nonNullAd.adBodyText
adHolder.tvAdSocialContext.text = nonNullAd.adSocialContext
adHolder.tvAdSponsoredLabel.setText(R.string.sponsored)
adHolder.btnAdCallToAction.text = nonNullAd.adCallToAction
adHolder.btnAdCallToAction.visibility =
if (nonNullAd.hasCallToAction()) View.VISIBLE else View.INVISIBLE
val adOptionsView = AdOptionsView(activity, nonNullAd, adHolder.nativeAdLayout)
adHolder.adChoicesContainer.addView(adOptionsView, 0)
val clickableViews = ArrayList<View>()
clickableViews.add(adHolder.ivAdIcon)
clickableViews.add(adHolder.mvAdMedia)
clickableViews.add(adHolder.btnAdCallToAction)
nonNullAd.registerViewForInteraction(
adHolder.nativeAdLayout,
adHolder.mvAdMedia,
adHolder.ivAdIcon,
clickableViews,
)
}
} else {
val postHolder = holder as PostHolder
// Calculate where the next postItem index is by subtracting ads we've shown.
val index = position - position / AD_DISPLAY_FREQUENCY - 1
val postItem = postItems[index]
postHolder.tvPostContent.text = postItem.postContent
}
}
override fun getItemCount(): Int {
return postItems.size + adItems.size
}
private class PostHolder internal constructor(view: View) : RecyclerView.ViewHolder(view) {
internal var tvPostContent: TextView = view.findViewById(R.id.tvPostContent)
}
private class AdHolder internal constructor(internal var nativeAdLayout: NativeAdLayout) :
RecyclerView.ViewHolder(nativeAdLayout) {
internal var mvAdMedia: MediaView = nativeAdLayout.findViewById(R.id.native_ad_media)
internal var ivAdIcon: MediaView = nativeAdLayout.findViewById(R.id.native_ad_icon)
internal var tvAdTitle: TextView = nativeAdLayout.findViewById(R.id.native_ad_title)
internal var tvAdBody: TextView = nativeAdLayout.findViewById(R.id.native_ad_body)
internal var tvAdSocialContext: TextView =
nativeAdLayout.findViewById(R.id.native_ad_social_context)
internal var tvAdSponsoredLabel: TextView =
nativeAdLayout.findViewById(R.id.native_ad_sponsored_label)
internal var btnAdCallToAction: Button =
nativeAdLayout.findViewById(R.id.native_ad_call_to_action)
internal var adChoicesContainer: LinearLayout =
nativeAdLayout.findViewById(R.id.ad_choices_container)
}
companion object {
private const val AD_DISPLAY_FREQUENCY = 5
private const val POST_TYPE = 0
private const val AD_TYPE = 1
}
}
================================================
FILE: samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/adapters/SampleAdapter.kt
================================================
/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
* All rights reserved.
*
* This source code is licensed under the license found in the
* LICENSE file in the root directory of this source tree.
*/
package com.facebook.samples.adunitssamplekotlin.adapters
import android.content.Context
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.ArrayAdapter
import android.widget.TextView
import com.facebook.samples.adunitssamplekotlin.AdUnitsSampleType
import com.facebook.samples.adunitssamplekotlin.R
class SampleAdapter(context: Context, resource: Int) :
ArrayAdapter<SampleAdapter.Item>(context, resource) {
class Item(val title: String
gitextract_zu2obygx/
├── .github/
│ └── workflows/
│ └── main.yml
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE
├── README.md
└── samples/
├── android/
│ ├── .gitignore
│ ├── AdUnitsSample/
│ │ ├── .gitignore
│ │ ├── LICENSE
│ │ ├── build.gradle
│ │ ├── libs/
│ │ │ ├── AudienceNetwork.aar
│ │ │ └── DebugSettings.aar
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── AndroidManifestVariables.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── facebook/
│ │ │ └── samples/
│ │ │ └── AdUnitsSample/
│ │ │ ├── AdUnitsSampleActivity.java
│ │ │ ├── AdUnitsSampleApplication.java
│ │ │ ├── AdUnitsSampleType.java
│ │ │ ├── AudienceNetworkInitializeHelper.java
│ │ │ ├── SampleListActivity.java
│ │ │ ├── SplashActivity.java
│ │ │ ├── adapters/
│ │ │ │ ├── NativeAdRecyclerAdapter.java
│ │ │ │ └── SampleAdapter.java
│ │ │ ├── fragments/
│ │ │ │ ├── BannerFragment.java
│ │ │ │ ├── InterstitialFragment.java
│ │ │ │ ├── MultiLoadInterstitialFragment.java
│ │ │ │ ├── NativeAdHScrollFragment.java
│ │ │ │ ├── NativeAdRecyclerFragment.java
│ │ │ │ ├── NativeAdSampleFragment.java
│ │ │ │ ├── NativeAdTemplateFragment.java
│ │ │ │ ├── NativeBannerAdFragment.java
│ │ │ │ ├── NativeBannerAdTemplateFragment.java
│ │ │ │ ├── RectangleFragment.java
│ │ │ │ ├── RewardedInterstitialFragment.java
│ │ │ │ └── RewardedVideoFragment.java
│ │ │ ├── models/
│ │ │ │ └── RecyclerPostItem.java
│ │ │ └── thirdparty/
│ │ │ └── DividerItemDecoration/
│ │ │ └── DividerItemDecoration.java
│ │ └── res/
│ │ ├── layout/
│ │ │ ├── activity_ad_sample.xml
│ │ │ ├── activity_sample_list.xml
│ │ │ ├── activity_splash.xml
│ │ │ ├── fragment_banner.xml
│ │ │ ├── fragment_interstitial.xml
│ │ │ ├── fragment_multi_load_interstitial.xml
│ │ │ ├── fragment_native_ad_hscroll.xml
│ │ │ ├── fragment_native_ad_recycler.xml
│ │ │ ├── fragment_native_ad_sample.xml
│ │ │ ├── fragment_native_ad_template.xml
│ │ │ ├── fragment_native_banner_ad.xml
│ │ │ ├── fragment_native_banner_ad_template.xml
│ │ │ ├── fragment_rectangle.xml
│ │ │ ├── fragment_rewarded_interstitial.xml
│ │ │ ├── fragment_rewarded_video.xml
│ │ │ ├── list_item_section.xml
│ │ │ ├── native_ad_unit.xml
│ │ │ ├── native_banner_ad_unit.xml
│ │ │ └── recycler_post_item.xml
│ │ ├── layout-land/
│ │ │ └── fragment_rectangle.xml
│ │ ├── menu/
│ │ │ └── ad_units_sample_menu.xml
│ │ ├── values/
│ │ │ ├── layouts.xml
│ │ │ └── strings.xml
│ │ ├── values-large/
│ │ │ └── layout.xml
│ │ ├── values-sw600dp/
│ │ │ └── layout.xml
│ │ └── xml/
│ │ ├── locales_config.xml
│ │ └── network_security_config.xml
│ ├── KotlinAdUnitsSample/
│ │ ├── .gitignore
│ │ ├── KotlinAdUnitsSample/
│ │ │ └── .gitignore
│ │ ├── LICENSE
│ │ ├── build.gradle
│ │ ├── libs/
│ │ │ ├── AudienceNetwork.aar
│ │ │ └── DebugSettings.aar
│ │ ├── proguard-rules.pro
│ │ └── src/
│ │ └── main/
│ │ ├── AndroidManifest.xml
│ │ ├── java/
│ │ │ └── com/
│ │ │ └── facebook/
│ │ │ └── samples/
│ │ │ └── adunitssamplekotlin/
│ │ │ ├── AdUnitsSampleActivity.kt
│ │ │ ├── AdUnitsSampleApplication.kt
│ │ │ ├── AdUnitsSampleType.kt
│ │ │ ├── AudienceNetworkInitializeHelper.kt
│ │ │ ├── SampleListActivity.kt
│ │ │ ├── SplashActivity.kt
│ │ │ ├── adapters/
│ │ │ │ ├── NativeAdRecyclerAdapter.kt
│ │ │ │ └── SampleAdapter.kt
│ │ │ ├── fragments/
│ │ │ │ ├── BannerFragment.kt
│ │ │ │ ├── InterstitialFragment.kt
│ │ │ │ ├── NativeAdHScrollFragment.kt
│ │ │ │ ├── NativeAdRecyclerFragment.kt
│ │ │ │ ├── NativeAdSampleFragment.kt
│ │ │ │ ├── NativeAdTemplateFragment.kt
│ │ │ │ ├── NativeBannerAdFragment.kt
│ │ │ │ ├── NativeBannerAdTemplateFragment.kt
│ │ │ │ ├── RectangleFragment.kt
│ │ │ │ ├── RewardedInterstitialFragment.kt
│ │ │ │ ├── RewardedVideoFragment.kt
│ │ │ │ └── SampleListFragment.kt
│ │ │ └── models/
│ │ │ └── RecyclerPostItem.kt
│ │ └── res/
│ │ ├── layout/
│ │ │ ├── activity_ad_sample.xml
│ │ │ ├── activity_sample_list.xml
│ │ │ ├── activity_splash.xml
│ │ │ ├── fragment_banner.xml
│ │ │ ├── fragment_interstitial.xml
│ │ │ ├── fragment_native_ad_hscroll.xml
│ │ │ ├── fragment_native_ad_recycler.xml
│ │ │ ├── fragment_native_ad_sample.xml
│ │ │ ├── fragment_native_ad_template.xml
│ │ │ ├── fragment_native_banner_ad.xml
│ │ │ ├── fragment_native_banner_ad_template.xml
│ │ │ ├── fragment_rectangle.xml
│ │ │ ├── fragment_rewarded_interstitial.xml
│ │ │ ├── fragment_rewarded_video.xml
│ │ │ ├── list_item_section.xml
│ │ │ ├── native_ad_unit.xml
│ │ │ ├── native_banner_ad_unit.xml
│ │ │ └── recycler_post_item.xml
│ │ ├── menu/
│ │ │ └── ad_units_sample_menu.xml
│ │ └── values/
│ │ ├── colors.xml
│ │ ├── strings.xml
│ │ └── styles.xml
│ ├── README.md
│ ├── build.gradle
│ ├── gradle.properties
│ ├── gradlew
│ ├── gradlew.bat
│ └── settings.gradle
├── ios/
│ ├── AdUnitsSample/
│ │ ├── .gitignore
│ │ ├── AdUnitsSample/
│ │ │ ├── AdUnitsSample-Prefix.pch
│ │ │ ├── AdUnitsSample.entitlements
│ │ │ ├── AdUnitsSampleStoryboard.storyboard
│ │ │ ├── AppDelegate.h
│ │ │ ├── AppDelegate.m
│ │ │ ├── BannerViewController.h
│ │ │ ├── BannerViewController.m
│ │ │ ├── CollectionViewController.h
│ │ │ ├── CollectionViewController.m
│ │ │ ├── DebugLogsViewController.h
│ │ │ ├── DebugLogsViewController.m
│ │ │ ├── Images.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ └── Contents.json
│ │ │ ├── Info.plist
│ │ │ ├── InfoPlist.strings
│ │ │ ├── InstreamViewController.h
│ │ │ ├── InstreamViewController.m
│ │ │ ├── InterstitialViewController.h
│ │ │ ├── InterstitialViewController.m
│ │ │ ├── LaunchScreen.storyboard
│ │ │ ├── MediumRectViewController.h
│ │ │ ├── MediumRectViewController.m
│ │ │ ├── MenuTableViewController.h
│ │ │ ├── MenuTableViewController.m
│ │ │ ├── NativeAdTemplateViewController.h
│ │ │ ├── NativeAdTemplateViewController.m
│ │ │ ├── NativeBannerAdTemplateViewController.h
│ │ │ ├── NativeBannerAdTemplateViewController.m
│ │ │ ├── NativeBannerViewController.h
│ │ │ ├── NativeBannerViewController.m
│ │ │ ├── NativeViewController.h
│ │ │ ├── NativeViewController.m
│ │ │ ├── NavigationController.h
│ │ │ ├── NavigationController.m
│ │ │ ├── RewardedVideoViewController.h
│ │ │ ├── RewardedVideoViewController.m
│ │ │ ├── ScrollViewController.h
│ │ │ ├── ScrollViewController.m
│ │ │ ├── SettingsLogLevelCell.h
│ │ │ ├── SettingsLogLevelCell.m
│ │ │ ├── SettingsSandboxCell.h
│ │ │ ├── SettingsSandboxCell.m
│ │ │ ├── SettingsTableViewController.h
│ │ │ ├── SettingsTableViewController.m
│ │ │ ├── SettingsTestAdCell.h
│ │ │ ├── SettingsTestAdCell.m
│ │ │ ├── SettingsTestModeCell.h
│ │ │ ├── SettingsTestModeCell.m
│ │ │ ├── TableViewController.h
│ │ │ ├── TableViewController.m
│ │ │ └── main.m
│ │ ├── AdUnitsSample.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcshareddata/
│ │ │ └── xcschemes/
│ │ │ └── AdUnitsSample.xcscheme
│ │ ├── AdUnitsSample.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ ├── Podfile
│ │ ├── ReadMe.txt
│ │ └── VERSION.bzl
│ ├── FANSample/
│ │ ├── .gitignore
│ │ ├── FANSample/
│ │ │ ├── AppDelegate.swift
│ │ │ ├── Assets.xcassets/
│ │ │ │ ├── AppIcon.appiconset/
│ │ │ │ │ └── Contents.json
│ │ │ │ ├── Contents.json
│ │ │ │ └── fan.imageset/
│ │ │ │ └── Contents.json
│ │ │ ├── Base.lproj/
│ │ │ │ ├── LaunchScreen.storyboard
│ │ │ │ └── Main.storyboard
│ │ │ ├── Extensions/
│ │ │ │ ├── NSObject+ClassName.swift
│ │ │ │ ├── UIView+NibContent.swift
│ │ │ │ └── UIViewController+Storyboard.swift
│ │ │ ├── Info.plist
│ │ │ ├── Samples/
│ │ │ │ ├── BannerSampleViewController.swift
│ │ │ │ ├── FullscreenAdSampleViewController.swift
│ │ │ │ ├── Native/
│ │ │ │ │ ├── NativeAdScreenViewController.swift
│ │ │ │ │ ├── NativeAdView.swift
│ │ │ │ │ └── NativeAdView.xib
│ │ │ │ ├── NativeBanner/
│ │ │ │ │ ├── NativeBannerAdScreenViewController.swift
│ │ │ │ │ ├── NativeBannerAdView.swift
│ │ │ │ │ └── NativeBannerAdView.xib
│ │ │ │ ├── NativeBannerTemplate/
│ │ │ │ │ ├── NativeBannerTemplateAdScreenViewController.swift
│ │ │ │ │ └── NativeBannerTemplateAdView.swift
│ │ │ │ └── NativeTemplate/
│ │ │ │ ├── NativeTemplateAdView.swift
│ │ │ │ └── NativeTemplateScreenViewController.swift
│ │ │ ├── SamplesViewController.swift
│ │ │ ├── SceneDelegate.swift
│ │ │ ├── Settings/
│ │ │ │ ├── Picker/
│ │ │ │ │ ├── PickerTableViewCell.swift
│ │ │ │ │ ├── PickerTableViewCell.xib
│ │ │ │ │ └── ViewModels.swift
│ │ │ │ ├── SettingScreenViewController.swift
│ │ │ │ └── TestMode/
│ │ │ │ ├── TestModeTableViewCell.swift
│ │ │ │ └── TestModeTableViewCell.xib
│ │ │ └── Utils/
│ │ │ ├── AdUtils.swift
│ │ │ ├── BottomBarView.swift
│ │ │ ├── BottomBarView.xib
│ │ │ └── NavigationController.swift
│ │ ├── FANSample.xcodeproj/
│ │ │ ├── project.pbxproj
│ │ │ ├── project.xcworkspace/
│ │ │ │ ├── contents.xcworkspacedata
│ │ │ │ └── xcshareddata/
│ │ │ │ └── IDEWorkspaceChecks.plist
│ │ │ └── xcshareddata/
│ │ │ └── xcschemes/
│ │ │ └── FANSample.xcscheme
│ │ ├── FANSample.xcworkspace/
│ │ │ ├── contents.xcworkspacedata
│ │ │ └── xcshareddata/
│ │ │ └── IDEWorkspaceChecks.plist
│ │ ├── Podfile
│ │ └── README.md
│ └── README.md
└── python/
└── ReportingAPISamples/
├── .gitignore
├── CONTRIBUTING.md
├── LICENSE.md
├── PATENTS.md
├── README.md
├── adnw_examples.py
├── adnw_exception.py
├── adnw_params.py
├── adnw_requests.py
├── adnw_response.py
└── adnw_utils.py
SYMBOL INDEX (237 symbols across 28 files)
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleActivity.java
class AdUnitsSampleActivity (line 35) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreate (line 40) | @Override
method onCreateOptionsMenu (line 122) | @Override
method onOptionsItemSelected (line 129) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleApplication.java
class AdUnitsSampleApplication (line 15) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreate (line 18) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleType.java
type AdUnitsSampleType (line 14) | @Nullsafe(Nullsafe.Mode.LOCAL)
method AdUnitsSampleType (line 32) | AdUnitsSampleType(String mName) {
method getName (line 36) | public String getName() {
method getSampleTypeFromName (line 40) | public static @Nullable AdUnitsSampleType getSampleTypeFromName(String...
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AudienceNetworkInitializeHelper.java
class AudienceNetworkInitializeHelper (line 21) | @Nullsafe(Nullsafe.Mode.LOCAL)
method AudienceNetworkInitializeHelper (line 26) | private AudienceNetworkInitializeHelper(Context context) {
method initialize (line 36) | static void initialize(Context context) {
method onInitialized (line 48) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/SampleListActivity.java
class SampleListActivity (line 26) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreate (line 31) | @Override
method onCreateOptionsMenu (line 69) | @Override
method onOptionsItemSelected (line 76) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/SplashActivity.java
class SplashActivity (line 20) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreate (line 25) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/adapters/NativeAdRecyclerAdapter.java
class NativeAdRecyclerAdapter (line 35) | @Nullsafe(Nullsafe.Mode.LOCAL)
method NativeAdRecyclerAdapter (line 48) | public NativeAdRecyclerAdapter(
method onCreateViewHolder (line 56) | @Override
method getItemViewType (line 72) | @Override
method onBindViewHolder (line 77) | @Override
method getItemCount (line 153) | @Override
class PostHolder (line 158) | private static class PostHolder extends RecyclerView.ViewHolder {
method PostHolder (line 162) | PostHolder(View view) {
class AdHolder (line 169) | private static class AdHolder extends RecyclerView.ViewHolder {
method AdHolder (line 181) | AdHolder(NativeAdLayout adLayout) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/adapters/SampleAdapter.java
class SampleAdapter (line 22) | @Nullsafe(Nullsafe.Mode.LOCAL)
class Item (line 25) | public static class Item {
method Item (line 29) | public Item(String title, boolean isSection) {
method Item (line 34) | public Item(String title) {
method getTitle (line 38) | public String getTitle() {
method SampleAdapter (line 46) | public SampleAdapter(Context context) {
method getView (line 74) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/BannerFragment.java
class BannerFragment (line 30) | public class BannerFragment extends Fragment implements AdListener {
method onCreateView (line 39) | @Override
method onDestroyView (line 58) | @Override
method onDestroy (line 64) | @Override
method loadAdView (line 73) | private void loadAdView() {
method onError (line 98) | @Override
method onAdLoaded (line 105) | @Override
method onAdClicked (line 112) | @Override
method onLoggingImpression (line 117) | @Override
method setLabel (line 122) | private void setLabel(String status) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/InterstitialFragment.java
class InterstitialFragment (line 33) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 45) | @Override
method onDestroy (line 107) | @Override
method onError (line 116) | @Override
method onAdLoaded (line 123) | @Override
method onInterstitialDisplayed (line 130) | @Override
method onInterstitialDismissed (line 135) | @Override
method onAdClicked (line 144) | @Override
method onLoggingImpression (line 149) | @Override
method setLabel (line 155) | private void setLabel(String label) {
method onRewardedAdCompleted (line 162) | @Override
method onRewardedAdServerSucceeded (line 167) | @Override
method onRewardedAdServerFailed (line 172) | @Override
method onInterstitialActivityDestroyed (line 177) | @Override
method showToast (line 182) | private void showToast(String message) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/MultiLoadInterstitialFragment.java
class MultiLoadInterstitialFragment (line 31) | public class MultiLoadInterstitialFragment extends Fragment
method onCreateView (line 51) | @Override
method destroy (line 230) | private void destroy(@Nullable InterstitialAd interstitialAd) {
method onDestroy (line 237) | @Override
method onDestroyView (line 242) | @Override
method onError (line 260) | @Override
method onAdLoaded (line 278) | @Override
method onInterstitialDisplayed (line 291) | @Override
method onInterstitialDismissed (line 296) | @Override
method onAdClicked (line 312) | @Override
method onLoggingImpression (line 318) | @Override
method setLabel (line 324) | private void setLabel(@Nullable TextView interstitialAdStatusLabel, St...
method onRewardedAdCompleted (line 330) | @Override
method onRewardedAdServerSucceeded (line 333) | @Override
method onRewardedAdServerFailed (line 336) | @Override
method onInterstitialActivityDestroyed (line 339) | @Override
method showToast (line 344) | private void showToast(String message) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdHScrollFragment.java
class NativeAdHScrollFragment (line 29) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 38) | @Override
method onAdsLoaded (line 71) | @Override
method onAdError (line 88) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdRecyclerFragment.java
class NativeAdRecyclerFragment (line 29) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 36) | @Override
method onAdsLoaded (line 64) | @Override
method onAdError (line 79) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdSampleFragment.java
class NativeAdSampleFragment (line 41) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 56) | @Override
method onDestroyView (line 124) | @Override
method onError (line 133) | @Override
method onAdClicked (line 140) | @Override
method onLoggingImpression (line 145) | @Override
method onMediaDownloaded (line 150) | @Override
method onAdLoaded (line 157) | @Override
method inflateAd (line 222) | private void inflateAd(NativeAd nativeAd, View adView) {
method onDestroy (line 276) | @Override
method getMediaViewListener (line 290) | private static MediaViewListener getMediaViewListener() {
method showToast (line 334) | private void showToast(String message) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdTemplateFragment.java
class NativeAdTemplateFragment (line 38) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 64) | @Override
method onAdLoaded (line 91) | @Override
method onError (line 102) | @Override
method onAdClicked (line 108) | @Override
method onLoggingImpression (line 113) | @Override
method onMediaDownloaded (line 118) | @Override
method onDestroy (line 123) | @Override
method createAndLoadNativeAd (line 129) | private void createAndLoadNativeAd() {
method reloadAdContainer (line 142) | private void reloadAdContainer() {
method setUpLayoutBuilders (line 170) | private void setUpLayoutBuilders() {
method updateAdViewParams (line 224) | private void updateAdViewParams() {
method setUpButtons (line 234) | private void setUpButtons() {
method showCodeInAdContainer (line 256) | private void showCodeInAdContainer() {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeBannerAdFragment.java
class NativeBannerAdFragment (line 38) | public class NativeBannerAdFragment extends Fragment implements NativeAd...
method newInstance (line 54) | public static NativeBannerAdFragment newInstance(boolean useImageView) {
method onCreate (line 64) | @Override
method onCreateView (line 74) | @Nullable
method onError (line 120) | @Override
method onAdLoaded (line 125) | @Override
method onAdClicked (line 184) | @Override
method onLoggingImpression (line 189) | @Override
method onMediaDownloaded (line 194) | @Override
method inflateAd (line 199) | private void inflateAd(NativeBannerAd nativeBannerAd, View adView) {
method onDestroy (line 234) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeBannerAdTemplateFragment.java
class NativeBannerAdTemplateFragment (line 34) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 54) | @Override
method createAndLoadNativeAd (line 94) | protected void createAndLoadNativeAd() {
method reloadAdContainer (line 107) | private void reloadAdContainer() {
method setSpinnerListeners (line 136) | private void setSpinnerListeners() {
method setButtonListeners (line 184) | private void setButtonListeners() {
method showCodeInAdContainer (line 198) | private void showCodeInAdContainer() {
method onAdLoaded (line 215) | @Override
method onError (line 226) | @Override
method onAdClicked (line 232) | @Override
method onLoggingImpression (line 237) | @Override
method onMediaDownloaded (line 242) | @Override
method onDestroy (line 247) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RectangleFragment.java
class RectangleFragment (line 31) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 41) | @Override
method onDestroyView (line 63) | @Override
method onDestroy (line 69) | @Override
method loadAdView (line 78) | private void loadAdView() {
method onError (line 99) | @Override
method onAdLoaded (line 106) | @Override
method onAdClicked (line 113) | @Override
method onLoggingImpression (line 118) | @Override
method setLabel (line 123) | private void setLabel(String status) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RewardedInterstitialFragment.java
class RewardedInterstitialFragment (line 29) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 39) | @Override
method onError (line 97) | @Override
method onAdLoaded (line 104) | @Override
method onAdClicked (line 111) | @Override
method setStatusLabelText (line 116) | private void setStatusLabelText(String label) {
method showToast (line 122) | private void showToast(String message) {
method onRewardedInterstitialCompleted (line 128) | @Override
method onLoggingImpression (line 133) | @Override
method onRewardedInterstitialClosed (line 138) | @Override
method onRewardServerFailed (line 143) | @Override
method onRewardServerSuccess (line 148) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RewardedVideoFragment.java
class RewardedVideoFragment (line 30) | @Nullsafe(Nullsafe.Mode.LOCAL)
method onCreateView (line 40) | @Override
method onError (line 94) | @Override
method onAdLoaded (line 101) | @Override
method onAdClicked (line 108) | @Override
method setStatusLabelText (line 113) | private void setStatusLabelText(String label) {
method showToast (line 119) | private void showToast(String message) {
method onRewardedVideoCompleted (line 126) | @Override
method onLoggingImpression (line 131) | @Override
method onRewardedVideoClosed (line 136) | @Override
method onRewardServerFailed (line 141) | @Override
method onRewardServerSuccess (line 146) | @Override
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/models/RecyclerPostItem.java
class RecyclerPostItem (line 13) | @Nullsafe(Nullsafe.Mode.LOCAL)
method RecyclerPostItem (line 19) | public RecyclerPostItem(String postContent) {
method getPostContent (line 23) | public String getPostContent() {
method setPostContent (line 27) | public void setPostContent(String postContent) {
FILE: samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/thirdparty/DividerItemDecoration/DividerItemDecoration.java
class DividerItemDecoration (line 29) | @Nullsafe(Nullsafe.Mode.LOCAL)
method DividerItemDecoration (line 42) | public DividerItemDecoration(Context context, int orientation) {
method setOrientation (line 50) | public void setOrientation(int orientation) {
method onDraw (line 57) | @Override
method drawVertical (line 66) | public void drawVertical(Canvas c, RecyclerView parent) {
method drawHorizontal (line 81) | public void drawHorizontal(Canvas c, RecyclerView parent) {
method getItemOffsets (line 96) | @Override
FILE: samples/python/ReportingAPISamples/adnw_examples.py
function run_sync_request (line 11) | def run_sync_request(app_id, access_token):
function run_async_request_1 (line 29) | def run_async_request_1(app_id, access_token):
function run_async_request_2 (line 51) | def run_async_request_2(app_id, access_token):
function run_async_request_for_result_1 (line 68) | def run_async_request_for_result_1(app_id, access_token):
function run_async_request_for_result_2 (line 75) | def run_async_request_for_result_2(app_id, access_token):
function try_run_async_request_with_query_ids (line 83) | def try_run_async_request_with_query_ids(app_id, access_token, query_ids...
function run_async_request_with_query_ids (line 96) | def run_async_request_with_query_ids(app_id, access_token, query_ids: [s...
FILE: samples/python/ReportingAPISamples/adnw_exception.py
class ValidationError (line 1) | class ValidationError(Exception):
method __init__ (line 2) | def __init__(self, message, errors=None):
class HttpResponseError (line 8) | class HttpResponseError(Exception):
method __init__ (line 9) | def __init__(self, message, errors=None):
class InvalidQueryIdError (line 15) | class InvalidQueryIdError(Exception):
method __init__ (line 16) | def __init__(self, message, errors=None):
FILE: samples/python/ReportingAPISamples/adnw_params.py
class Metric (line 18) | class Metric(enum.Enum):
class Breakdown (line 38) | class Breakdown(enum.Enum):
class FilterOperator (line 48) | class FilterOperator(enum.Enum):
class Filter (line 52) | class Filter:
method __init__ (line 53) | def __init__(self, condition: Breakdown, operator: FilterOperator, fil...
method raw_value (line 58) | def raw_value(self):
method __hash__ (line 63) | def __hash__(self):
method __eq__ (line 66) | def __eq__(self, other):
class OrderingColumn (line 70) | class OrderingColumn(enum.Enum):
class OrderingType (line 75) | class OrderingType(enum.Enum):
class AggregationPeriod (line 80) | class AggregationPeriod(enum.Enum):
FILE: samples/python/ReportingAPISamples/adnw_requests.py
class ADNWRequestBuilder (line 20) | class ADNWRequestBuilder(object):
method __init__ (line 22) | def __init__(self, app_id: string, access_token: string):
method add_metrics (line 36) | def add_metrics(self, metrics: [Metric]):
method add_metric (line 39) | def add_metric(self, metric: Metric):
method add_breakdowns (line 42) | def add_breakdowns(self, breakdowns: [Breakdown]):
method add_breakdown (line 45) | def add_breakdown(self, breakdown: Breakdown):
method set_date_range (line 48) | def set_date_range(self, date_since: datetime.date, date_until: dateti...
method add_filters (line 52) | def add_filters(self, filters: [Filter]):
method add_filter (line 55) | def add_filter(self, _filter: Filter):
method set_ordering_type (line 58) | def set_ordering_type(self, ordering_type: OrderingType):
method set_ordering_column (line 61) | def set_ordering_column(self, ordering_column: OrderingColumn):
method set_aggregation_period (line 64) | def set_aggregation_period(self, aggregation_period: AggregationPeriod):
method set_limit (line 67) | def set_limit(self, limit: int):
method set_query_ids (line 70) | def set_query_ids(self, query_ids: [string]):
method build_sync_request (line 74) | def build_sync_request(self):
method build_sync_request_with_query_ids (line 82) | def build_sync_request_with_query_ids(self):
method build_async_request (line 94) | def build_async_request(self):
method get_params (line 99) | def get_params(self):
method validate_params (line 116) | def validate_params(self, is_sync_request: bool = True, is_using_query...
FILE: samples/python/ReportingAPISamples/adnw_response.py
class ADNWResponse (line 7) | class ADNWResponse(object):
method get_instance (line 11) | def get_instance():
method __init__ (line 16) | def __init__(self):
method validate_response (line 26) | def validate_response(self, _request: requests.request):
method get_query_id (line 44) | def get_query_id(self, _json: json):
FILE: samples/python/ReportingAPISamples/adnw_utils.py
function raw_value (line 13) | def raw_value(enum_val: enum.Enum):
function raw_statement (line 17) | def raw_statement(_filter: Filter):
function validate (line 21) | def validate(date_text: string):
function flatten_item (line 29) | def flatten_item(value, key=None):
function write_to_csv (line 48) | def write_to_csv(_json: json):
function add_separated_key_value_if_needed (line 88) | def add_separated_key_value_if_needed(node: dict):
function is_list_empty (line 101) | def is_list_empty(_list: list):
Condensed preview — 236 files, each showing path, character count, and a content snippet. Download the .json file or copy for the full structured content (873K chars).
[
{
"path": ".github/workflows/main.yml",
"chars": 1582,
"preview": "name: Close new issues with template\n\non:\n issues:\n types: [opened]\n\njobs:\n close-new-issues:\n runs-on: ub"
},
{
"path": ".gitignore",
"chars": 108,
"preview": ".DS_Store\nxcuserdata/\n*.xcuserdatad\n*.xcuserstate\n*.hmap\n*.ipa\n*.dSYM.zip\n*.dSYM\n\nPods/\nbuild/\nDerivedData/\n"
},
{
"path": "CONTRIBUTING.md",
"chars": 1097,
"preview": "<H1>Contributing to audience-network-support</H1>\nWe want to make contributing to this project as easy and transparent a"
},
{
"path": "LICENSE",
"chars": 1045,
"preview": "Copyright (c) 2016-present, Facebook, Inc. All rights reserved.\n\nYou are hereby granted a non-exclusive, worldwide, roya"
},
{
"path": "README.md",
"chars": 951,
"preview": "# Audience Network Samples\n\nIn this repository there are sample code that demonstrates how to use Facebook [Audience Net"
},
{
"path": "samples/android/.gitignore",
"chars": 587,
"preview": "admob.xml\n\n# Built application files\n*.apk\n*.ap_\n\n# Files for the ART/Dalvik VM\n*.dex\n\n# Java class files\n*.class\n\n# Gen"
},
{
"path": "samples/android/AdUnitsSample/.gitignore",
"chars": 208,
"preview": "BUCK\n*.iml\n.gradle\n/local.properties\n/.idea/caches\n/.idea/libraries\n/.idea/modules.xml\n/.idea/workspace.xml\n/.idea/navEd"
},
{
"path": "samples/android/AdUnitsSample/LICENSE",
"chars": 1035,
"preview": "Copyright (c) Meta Platforms, Inc. and affiliates.\nAll rights reserved.\n\nYou are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/android/AdUnitsSample/build.gradle",
"chars": 1219,
"preview": "apply plugin: 'com.android.application'\n\nrepositories {\n flatDir {\n dirs 'libs'\n }\n}\n\ndependencies {\n implementa"
},
{
"path": "samples/android/AdUnitsSample/proguard-rules.pro",
"chars": 665,
"preview": "# Add project specific ProGuard rules here.\n# By default, the flags in this file are appended to flags specified\n# in /U"
},
{
"path": "samples/android/AdUnitsSample/src/main/AndroidManifest.xml",
"chars": 1560,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest package=\"com.facebook.samples.AdUnitsSample\"\n xmlns:android=\"h"
},
{
"path": "samples/android/AdUnitsSample/src/main/AndroidManifestVariables.xml",
"chars": 331,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<manifest\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n pack"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleActivity.java",
"chars": 5029,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleApplication.java",
"chars": 648,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AdUnitsSampleType.java",
"chars": 1316,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/AudienceNetworkInitializeHelper.java",
"chars": 1645,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/SampleListActivity.java",
"chars": 2883,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/SplashActivity.java",
"chars": 1762,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/adapters/NativeAdRecyclerAdapter.java",
"chars": 7107,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/adapters/SampleAdapter.java",
"chars": 3192,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/BannerFragment.java",
"chars": 3593,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/InterstitialFragment.java",
"chars": 5750,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/MultiLoadInterstitialFragment.java",
"chars": 12419,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdHScrollFragment.java",
"chars": 2995,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdRecyclerFragment.java",
"chars": 2993,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdSampleFragment.java",
"chars": 11752,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeAdTemplateFragment.java",
"chars": 9083,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeBannerAdFragment.java",
"chars": 8795,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/NativeBannerAdTemplateFragment.java",
"chars": 8895,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RectangleFragment.java",
"chars": 3782,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RewardedInterstitialFragment.java",
"chars": 4948,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/fragments/RewardedVideoFragment.java",
"chars": 4691,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/models/RecyclerPostItem.java",
"chars": 692,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/AdUnitsSample/src/main/java/com/facebook/samples/AdUnitsSample/thirdparty/DividerItemDecoration/DividerItemDecoration.java",
"chars": 3671,
"preview": "/*\n * Copyright (C) 2014 The Android Open Source Project\n *\n * Licensed under the Apache License, Version 2.0 (the \"Lice"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/activity_ad_sample.xml",
"chars": 1075,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\nCopyright 2010-present Facebook.\n\nLicensed under the Apache License, Version"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/activity_sample_list.xml",
"chars": 735,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/activity_splash.xml",
"chars": 1190,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_banner.xml",
"chars": 1275,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n x"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_interstitial.xml",
"chars": 1552,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_multi_load_interstitial.xml",
"chars": 3789,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_hscroll.xml",
"chars": 1066,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_recycler.xml",
"chars": 613,
"preview": "<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.com"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_sample.xml",
"chars": 3097,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_native_ad_template.xml",
"chars": 3694,
"preview": "<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.c"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_native_banner_ad.xml",
"chars": 1247,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n a"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_native_banner_ad_template.xml",
"chars": 3480,
"preview": "<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.c"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_rectangle.xml",
"chars": 1402,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<ScrollView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n x"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_rewarded_interstitial.xml",
"chars": 1623,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/fragment_rewarded_video.xml",
"chars": 1558,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/list_item_section.xml",
"chars": 382,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/native_ad_unit.xml",
"chars": 5057,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.facebook.ads.NativeAdLayout\n xmlns:android=\"http://schemas.android.com/ap"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/native_banner_ad_unit.xml",
"chars": 3416,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright 2004-present Facebook. All Rights Reserved. -->\n\n<LinearLayout xml"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout/recycler_post_item.xml",
"chars": 710,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/layout-land/fragment_rectangle.xml",
"chars": 1420,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<ScrollView\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n x"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/menu/ad_units_sample_menu.xml",
"chars": 234,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item\n "
},
{
"path": "samples/android/AdUnitsSample/src/main/res/values/layouts.xml",
"chars": 135,
"preview": "<resources>\n <item name=\"main\" type=\"layout\">@layout/activity_ad_sample</item>\n <bool name=\"is_tablet\">false</bool"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/values/strings.xml",
"chars": 4940,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\nCopyright 2010-present Facebook.\n\nLicensed under the Apache License, Version"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/values-large/layout.xml",
"chars": 134,
"preview": "<resources>\n <item name=\"main\" type=\"layout\">@layout/activity_ad_sample</item>\n <bool name=\"is_tablet\">true</bool>"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/values-sw600dp/layout.xml",
"chars": 134,
"preview": "<resources>\n <item name=\"main\" type=\"layout\">@layout/activity_ad_sample</item>\n <bool name=\"is_tablet\">true</bool>"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/xml/locales_config.xml",
"chars": 4607,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<locale-config xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <l"
},
{
"path": "samples/android/AdUnitsSample/src/main/res/xml/network_security_config.xml",
"chars": 556,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<network-security-config>\n <!-- Must be included for proper work of the cache."
},
{
"path": "samples/android/KotlinAdUnitsSample/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "samples/android/KotlinAdUnitsSample/KotlinAdUnitsSample/.gitignore",
"chars": 7,
"preview": "/build\n"
},
{
"path": "samples/android/KotlinAdUnitsSample/LICENSE",
"chars": 1035,
"preview": "Copyright (c) Meta Platforms, Inc. and affiliates.\nAll rights reserved.\n\nYou are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/android/KotlinAdUnitsSample/build.gradle",
"chars": 1386,
"preview": "apply plugin: 'com.android.application'\napply plugin: 'kotlin-android'\n\nrepositories {\n flatDir {\n dirs 'libs'\n }\n}"
},
{
"path": "samples/android/KotlinAdUnitsSample/proguard-rules.pro",
"chars": 751,
"preview": "# Add project specific ProGuard rules here.\n# You can control the set of applied configuration files using the\n# proguar"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/AndroidManifest.xml",
"chars": 970,
"preview": "<manifest package=\"com.facebook.samples.adunitssamplekotlin\"\n xmlns:android=\"http://schemas.android.com/apk/res"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AdUnitsSampleActivity.kt",
"chars": 2742,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AdUnitsSampleApplication.kt",
"chars": 861,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AdUnitsSampleType.kt",
"chars": 944,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/AudienceNetworkInitializeHelper.kt",
"chars": 1366,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/SampleListActivity.kt",
"chars": 1409,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/SplashActivity.kt",
"chars": 1536,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/adapters/NativeAdRecyclerAdapter.kt",
"chars": 4965,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/adapters/SampleAdapter.kt",
"chars": 2246,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/BannerFragment.kt",
"chars": 2491,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/InterstitialFragment.kt",
"chars": 3381,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/NativeAdHScrollFragment.kt",
"chars": 2222,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/NativeAdRecyclerFragment.kt",
"chars": 2301,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/NativeAdSampleFragment.kt",
"chars": 7934,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/NativeAdTemplateFragment.kt",
"chars": 7724,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/NativeBannerAdFragment.kt",
"chars": 6422,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/NativeBannerAdTemplateFragment.kt",
"chars": 7600,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/RectangleFragment.kt",
"chars": 3130,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/RewardedInterstitialFragment.kt",
"chars": 3835,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/RewardedVideoFragment.kt",
"chars": 3318,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/fragments/SampleListFragment.kt",
"chars": 1522,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/java/com/facebook/samples/adunitssamplekotlin/models/RecyclerPostItem.kt",
"chars": 316,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/activity_ad_sample.xml",
"chars": 551,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/activity_sample_list.xml",
"chars": 558,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/activity_splash.xml",
"chars": 1190,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_banner.xml",
"chars": 1316,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_interstitial.xml",
"chars": 1459,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_native_ad_hscroll.xml",
"chars": 1064,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_native_ad_recycler.xml",
"chars": 472,
"preview": "<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n android:layout_width=\"match_parent\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_native_ad_sample.xml",
"chars": 1616,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_native_ad_template.xml",
"chars": 3732,
"preview": "<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.c"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_native_banner_ad.xml",
"chars": 1246,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n a"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_native_banner_ad_template.xml",
"chars": 3480,
"preview": "<RelativeLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n xmlns:tools=\"http://schemas.android.c"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_rectangle.xml",
"chars": 1308,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_rewarded_interstitial.xml",
"chars": 1501,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/fragment_rewarded_video.xml",
"chars": 1466,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<RelativeLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/list_item_section.xml",
"chars": 376,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout xmlns:android=\"http://schemas.android.com/apk/res/android\"\n andr"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/native_ad_unit.xml",
"chars": 4807,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<com.facebook.ads.NativeAdLayout\n xmlns:android=\"http://schemas.android.com/ap"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/native_banner_ad_unit.xml",
"chars": 3211,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!-- Copyright 2004-present Facebook. All Rights Reserved. -->\n\n<LinearLayout xml"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/layout/recycler_post_item.xml",
"chars": 643,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<LinearLayout\n xmlns:android=\"http://schemas.android.com/apk/res/android\"\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/menu/ad_units_sample_menu.xml",
"chars": 222,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<menu xmlns:android=\"http://schemas.android.com/apk/res/android\">\n <item\n "
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/values/colors.xml",
"chars": 208,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<resources>\n <color name=\"colorPrimary\">#008577</color>\n <color name=\"color"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/values/strings.xml",
"chars": 4861,
"preview": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<!--\nCopyright 2010-present Facebook.\n\nLicensed under the Apache License, Version"
},
{
"path": "samples/android/KotlinAdUnitsSample/src/main/res/values/styles.xml",
"chars": 383,
"preview": "<resources>\n\n <!-- Base application theme. -->\n <style name=\"AppTheme\" parent=\"Theme.AppCompat.Light.DarkActionBar"
},
{
"path": "samples/android/README.md",
"chars": 1676,
"preview": "Samples for Android Platform\n============================\n\nFacebook Audience Network allows you to monetize your Android"
},
{
"path": "samples/android/build.gradle",
"chars": 699,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/android/gradle.properties",
"chars": 418,
"preview": "# Ensure you update the following if making changes here:\n# - samples/common/build.gradle.template\n\nGRADLE_VERSION=7.0"
},
{
"path": "samples/android/gradlew",
"chars": 5080,
"preview": "#!/usr/bin/env bash\n\n##############################################################################\n##\n## Gradle start "
},
{
"path": "samples/android/gradlew.bat",
"chars": 2624,
"preview": "@REM Copyright (c) Meta Platforms, Inc. and affiliates.\r\n@REM All rights reserved.\r\n@REM\r\n@REM This source code is licen"
},
{
"path": "samples/android/settings.gradle",
"chars": 267,
"preview": "/*\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n * All rights reserved.\n *\n * This source code is licensed unde"
},
{
"path": "samples/ios/AdUnitsSample/.gitignore",
"chars": 274,
"preview": "# Xcode\n\n## Build generated\nbuild/\nDerivedData/\n\n## Various settings\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/AdUnitsSample-Prefix.pch",
"chars": 340,
"preview": "//\n// Prefix header\n//\n// The contents of this file are implicitly included at the beginning of every source file.\n//\n"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/AdUnitsSample.entitlements",
"chars": 326,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/AdUnitsSampleStoryboard.storyboard",
"chars": 147180,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/AppDelegate.h",
"chars": 1299,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/AppDelegate.m",
"chars": 7240,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/BannerViewController.h",
"chars": 1176,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/BannerViewController.m",
"chars": 5180,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/CollectionViewController.h",
"chars": 1180,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/CollectionViewController.m",
"chars": 8448,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/DebugLogsViewController.h",
"chars": 1184,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/DebugLogsViewController.m",
"chars": 5938,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/Images.xcassets/AppIcon.appiconset/Contents.json",
"chars": 4622,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"20x20\",\n \"scale\" : \"2x\"\n },\n {\n \"idiom\""
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/Images.xcassets/Contents.json",
"chars": 62,
"preview": "{\n \"info\" : {\n \"version\" : 1,\n \"author\" : \"xcode\"\n }\n}"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/Info.plist",
"chars": 1582,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/InfoPlist.strings",
"chars": 45,
"preview": "/* Localized versions of Info.plist keys */\n\n"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/InstreamViewController.h",
"chars": 1178,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/InstreamViewController.m",
"chars": 3360,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/InterstitialViewController.h",
"chars": 1182,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/InterstitialViewController.m",
"chars": 3507,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/LaunchScreen.storyboard",
"chars": 6344,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/MediumRectViewController.h",
"chars": 1180,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/MediumRectViewController.m",
"chars": 3869,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/MenuTableViewController.h",
"chars": 1184,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/MenuTableViewController.m",
"chars": 1513,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeAdTemplateViewController.h",
"chars": 1186,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeAdTemplateViewController.m",
"chars": 5323,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeBannerAdTemplateViewController.h",
"chars": 1192,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeBannerAdTemplateViewController.m",
"chars": 5118,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeBannerViewController.h",
"chars": 1182,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeBannerViewController.m",
"chars": 5747,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeViewController.h",
"chars": 1176,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NativeViewController.m",
"chars": 9470,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NavigationController.h",
"chars": 1182,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/NavigationController.m",
"chars": 1705,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/RewardedVideoViewController.h",
"chars": 1183,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/RewardedVideoViewController.m",
"chars": 4165,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/ScrollViewController.h",
"chars": 1176,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/ScrollViewController.m",
"chars": 4094,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsLogLevelCell.h",
"chars": 1175,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsLogLevelCell.m",
"chars": 2812,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsSandboxCell.h",
"chars": 1174,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsSandboxCell.m",
"chars": 1766,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsTableViewController.h",
"chars": 1188,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsTableViewController.m",
"chars": 3586,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsTestAdCell.h",
"chars": 1173,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsTestAdCell.m",
"chars": 4544,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsTestModeCell.h",
"chars": 1244,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/SettingsTestModeCell.m",
"chars": 1765,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/TableViewController.h",
"chars": 1175,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/TableViewController.m",
"chars": 7635,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample/main.m",
"chars": 1301,
"preview": "// Copyright (c) 2014-present, Facebook, Inc. All rights reserved.\n//\n// You are hereby granted a non-exclusive, worldwi"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample.xcodeproj/project.pbxproj",
"chars": 28896,
"preview": "// !$*UTF8*$!\n{\n\tarchiveVersion = 1;\n\tclasses = {\n\t};\n\tobjectVersion = 46;\n\tobjects = {\n\n/* Begin PBXBuildFile section *"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample.xcodeproj/project.xcworkspace/contents.xcworkspacedata",
"chars": 135,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"self:\">\n </FileRef"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
"chars": 238,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample.xcodeproj/xcshareddata/xcschemes/AdUnitsSample.xcscheme",
"chars": 3375,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Scheme\n LastUpgradeVersion = \"0820\"\n version = \"1.3\">\n <BuildAction\n "
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample.xcworkspace/contents.xcworkspacedata",
"chars": 231,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<Workspace\n version = \"1.0\">\n <FileRef\n location = \"group:AdUnitsSample."
},
{
"path": "samples/ios/AdUnitsSample/AdUnitsSample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist",
"chars": 238,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "samples/ios/AdUnitsSample/Podfile",
"chars": 289,
"preview": "# Uncomment the next line to define a global platform for your project\n# platform :ios, '9.0'\n\ntarget 'AdUnitsSample' do"
},
{
"path": "samples/ios/AdUnitsSample/ReadMe.txt",
"chars": 1019,
"preview": "AdUnitsSample\n\nIn this sample we demonstrate how to use the Native Ad API (FBNativeAd) from the Facebook Ads SDK for iOS"
},
{
"path": "samples/ios/AdUnitsSample/VERSION.bzl",
"chars": 228,
"preview": "VERSION_CONFIG = {\n # These are bumped by automation\n # See https://our.intern.facebook.com/intern/wiki/index.php/"
},
{
"path": "samples/ios/FANSample/.gitignore",
"chars": 287,
"preview": "# Xcode\n\n## Build generated\nbuild/\nDerivedData/\n\n## Various settings\n*.pbxuser\n!default.pbxuser\n*.mode1v3\n!default.mode1"
},
{
"path": "samples/ios/FANSample/FANSample/AppDelegate.swift",
"chars": 1502,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\nimport FBAudienceNetwork\n\n@UIAppli"
},
{
"path": "samples/ios/FANSample/FANSample/Assets.xcassets/AppIcon.appiconset/Contents.json",
"chars": 2260,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"iphone\",\n \"size\" : \"20x20\",\n \"scale\" : \"2x\",\n \"filename\" : \"icon_"
},
{
"path": "samples/ios/FANSample/FANSample/Assets.xcassets/Contents.json",
"chars": 62,
"preview": "{\n \"info\" : {\n \"version\" : 1,\n \"author\" : \"xcode\"\n }\n}"
},
{
"path": "samples/ios/FANSample/FANSample/Assets.xcassets/fan.imageset/Contents.json",
"chars": 300,
"preview": "{\n \"images\" : [\n {\n \"idiom\" : \"universal\",\n \"scale\" : \"1x\"\n },\n {\n \"idiom\" : \"universal\",\n "
},
{
"path": "samples/ios/FANSample/FANSample/Base.lproj/LaunchScreen.storyboard",
"chars": 3246,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "samples/ios/FANSample/FANSample/Base.lproj/Main.storyboard",
"chars": 34762,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB\" version=\"3"
},
{
"path": "samples/ios/FANSample/FANSample/Extensions/NSObject+ClassName.swift",
"chars": 284,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport Foundation\n\nextension NSObject {\n var"
},
{
"path": "samples/ios/FANSample/FANSample/Extensions/UIView+NibContent.swift",
"chars": 900,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\n\nextension UIView {\n @discardab"
},
{
"path": "samples/ios/FANSample/FANSample/Extensions/UIViewController+Storyboard.swift",
"chars": 401,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\n\nextension UIViewController {\n "
},
{
"path": "samples/ios/FANSample/FANSample/Info.plist",
"chars": 2204,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"http://www.apple.com/DTDs/P"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/BannerSampleViewController.swift",
"chars": 4192,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\nimport FBAudienceNetwork\n\nenum Ban"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/FullscreenAdSampleViewController.swift",
"chars": 7140,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport os\nimport UIKit\nimport FBAudienceNetwork"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/Native/NativeAdScreenViewController.swift",
"chars": 2268,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\n\nfinal class NativeAdScreenViewCon"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/Native/NativeAdView.swift",
"chars": 5258,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\nimport FBAudienceNetwork\n\nfinal cl"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/Native/NativeAdView.xib",
"chars": 12937,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" version=\"3.0\" toolsVe"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeBanner/NativeBannerAdScreenViewController.swift",
"chars": 1917,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\n\nfinal class NativeBannerAdScreenV"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeBanner/NativeBannerAdView.swift",
"chars": 4324,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\nimport FBAudienceNetwork\n\nfinal cl"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeBanner/NativeBannerAdView.xib",
"chars": 8603,
"preview": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<document type=\"com.apple.InterfaceBuilder3.CocoaTouch.XIB\" version=\"3.0\" toolsVe"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeBannerTemplate/NativeBannerTemplateAdScreenViewController.swift",
"chars": 2159,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\n\nfinal class NativeBannerTemplateA"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeBannerTemplate/NativeBannerTemplateAdView.swift",
"chars": 3334,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\nimport FBAudienceNetwork\n\nextensio"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeTemplate/NativeTemplateAdView.swift",
"chars": 2839,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\nimport FBAudienceNetwork\n\nfinal cl"
},
{
"path": "samples/ios/FANSample/FANSample/Samples/NativeTemplate/NativeTemplateScreenViewController.swift",
"chars": 3435,
"preview": "// (c) Facebook, Inc. and its affiliates. Confidential and proprietary.\n\nimport UIKit\n\nfinal class NativeTemplateScreenV"
}
]
// ... and 36 more files (download for full content)
About this extraction
This page contains the full source code of the fbsamples/audience-network GitHub repository, extracted and formatted as plain text for AI agents and large language models (LLMs). The extraction includes 236 files (788.9 KB), approximately 199.3k tokens, and a symbol index with 237 extracted functions, classes, methods, constants, and types. Use this with OpenClaw, Claude, ChatGPT, Cursor, Windsurf, or any other AI tool that accepts text input. You can copy the full output to your clipboard or download it as a .txt file.
Extracted by GitExtract — free GitHub repo to text converter for AI. Built by Nikandr Surkov.