
package com.uwetrottmann.shopr.loaders;

import android.content.Context;

import com.uwetrottmann.shopr.model.Item;
import com.uwetrottmann.shopr.utils.Lists;

import java.math.BigDecimal;
import java.util.List;

/**
 * Returns a list of items based on the current user model.
 */
public class ItemLoader extends GenericSimpleLoader<List<Item>> {

    public ItemLoader(Context context) {
        super(context);
    }

    @Override
    public List<Item> loadInBackground() {
        List<Item> items = Lists.newArrayList();

        for (int i = 0; i < 10; i++) {
            Item item = new Item().id(i).name("Sample Item " + i).picture("sample.jpg").shopId(42);
            double random = Math.random() * 200;
            item.price(new BigDecimal(random));
            item.label(Math.random() > 0.5 ? "Armani" : "Hugo Boss");
            items.add(item);
        }

        return items;
    }

}

@@ -68,16 +68,133 @@
 ntext;%0A%0A
+import com.uwetrottmann.shopr.algorithm.AdaptiveSelection;%0Aimport com.uwetrottmann.shopr.algorithm.model.Attributes;%0A
 import c
@@ -650,136 +650,855 @@
     
-for (int i = 0; i %3C 10; i++) %7B%0A            Item item = new Item().id(i).name(%22Sample Item %22 + i).picture(%22sample.jpg%22).shopId(42
+AdaptiveSelection manager = AdaptiveSelection.get();%0A        List%3Ccom.uwetrottmann.shopr.algorithm.model.Item%3E recommendations = manager%0A                .getRecommendations(null);%0A%0A        // Until we have real data transfer the model of item used by algorithm%0A        // to the app model%0A        int count = 0;%0A        for (com.uwetrottmann.shopr.algorithm.model.Item item : recommendations) %7B%0A            Attributes attrs = item.attributes();%0A            String label = attrs.label().currentValue().toString();%0A            String type = attrs.type().currentValue().toString();%0A%0A            Item expandedItem = new Item().id(count++);%0A            expandedItem.name(label + %22 %22 + type + %22 %22 + count);%0A            expandedItem.color(attrs.color().currentValue().toString());%0A            expandedItem.label(label);%0A            expandedItem.type(type
 );%0A 
@@ -1553,25 +1553,33 @@
             
-i
+expandedI
 tem.price(ne
@@ -1597,24 +1597,25 @@
 l(random));%0A
+%0A
             
@@ -1622,85 +1622,23 @@
 item
-.label(Math.random() %3E 0.5 ? %22Armani%22 : %22Hugo Boss%22);%0A            items.add(i
+s.add(expandedI
 tem)

Integrate recommender into item loader.