Java 类com.facebook.ads.AdSettings 实例源码

项目:pubnative-android-sdk    文件:Facebook.java   
public static void init(Context context) {

    AdSettings.setMediationService(MEDIATION_SERVICE_NAME);
    AdSettings.setIsChildDirected(PNSettings.isCoppaModeEnabled);
    if (PNSettings.isTestModeEnabled) {
        AdSettings.addTestDevice(PNCrypto.md5(PNSettings.advertisingId));
        FacebookTestModeHelper.updateHashId(context, PNCrypto.md5(PNSettings.advertisingId));
    }
}
项目:react-native-fbads    文件:AdSettingsManager.java   
@ReactMethod
public void addTestDevice(String deviceHashedId) {
    if (deviceHashedId == "current") {
        SharedPreferences sp = getReactApplicationContext()
            .getSharedPreferences("FBAdPrefs", 0);

        deviceHashedId = sp.getString("deviceIdHash", null);
    }
    AdSettings.addTestDevice(deviceHashedId);
}
项目:Sportmix    文件:TrtsporFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_aspor_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:PostItemAdapter.java   
private void inflateAd(NativeAd nativeAd, View adView) {
    // Create native UI using the ad metadata.
    ImageView nativeAdIcon = (ImageView) adView.findViewById(R.id.native_ad_icon);
    TextView nativeAdTitle = (TextView) adView.findViewById(R.id.native_ad_title);
    TextView nativeAdBody = (TextView) adView.findViewById(R.id.native_ad_body);
    MediaView nativeAdMedia = (MediaView) adView.findViewById(R.id.native_ad_media);
    nativeAdMedia.setAutoplay(AdSettings.isVideoAutoplay());
    TextView nativeAdSocialContext =
            (TextView) adView.findViewById(R.id.native_ad_social_context);
    Button nativeAdCallToAction = (Button) adView.findViewById(R.id.native_ad_call_to_action);

    // Setting the Text
    nativeAdSocialContext.setText(nativeAd.getAdSocialContext());
    nativeAdCallToAction.setText(nativeAd.getAdCallToAction());
    nativeAdCallToAction.setVisibility(View.VISIBLE);
    nativeAdTitle.setText(nativeAd.getAdTitle());
    nativeAdBody.setText(nativeAd.getAdBody());

    // Downloading and setting the ad icon.
    NativeAd.Image adIcon = nativeAd.getAdIcon();
    NativeAd.downloadAndDisplayImage(adIcon, nativeAdIcon);

    // Downloading and setting the cover image.
    NativeAd.Image adCoverImage = nativeAd.getAdCoverImage();
    int bannerWidth = adCoverImage.getWidth();
    int bannerHeight = adCoverImage.getHeight();
    DisplayMetrics metrics = myContext.getResources().getDisplayMetrics();
    int mediaWidth = adView.getWidth() > 0 ? adView.getWidth() : metrics.widthPixels;
    nativeAdMedia.setLayoutParams(new LinearLayout.LayoutParams(
            mediaWidth,
            Math.min(
                    (int) (((double) mediaWidth / (double) bannerWidth) * bannerHeight),
                    metrics.heightPixels / 7))); // eskiden 3
    nativeAdMedia.setNativeAd(nativeAd);

    // Wire up the View with the native ad, the whole nativeAdContainer will be clickable.
    nativeAd.registerViewForInteraction(adView);
}
项目:react-native-fbads    文件:AdSettingsManager.java   
@ReactMethod
public void clearTestDevices() {
    AdSettings.clearTestDevices();
}
项目:react-native-fbads    文件:AdSettingsManager.java   
@ReactMethod
public void setIsChildDirected(boolean isDirected) {
    AdSettings.setIsChildDirected(isDirected);
}
项目:react-native-fbads    文件:AdSettingsManager.java   
@ReactMethod
public void setMediationService(String mediationService) {
    AdSettings.setMediationService(mediationService);
}
项目:react-native-fbads    文件:AdSettingsManager.java   
@ReactMethod
public void setUrlPrefix(String urlPrefix) {
    AdSettings.setUrlPrefix(urlPrefix);
}
项目:googleads-mobile-android-mediation    文件:FacebookAdapter.java   
private void buildAdRequest(MediationAdRequest adRequest) {
    if (adRequest != null) {
        AdSettings.setIsChildDirected((adRequest.taggedForChildDirectedTreatment()
                == MediationAdRequest.TAG_FOR_CHILD_DIRECTED_TREATMENT_TRUE));
    }
}
项目:Sportmix    文件:FotomacFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_fotomac_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:SporxFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_sporx_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:SabahFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_sabah_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:EuroSportFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_aspor_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:LigTvFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_ligtv_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:GoalComFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_ntvspor_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}
项目:Sportmix    文件:HaberTurkFragment.java   
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    v = inflater.inflate(R.layout.layout_haberturk_fragment, container, false);

    swipeRefreshLayout = (SwipeRefreshLayout) v.findViewById(R.id.swipe_refresh_layout);
  /*  alertDialog=new SpotsDialog(getActivity(),R.style.Custom_Progress_Dialog);
    setCustomAlertDialog();*/
    // fillTheData();


    swipeRefreshLayout.setOnRefreshListener(this);

    // Configure the refreshing colors
    swipeRefreshLayout.setColorSchemeResources(android.R.color.holo_blue_bright,
            android.R.color.holo_green_light,
            android.R.color.holo_orange_light,
            android.R.color.holo_red_light);

    swipeRefreshLayout.post(new Runnable() {
                                @Override
                                public void run() {
                                    swipeRefreshLayout.setRefreshing(true);

                                    fetchAllNews();
                                    swipeRefreshLayout.setRefreshing(false);
                                }
                            }
    );

    //init native ads manager
    listNativeAdsManager = new NativeAdsManager(getActivity(),
            getString(R.string.test_facebook_unit_id),
            getResources().getInteger(R.integer.max_pull_ad_number));
    if (getString(R.string.test_ad_mode).equals("T")){
        AdSettings.addTestDevice(getString(R.string.test_device_id));
    }
    listNativeAdsManager.setListener(this);
    listNativeAdsManager.loadAds();
    return v;
}