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

项目:sekai    文件:NativeAdHscrollActivity.java   
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.hscroll);

    manager = new NativeAdsManager(this, "YOUR_PLACEMENT_ID", 5);
    manager.setListener(this);
    manager.loadAds(NativeAd.MediaCacheFlag.ALL);

    inflater = (LayoutInflater)this.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

    reloadButton = (Button)findViewById(R.id.reloadHscroll);
    reloadButton.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            manager.loadAds();
        }
    });
}
项目:react-native-fbads    文件:NativeAdManager.java   
/**
 * Initialises native ad manager for a given placement id and ads to request.
 * This method is run on the UI thread
 *
 * @param placementId
 * @param adsToRequest
 */
@ReactMethod
public void init(final String placementId, final int adsToRequest) {
    final ReactApplicationContext reactContext = this.getReactApplicationContext();

    UiThreadUtil.runOnUiThread(new Runnable() {
        @Override
        public void run() {
            final NativeAdsManager adsManager = new NativeAdsManager(reactContext, placementId, adsToRequest);

            adsManager.setListener(NativeAdManager.this);

            mAdsManagers.put(placementId, adsManager);

            adsManager.loadAds();
        }
    });
}
项目:react-native-fbads    文件:NativeAdViewManager.java   
@ReactProp(name = "adsManager")
public void setAdsManager(NativeAdView view, String adsManagerId) {
    NativeAdManager adManager = mReactContext.getNativeModule(NativeAdManager.class);
    NativeAdsManager adsManager = adManager.getFBAdsManager(adsManagerId);

    view.setNativeAd(adsManager.nextNativeAd());
}
项目:react-native-fbads    文件:NativeAdManager.java   
/**
 * Called when one of the registered ads managers loads ads. Sends state of all
 * managers back to JS
 */
@Override
public void onAdsLoaded() {
    WritableMap adsManagersState = Arguments.createMap();

    for (String key : mAdsManagers.keySet()) {
        NativeAdsManager adsManager = mAdsManagers.get(key);
        adsManagersState.putBoolean(key, adsManager.isLoaded());
    }

    sendAppEvent("CTKNativeAdsManagersChanged", adsManagersState);
}
项目: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    文件: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;
}
项目:react-native-fbads    文件:NativeAdManager.java   
/**
 * Returns FBAdsManager for a given placement id
 *
 * @param placementId
 * @return
 */
public NativeAdsManager getFBAdsManager(String placementId) {
    return mAdsManagers.get(placementId);
}