
package com.uwetrottmann.shopr.loaders;

import android.content.Context;

import com.uwetrottmann.shopr.algorithm.AdaptiveSelection;
import com.uwetrottmann.shopr.algorithm.model.Attributes;
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();

        AdaptiveSelection manager = AdaptiveSelection.get();
        List<com.uwetrottmann.shopr.algorithm.model.Item> recommendations = manager
                .getRecommendations(null);

        // Until we have real data transfer the model of item used by algorithm
        // to the app model
        int count = 0;
        for (com.uwetrottmann.shopr.algorithm.model.Item item : recommendations) {
            Attributes attrs = item.attributes();
            String label = attrs.label().currentValue().toString();
            String type = attrs.type().currentValue().toString();

            Item expandedItem = new Item().id(count++);
            expandedItem.name(label + " " + type + " " + count);
            expandedItem.color(attrs.color().currentValue().toString());
            expandedItem.label(label);
            expandedItem.type(type);
            double random = Math.random() * 200;
            expandedItem.price(new BigDecimal(random));

            items.add(expandedItem);
        }

        return items;
    }

}

@@ -1312,21 +1312,20 @@
 em.name(
-label
+type
  + %22 %22 +
@@ -1325,26 +1325,21 @@
 + %22 %22 + 
-type + %22 %22
+label
  + count

Switch temporary naming scheme.