// Path: app/src/main/java/com/crazymin2/retailstore/ApplicationController.java
// public class ApplicationController extends Application {
// 
//     private static ApplicationController mInstance;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         mInstance = this;
//     }
// 
//     public static synchronized ApplicationController getInstance() {
//         return mInstance;
//     }
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/home/data/Category.java
// public class Category {
// 
//     public int id;
//     public int categoryId;
//     public String imageUrlOriginal;
//     public String imageUrlThumb;
//     public String imageUrlSmall;
//     public String imageUrlMedium;
//     public String name;
// 
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/home/data/Product.java
// public class Product implements Parcelable {
// 
//     public int id;
//     public int categoryId;
//     public int productId;
//     public String price;
//     public String imageUrlOriginal;
//     public String imageUrlThumb;
//     public String imageUrlSmall;
//     public String imageUrlMedium;
//     public String name;
// 
//     /*
//     * Utility variables which are supposed to work for item deletion and addition
//     */
//     public boolean isInCart = false;
//     public double totalPrice = 0;
// 
//     public Product(){
// 
//     }
// 
// 
//     protected Product(Parcel in) {
//         id = in.readInt();
//         categoryId = in.readInt();
//         productId = in.readInt();
//         price = in.readString();
//         imageUrlOriginal = in.readString();
//         imageUrlThumb = in.readString();
//         imageUrlSmall = in.readString();
//         imageUrlMedium = in.readString();
//         name = in.readString();
//         isInCart = in.readByte() != 0;
//         totalPrice = in.readDouble();
//     }
// 
//     public static final Creator<Product> CREATOR = new Creator<Product>() {
//         @Override
//         public Product createFromParcel(Parcel in) {
//             return new Product(in);
//         }
// 
//         @Override
//         public Product[] newArray(int size) {
//             return new Product[size];
//         }
//     };
// 
//     /*
//     * (non-Javadoc)
//     *
//     * @see java.lang.Object#equals(java.lang.Object)
//     *
//     * Please don not override toString() method it will give response which cause override method
//     * equals() failure.
//     *
//     * the reason behind to override equals and hashCode method is to compare added cart products in
//     * local database with the products coming from server on basis of unique product id.
//     */
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (obj == null)
//             return false;
//         if (getClass() != obj.getClass())
//             return false;
//         Product other = (Product) obj;
//         if (id != other.id)
//             return false;
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         final int prime = 31;
//         int result = 1;
//         result = prime * result + id;
//         return result;
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeInt(id);
//         dest.writeInt(categoryId);
//         dest.writeInt(productId);
//         dest.writeString(price);
//         dest.writeString(imageUrlOriginal);
//         dest.writeString(imageUrlThumb);
//         dest.writeString(imageUrlSmall);
//         dest.writeString(imageUrlMedium);
//         dest.writeString(name);
//         dest.writeByte((byte) (isInCart ? 1 : 0));
//         dest.writeDouble(totalPrice);
//     }
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/util/LogUtils.java
// public static void LOGE(final String tag, String message) {
//     if (LOGGING_ENABLED){
//         Log.e(tag, message);
//     }
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/util/LogUtils.java
// public static String makeLogTag(String str) {
//     if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
//         return LOG_PREFIX + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH - 1);
//     }
// 
//     return LOG_PREFIX + str;
// }


import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.crazymin2.retailstore.ApplicationController;
import com.crazymin2.retailstore.home.data.Category;
import com.crazymin2.retailstore.home.data.Product;
import java.util.ArrayList;
import static com.crazymin2.retailstore.util.LogUtils.LOGE;
import static com.crazymin2.retailstore.util.LogUtils.makeLogTag;
            database = dbHelper.getReadableDatabase();
            cursor = database.query(CATEGORY.TABLE_NAME, null, null, null, null, null, null);

            if (cursor.moveToFirst()) {
                do {
                    Category category = new Category();
                    category.id = getIntValue(cursor, CATEGORY._ID);
                    category.categoryId = getIntValue(cursor, CATEGORY.CATEGORY_ID);
                    category.imageUrlOriginal = getStringValue(cursor, CATEGORY.IMAGE_URL_ORIGINAL);
                    category.imageUrlThumb = getStringValue(cursor, CATEGORY.IMAGE_URL_THUMB);
                    category.imageUrlSmall = getStringValue(cursor, CATEGORY.IMAGE_URL_SMALL);
                    category.imageUrlMedium = getStringValue(cursor, CATEGORY.IMAGE_URL_MEDIUM);
                    category.name = getStringValue(cursor, CATEGORY.NAME);
                    categories.add(category);
                } while (cursor.moveToNext());
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (database != null) {
                database.close();
            }
            if (cursor != null && !cursor.isClosed()) {
                cursor.close();
            }
        }
        return categories;
    }

