// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/provider/ShoprContract.java
// public static class Items implements ItemsColumns, BaseColumns {
//     public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
//             .appendPath(PATH_ITEMS).build();
// 
//     /** Use if multiple items get returned */
//     public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.shopr.item";
// 
//     /** Use if a single item is returned */
//     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.shopr.item";
// 
//     public static Uri buildItemUri(int itemId) {
//         return CONTENT_URI.buildUpon().appendPath(String.valueOf(itemId))
//                 .build();
//     }
// 
//     public static String getItemId(Uri uri) {
//         return uri.getLastPathSegment();
//     }
// }
// 
// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/provider/ShoprContract.java
// public static class Shops implements ShopsColumns, BaseColumns {
//     public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
//             .appendPath(PATH_SHOPS).build();
// 
//     /** Use if multiple items get returned */
//     public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.shopr.shop";
// 
//     /** Use if a single item is returned */
//     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.shopr.shop";
// 
//     public static Uri buildShopUri(int shopId) {
//         return CONTENT_URI.buildUpon().appendPath(String.valueOf(shopId))
//                 .build();
//     }
// 
//     public static String getShopId(Uri uri) {
//         return uri.getLastPathSegment();
//     }
// }
// 
// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/utils/Utils.java
// public class Utils {
// 
//     /**
//      * Returns the first http url out of the given array in the form of
//      * "[http://abc,http://cde]".
//      */
//     public static String extractFirstUrl(String arrayAsString) {
//         arrayAsString = arrayAsString.substring(1, arrayAsString.length() - 1);
//         /*
//          * Some eBay URLs sadly include commas (,), so really split by ",http".
//          * We only want the first one anyhow.
//          */
//         String url = arrayAsString.split(",http")[0];
//         return url;
//     }
// 
// }


import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import au.com.bytecode.opencsv.CSVReader;
import com.uwetrottmann.androidutils.Lists;
import com.uwetrottmann.shopr.R;
import com.uwetrottmann.shopr.provider.ShoprContract.Items;
import com.uwetrottmann.shopr.provider.ShoprContract.Shops;
import com.uwetrottmann.shopr.utils.Utils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;
            }

            Log.d(TAG, "Importing the following CSV schema: " + Arrays.toString(firstLine));

            String[] line;
            Random random = new Random(123456); // seed to get fixed
                                                // distribution
            while ((line = reader.readNext()) != null) {
                ContentValues values = new ContentValues();

                switch (mType) {
                    case IMPORT_SHOPS:
                        // add values for one shop
                        values.put(Shops._ID, line[0]);
                        values.put(Shops.NAME, line[1]);
                        values.put(Shops.OPENING_HOURS, line[2]);
                        values.put(Shops.LAT, line[5]);
                        values.put(Shops.LONG, line[6]);
                        break;
                    case IMPORT_ITEMS:
                        // add values for one item
                        values.put(Items._ID, line[0]);
                        values.put(Shops.REF_SHOP_ID, random.nextInt(129));
                        values.put(Items.CLOTHING_TYPE, line[1]);
                        values.put(Items.SEX, line[2]);
                        values.put(Items.COLOR, line[3]);
                        values.put(Items.BRAND, line[4]);
                        values.put(Items.PRICE, line[5]);
                        // extract first image
                        String imageUrl = line[6];
// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/provider/ShoprContract.java
// public static class Items implements ItemsColumns, BaseColumns {
//     public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
//             .appendPath(PATH_ITEMS).build();
// 
//     /** Use if multiple items get returned */
//     public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.shopr.item";
// 
//     /** Use if a single item is returned */
//     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.shopr.item";
// 
//     public static Uri buildItemUri(int itemId) {
//         return CONTENT_URI.buildUpon().appendPath(String.valueOf(itemId))
//                 .build();
//     }
// 
//     public static String getItemId(Uri uri) {
//         return uri.getLastPathSegment();
//     }
// }
// 
// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/provider/ShoprContract.java
// public static class Shops implements ShopsColumns, BaseColumns {
//     public static final Uri CONTENT_URI = BASE_CONTENT_URI.buildUpon()
//             .appendPath(PATH_SHOPS).build();
// 
//     /** Use if multiple items get returned */
//     public static final String CONTENT_TYPE = "vnd.android.cursor.dir/vnd.shopr.shop";
// 
//     /** Use if a single item is returned */
//     public static final String CONTENT_ITEM_TYPE = "vnd.android.cursor.item/vnd.shopr.shop";
// 
//     public static Uri buildShopUri(int shopId) {
//         return CONTENT_URI.buildUpon().appendPath(String.valueOf(shopId))
//                 .build();
//     }
// 
//     public static String getShopId(Uri uri) {
//         return uri.getLastPathSegment();
//     }
// }
// 
// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/utils/Utils.java
// public class Utils {
// 
//     /**
//      * Returns the first http url out of the given array in the form of
//      * "[http://abc,http://cde]".
//      */
//     public static String extractFirstUrl(String arrayAsString) {
//         arrayAsString = arrayAsString.substring(1, arrayAsString.length() - 1);
//         /*
//          * Some eBay URLs sadly include commas (,), so really split by ",http".
//          * We only want the first one anyhow.
//          */
//         String url = arrayAsString.split(",http")[0];
//         return url;
//     }
// 
// }


// Path: Android/Shopr/src/main/java/com/uwetrottmann/shopr/importer/CsvImportTask.java
import android.content.ContentValues;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.util.Log;
import android.widget.Toast;
import au.com.bytecode.opencsv.CSVReader;
import com.uwetrottmann.androidutils.Lists;
import com.uwetrottmann.shopr.R;
import com.uwetrottmann.shopr.provider.ShoprContract.Items;
import com.uwetrottmann.shopr.provider.ShoprContract.Shops;
import com.uwetrottmann.shopr.utils.Utils;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Random;

            }

            Log.d(TAG, "Importing the following CSV schema: " + Arrays.toString(firstLine));

            String[] line;
            Random random = new Random(123456); // seed to get fixed
                                                // distribution
            while ((line = reader.readNext()) != null) {
                ContentValues values = new ContentValues();

                switch (mType) {
                    case IMPORT_SHOPS:
                        // add values for one shop
                        values.put(Shops._ID, line[0]);
                        values.put(Shops.NAME, line[1]);
                        values.put(Shops.OPENING_HOURS, line[2]);
                        values.put(Shops.LAT, line[5]);
                        values.put(Shops.LONG, line[6]);
                        break;
                    case IMPORT_ITEMS:
                        // add values for one item
                        values.put(Items._ID, line[0]);
                        values.put(Shops.REF_SHOP_ID, random.nextInt(129));
                        values.put(Items.CLOTHING_TYPE, line[1]);
                        values.put(Items.SEX, line[2]);
                        values.put(Items.COLOR, line[3]);
                        values.put(Items.BRAND, line[4]);
                        values.put(Items.PRICE, line[5]);
                        // extract first image
                        String imageUrl = line[6];
                        imageUrl = Utils.extractFirstUrl(imageUrl);