> For the complete documentation index, see [llms.txt](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://intowow.gitbook.io/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md).

# CEInFeedHelper

`CEInFeedHelper` is the class that simplifies in-feed integration of Card Ad and Native Ad.

| Public construct |
| ---------------- |

| <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md">CEInFeedHelper(Context context, String channelName, boolean isDebug)</a></p><p>Create inFeedHelper object</p> |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| Public methods |   |
| -------------- | - |

| void | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#setadsource">setAdSource(CEIFAdSource adSource)</a></p><p>set Ad source by your Ad format to CEInFeedHelper</p> |
| ---- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| void | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#onscrollstatechanged">onScrollStateChanged(int state)</a></p><p>check if the feed is idle or scrolling</p> |
| ---- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| void | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#onscroll">onScroll(int visiblePos, int visibleItems, int totalChildView)</a></p><p>check the scroll state</p> |
| ---- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| Public methods |   |
| -------------- | - |

| CEIFAdView | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#getadview">getAdView(int position)</a></p><p>request Ad view from CEInFeedHelper</p> |
| ---------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| void | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#setadeventlistener">setAdEventListener(CEIFHelperAdEventListener listener)</a></p><p>set Ad event listener to receive Ad status</p> |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

| boolean | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#isad">isAd(int position)</a></p><p>check if this position is Ad</p> |
| ------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| boolean | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#isad-1">isAd(View view)</a></p><p>check if this view is Ad</p> |
| ------- | --------------------------------------------------------------------------------------------------------------------------------------------------------- |

| synchronized void | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#reset">reset()</a></p><p>reset the Ad cache to request new Ad when you want to reload the dataset</p> |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

| void | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#setitemcount">setItemCount(int originalCount)</a></p><p>set the number of original in-feed items into CEInFeedHelper</p> |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| int | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#getadjustedcount">getAdjustedCount(int originalCount)</a></p><p>get the number of current in-feed items</p> |
| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

| int | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#getoriginalposition">getOriginalPosition(int position)</a></p><p>get the item's original position when there are Ad items in the view</p> |
| --- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |

| int | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#getadjustedposition">getAdjustedPosition(final int originalPosition)</a></p><p>get the item's adjusted position when there are no Ad items in the view</p> |
| --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| Object | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#getaddata">getAdData(int position)</a></p><p>request Ad object from CEInFeedHelper</p> |
| ------ | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

| int | <p><a href="/crystalexpress-documentation-v3-x/android-sdk/api-reference/ceinfeedhelper.md#getviewtypecount">getViewTypeCount()</a></p><p>always return 2, because there are 2 type of items, normal ones and Ads</p> |
| --- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |

## setAdSource

void setAdSource(CEIFAdSource adSource)

set Ad source by your Ad format to CEInFeedHelper

| Parameter |                                      |
| --------- | ------------------------------------ |
| adSource  | CEIFAdSource: In-feed Ad source info |

## onScrollStateChanged

void onScrollStateChanged(int state)

check if the feed is idle or scrolling

| Parameter |                               |
| --------- | ----------------------------- |
| state     | int: the current scroll state |

## onScroll

void onScroll(int visiblePos, int visibleItems, int totalChildView)

check the scroll state

| Parameter      |                                              |
| -------------- | -------------------------------------------- |
| visiblePos     | int: the index of the first visible cell     |
| visibleItems   | int: the number of visible cells             |
| totalChildView | int: the number of items in the list adapter |

## getAdView

CEIFAdView getAdView(int position)

request Ad view from CEInFeedHelper if you don't want to use CEIFAdapter/CEIFRecyclerViewAdapter

| Parameter |                                          |
| --------- | ---------------------------------------- |
| position  | int: the position of the in-feed content |

## setAdEventListener

void setAdEventListener(CEIFHelperAdEventListener listener)

set Ad event listener to receive Ad status

| Parameter |                                                               |
| --------- | ------------------------------------------------------------- |
| listener  | CEIFHelperAdEventListener: the listener for ad event callback |

```java
mInFeedHelper.setAdEventListener(new CEInFeedHelper.CEIFHelperAdEventListener() {
            @Override
            public void onAdClicked(int index, Object ad) {

            }

            @Override
            public void onAdImpression(int index, Object ad) {

            }

            @Override
            public void onAdMute(int index, Object ad) {

            }

            @Override
            public void onAdUnmute(int index, Object ad) {

            }

            @Override
            public void onAdVideoStart(int index, Object ad) {

            }

            @Override
            public void onAdVideoEnd(int index, Object ad) {

            }

            @Override
            public void onAdVideoProgress(int index, Object ad, int totalDuration, int currentPosition) {

            }
        });
```

## isAd

boolean isAd(int position)

check if this position is Ad

| Parameter |                             |
| --------- | --------------------------- |
| position  | int: the Dataset's position |

## isAd

boolean isAd(View view)

check if this view is Ad

| Parameter |      |
| --------- | ---- |
| view      | View |

## reset

synchronized void reset()

reset the Ad cache to request new Ad when you want to reload the dataset. To be more specific, you can call this API when users pull down to refresh the in-feed page.

## setItemCount

void setItemCount(int originalCount)

set the number of original in-feed items into CEInFeedHelper

| Parameter     |                                           |
| ------------- | ----------------------------------------- |
| originalCount | int: the number of original in-feed items |

## getAdjustedCount

int getAdjustedCount(int originalCount)

get the number of current in-feed items

| Parameter     |                                       |
| ------------- | ------------------------------------- |
| originalCount | int: number of original in-feed items |

## getOriginalPosition

int getOriginalPosition(int position)

get the item's original position when there are Ad items in the view

| Parameter |                                          |
| --------- | ---------------------------------------- |
| position  | int: the in-feed item's current position |

## getAdjustedPosition

int getAdjustedPosition(final int originalPosition)

| Parameter        |                                           |
| ---------------- | ----------------------------------------- |
| originalPosition | int: the in-feed's item original position |

## getAdData

Object getAdData(int position)

request Ad object from CEInFeedHelper

| Parameter |                             |
| --------- | --------------------------- |
| position  | int: the Ad item's position |

## getViewTypeCount

int getViewTypeCount()

*\*\**&#x61;lways return 2, because there are 2 type of items, normal ones and Ads
