Skip to content

Curations Display

Sergio Azua edited this page Apr 25, 2016 · 9 revisions

Getting Curations Feed

  //Create list of desired groups to retrieve feed for.
  ArrayList<String> groups = new ArrayList<>();
  groups.add("__all__");

  //Builder used to construct CurationsRequest. Builder must be constructed with List of groups
  CurationsRequest request = new CurationsRequest.Builder(groups)
           //add other params. visit https://scissors.feedmagnet.com/docs/api/ for full list
           .limit(20)
           .withProductData(true)
           .build();

  //create instance of BVCurations
  BVCurations curations = new BVCurations();

  //use instance to get Curations Feed
  curations.getCurationsFeedItems(request, new CurationsCallback() {
      @Override
      public void onSuccess(List<CurationsFeedItem> feedItems) {
          //successfully completed. use feedItems to populate UI
      }

      @Override
      public void onFailure(Throwable throwable) {
          //failed to get feed. descriptive throwable can be used to debug
      }
  });

Curations UI Containers

In order to provide Bazaarvoice with feedback about user interaction that can help produce easier Return On Investment reports, you should use one of the provided views to wrap either a single CurationsFeedItem view, or a group of CurationsFeedItem views.

Wrap a single CurationsFeedItem view

Suppose you had the following layout to display a single CurationsFeedItem after fetching it as described above:

<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="90dp">
        <ImageView
            android:id="@+id/image"
            android:layout_width="90dp"
            android:layout_height="90dp"/>
        <TextView
            android:id="@+id/text"
            android:layout_width="match_parent"
            android:layout_height="90dp" />
</LinearLayout>

In order to take this and provide Bazaarvoice with feedback you should wrap the LinearLayout with the provided CurationsView:

<com.bazaarvoice.bvandroidsdk.CurationsView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/curationsView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">
    <LinearLayout
        android:orientation="horizontal"
        android:layout_width="match_parent"
        android:layout_height="90dp">
            <ImageView
                android:id="@+id/image"
                android:layout_width="90dp"
                android:layout_height="90dp"/>
            <TextView
                android:id="@+id/text"
                android:layout_width="match_parent"
                android:layout_height="90dp" />
    </LinearLayout>
</com.bazaarvoice.bvandroidsdk.CurationsView>

Finally, in the code, associate the inflated CurationsView object with the CurationsFeedItem it correlates to. An example of when you would do this is in the getView method of an Adapter

class MyAdapter extends ArrayAdapter<CurationsFeedItem> {
    private List<CurationsFeedItem> feedItems;

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ...
        CurationsFeedItem currentFeedItem = getItem(position);
        CurationsView curationsView = (curationsView) convertView.findViewById(R.id.curationsView);
        curationsView.setCurationsFeedItem(currentFeedItem);
        ...
    }
}
Wrap a group of CurationFeedItem views

Suppose you had the following layout to display a group of BVProducts after fetching them as described above,

<android.support.v7.widget.RecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/curationsRecyclerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

In order to take this and provide Bazaarvoice with feedback you should swap the RecyclerView with the provided CurationsRecyclerView,

<com.bazaarvoice.bvandroidsdk.CurationsRecyclerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/curationsRecyclerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>
Extra options to wrap a group of CurationFeedItem views

If you wanted to use other ViewGroups in place of a RecyclerView the three other options in the SDK are...

CurationsListView

<com.bazaarvoice.bvandroidsdk.CurationsListView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/curationsListView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

CurationsGridView

<com.bazaarvoice.bvandroidsdk.CurationsGridView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/curationsGridView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"/>

CurationsContainerView - If you wish to use a different ViewGroup than ListView, GridView, or RecyclerView (such as a LinearLayout) to display CurationsView objects, than you can simply wrap that with a CurationsContainerView.

<com.bazaarvoice.bvandroidsdk.CurationsContainerView
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/curationsContainerView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content">

        <com.bazaarvoice.bvandroidsdk.CurationsView
            android:id="@+id/curationsView1"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="90dp">
                    <ImageView
                        android:id="@+id/image"
                        android:layout_width="90dp"
                        android:layout_height="90dp"/>
                    <TextView
                        android:id="@+id/text"
                        android:layout_width="match_parent"
                        android:layout_height="90dp" />
            </LinearLayout>
        </com.bazaarvoice.bvandroidsdk.CurationsView>

        <com.bazaarvoice.bvandroidsdk.CurationsView
            android:id="@+id/curationsView2"
            android:layout_width="match_parent"
            android:layout_height="wrap_content">
            <LinearLayout
                android:orientation="horizontal"
                android:layout_width="match_parent"
                android:layout_height="90dp">
                    <ImageView
                        android:id="@+id/image"
                        android:layout_width="90dp"
                        android:layout_height="90dp"/>
                    <TextView
                        android:id="@+id/text"
                        android:layout_width="match_parent"
                        android:layout_height="90dp" />
            </LinearLayout>
        </com.bazaarvoice.bvandroidsdk.CurationsView>
        
    </LinearLayout>
    
</com.bazaarvoice.bvandroidsdk.CurationsContainerView>

Clone this wiki locally