// Path: app/src/main/java/com/crazymin2/retailstore/ApplicationController.java
// public class ApplicationController extends Application {
// 
//     private static ApplicationController mInstance;
// 
//     @Override
//     public void onCreate() {
//         super.onCreate();
//         mInstance = this;
//     }
// 
//     public static synchronized ApplicationController getInstance() {
//         return mInstance;
//     }
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/home/data/Category.java
// public class Category {
// 
//     public int id;
//     public int categoryId;
//     public String imageUrlOriginal;
//     public String imageUrlThumb;
//     public String imageUrlSmall;
//     public String imageUrlMedium;
//     public String name;
// 
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/home/data/Product.java
// public class Product implements Parcelable {
// 
//     public int id;
//     public int categoryId;
//     public int productId;
//     public String price;
//     public String imageUrlOriginal;
//     public String imageUrlThumb;
//     public String imageUrlSmall;
//     public String imageUrlMedium;
//     public String name;
// 
//     /*
//     * Utility variables which are supposed to work for item deletion and addition
//     */
//     public boolean isInCart = false;
//     public double totalPrice = 0;
// 
//     public Product(){
// 
//     }
// 
// 
//     protected Product(Parcel in) {
//         id = in.readInt();
//         categoryId = in.readInt();
//         productId = in.readInt();
//         price = in.readString();
//         imageUrlOriginal = in.readString();
//         imageUrlThumb = in.readString();
//         imageUrlSmall = in.readString();
//         imageUrlMedium = in.readString();
//         name = in.readString();
//         isInCart = in.readByte() != 0;
//         totalPrice = in.readDouble();
//     }
// 
//     public static final Creator<Product> CREATOR = new Creator<Product>() {
//         @Override
//         public Product createFromParcel(Parcel in) {
//             return new Product(in);
//         }
// 
//         @Override
//         public Product[] newArray(int size) {
//             return new Product[size];
//         }
//     };
// 
//     /*
//     * (non-Javadoc)
//     *
//     * @see java.lang.Object#equals(java.lang.Object)
//     *
//     * Please don not override toString() method it will give response which cause override method
//     * equals() failure.
//     *
//     * the reason behind to override equals and hashCode method is to compare added cart products in
//     * local database with the products coming from server on basis of unique product id.
//     */
// 
//     @Override
//     public boolean equals(Object obj) {
//         if (this == obj)
//             return true;
//         if (obj == null)
//             return false;
//         if (getClass() != obj.getClass())
//             return false;
//         Product other = (Product) obj;
//         if (id != other.id)
//             return false;
//         return true;
//     }
// 
//     @Override
//     public int hashCode() {
//         final int prime = 31;
//         int result = 1;
//         result = prime * result + id;
//         return result;
//     }
// 
//     @Override
//     public int describeContents() {
//         return 0;
//     }
// 
//     @Override
//     public void writeToParcel(Parcel dest, int flags) {
//         dest.writeInt(id);
//         dest.writeInt(categoryId);
//         dest.writeInt(productId);
//         dest.writeString(price);
//         dest.writeString(imageUrlOriginal);
//         dest.writeString(imageUrlThumb);
//         dest.writeString(imageUrlSmall);
//         dest.writeString(imageUrlMedium);
//         dest.writeString(name);
//         dest.writeByte((byte) (isInCart ? 1 : 0));
//         dest.writeDouble(totalPrice);
//     }
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/util/LogUtils.java
// public static void LOGE(final String tag, String message) {
//     if (LOGGING_ENABLED){
//         Log.e(tag, message);
//     }
// }
// 
// Path: app/src/main/java/com/crazymin2/retailstore/util/LogUtils.java
// public static String makeLogTag(String str) {
//     if (str.length() > MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH) {
//         return LOG_PREFIX + str.substring(0, MAX_LOG_TAG_LENGTH - LOG_PREFIX_LENGTH - 1);
//     }
// 
//     return LOG_PREFIX + str;
// }


// Path: app/src/main/java/com/crazymin2/retailstore/database/DatabaseManager.java
import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import com.crazymin2.retailstore.ApplicationController;
import com.crazymin2.retailstore.home.data.Category;
import com.crazymin2.retailstore.home.data.Product;
import java.util.ArrayList;
import static com.crazymin2.retailstore.util.LogUtils.LOGE;
import static com.crazymin2.retailstore.util.LogUtils.makeLogTag;

            database = dbHelper.getReadableDatabase();
            cursor = database.query(CATEGORY.TABLE_NAME, null, null, null, null, null, null);

            if (cursor.moveToFirst()) {
                do {
                    Category category = new Category();
                    category.id = getIntValue(cursor, CATEGORY._ID);
                    category.categoryId = getIntValue(cursor, CATEGORY.CATEGORY_ID);
                    category.imageUrlOriginal = getStringValue(cursor, CATEGORY.IMAGE_URL_ORIGINAL);
                    category.imageUrlThumb = getStringValue(cursor, CATEGORY.IMAGE_URL_THUMB);
                    category.imageUrlSmall = getStringValue(cursor, CATEGORY.IMAGE_URL_SMALL);
                    category.imageUrlMedium = getStringValue(cursor, CATEGORY.IMAGE_URL_MEDIUM);
                    category.name = getStringValue(cursor, CATEGORY.NAME);
                    categories.add(category);
                } while (cursor.moveToNext());
            }

        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            if (database != null) {
                database.close();
            }
            if (cursor != null && !cursor.isClosed()) {
                cursor.close();
            }
        }
        return categories;
    }

    public ArrayList<Product> getProductsByCategory(int categoryId) {