A Shopping cart library for Android that allows you add to add items to cart and retrieve at ease using JSONObjects.

Related tags

JSON Carteasy
Overview

Android Arsenal

Carteasy

A Shopping cart library for Android that allows you add to add items to cart and retrieve at ease using JSONObjects.

Quick Start

Add the following dependency to your build.gradle:

Dependencies will come here.

For Gradle:

implementation 'com.carteasy.v1.lib:carteasy:0.0.6'

For Maven: include maven url to repositories in build.gradle (module)

allprojects {
   repositories {
       jcenter()
       maven {
           url  "http://dl.bintray.com/tosinmath007/Carteasy"
       }
   }
}

You should then checkout the library and investigate the sample code, which covers some of the features.

Usage

Adding items to cart

Carteasy cs = new Carteasy();
cs.add(String id, String key, Object value);
cs.commit(getApplicationContext());
cs.add("Your Product Id", "key", "value");

Your product items is tied to your Id and can be retrieved anytime the Id is produced.

String productIdOne = "e400";
String productIdTwo= "e401";
Carteasy cs = new Carteasy();

cs.add(productIdOne, "product name", "Marlboro");
cs.add(productIdOne, "product description", "cigarate box");
cs.add(productIdOne, "product price", 200.00);
cs.add(productIdOne, "quantity", 5);
cs.add(productIdOne, "currency", "dollar");
...
cs.commit(getApplicationContext());

cs.add(productIdTwo, "product name", "Starbucks coffee");
cs.add(productIdTwo, "product description", "coffee bags");
cs.add(productIdTwo, "product price", 100.00);
cs.add(productIdTwo, "quantity", 9);
cs.add(productIdTwo, "currency", "dollar");
...
cs.commit(getApplicationContext());

Always keep data even when app is closed

cs.persistData(getApplicationContext(), true);

Retrieve item by Id and key

Returns an object. you can use it as an object or typecast it to what ever you want

Carteasy cs = new Carteasy();
Object value = cs.get( String id, String key, getApplicationContext());

Returns a String

Carteasy cs = new Carteasy();
String value = cs.getString( String id, String key, getApplicationContext());

You can return type of value using either of these below:

String

String value = cs.getString(String id, String key, Context context);

Integer

int value = cs.getInteger(String id, String key, Context context);

Float

Float value = cs.getFloat(String id, String key, Context context);

Double

Double value = cs.getDouble(String id, String key, Context context);

Long

Long value = cs.getLong(String id, String key, Context context);

Short

Short value = cs.getShort(String id, String key, Context context);

Update Items

To update a items value, you have to pass the id, key and your newValue as parameters

Carteasy cs = new Carteasy();
cs.update(String id, String key, Object newValue, Context context);

Removing specific item value from cart

Carteasy cs = new Carteasy();
cs.Removekey(String id, String key, Context context);

Removing item and its property value from cart

Carteasy cs = new Carteasy();
cs.RemoveId(String id, Context context);

Clearing all items from cart

Carteasy cs = new Carteasy();
cs.clearCart(Context context);

Viewing all items stored in cart

 Map<Integer, Map> data;
 Carteasy cs = new Carteasy();
 data = cs.ViewAll(Context context);

 for (Map.Entry<Integer, Map> entry : data.entrySet()) {
    //get the Id
    Log.d("Key: ",entry.getKey());
    Log.d("Value: ",entry.getValue());

    //Get the items tied to the Id
    Map<String, String> innerdata = entry.getValue();
    for (Map.Entry<String, String> innerentry : innerdata.entrySet()) {
        Log.d("Inner Key: ",innerentry.getKey());
        Log.d("Inner Value: ",innerentry.getValue());
    }
 }

Viewing all items stored which is tied to an ID

Carteasy cs = new Carteasy();
Map<String, String> data = cs.ViewData(String id, Context context);

for (Map.Entry<String, String> entry : data.entrySet()) {
   //get the Id
   Log.d("Key: ",entry.getKey());
   Log.d("Value: ",entry.getValue());
}

To persist data even when the app is closed, set persistData to True

Carteasy cs = new Carteasy();
cs.persistData(Context context, boolean true);

To Stop persist data, , set persistData to False

Carteasy cs = new Carteasy();
cs.persistData(Context context, boolean false);

Check isPersistEnabled

Carteasy cs = new Carteasy();
cs.isPersistEnabled(Context context);

doesIDExistInCart

boolean value = cs.doesIDExistInCart(String id, Context context);

Caveats

Nothing here for now.

Credits

This library depends on json-simple-1.1.1

License

Copyright (C) 2017 Tosin Onikute.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

	http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
Comments
  • ClearCart Error

    ClearCart Error

    This Error occurs when i call the clearCart Method: java.util.ConcurrentModificationException at java.util.HashMap$HashIterator.nextEntry(HashMap.java:851) at java.util.HashMap$KeyIterator.next(HashMap.java:885) at com.carteasy.v1.lib.RemoveData.clearAllFromCart(RemoveData.java:194) at com.carteasy.v1.lib.Carteasy.clearCart(Carteasy.java:152)

    opened by rademoh 4
  • Unable to Remove Specific Item from Cart

    Unable to Remove Specific Item from Cart

    When Removing a specific item from cart by using CartEasy.RemoveId() method it gives, "key does not found" error and when use CartEasy.RemoveKey() method by passing id and every key it gives "ID does not exist" error but I have verified, ID exist in cart and same is passing to methods.

    D/Carteasy:: ID does not exist I/chatty: uid=10519(pk.genie.shop) identical 6 lines D/Carteasy:: ID does not exist W/libEGL: EGLNativeWindowType 0x7c7fa84090 disconnect failed D/OpenGLRenderer: endAllActiveAnimators on 0x7bcb3ffb00 (RippleDrawable) with handle 0x7bf4391b00

    opened by shandogar 1
  • Cannot turn on persistance.

    Cannot turn on persistance.

    cs.persistData(getApplicationContext, true); does not work. Even after adding this line of code, when I restart my application everything starts all over again. Please tell me how to fix this. Or how to use it properly.

    opened by saqibarshad 1
  • *** Feature Request ***

    *** Feature Request ***

    The really simple yet great library saves a lot of time

    Just add a check data feature like if some id is in cart or not checking this every time with look is make it a bit messy

    opened by codegente 1
  • Long cannot be cast to Integer

    Long cannot be cast to Integer

    I'm trying to add 1 to a quantity when the cart doesn't exist (so file not found exception) and concatenate the quantity when it does. Unfortunately I'm having a ClassCastException. Here's my code :

    Carteasy cs = new Carteasy(); cs.add(menuIdsList.get(position), "name", menu.getName()); cs.add(menuIdsList.get(position), "description", menu.getDescription()); cs.add(menuIdsList.get(position), "price", menu.getPrice()); cs.add(menuIdsList.get(position), "picture", menu.getPicture()); try { int quantity = cs.getInteger(menuIdsList.get(position), "quantity", context.getApplicationContext()); ++quantity; Log.d("Menu Adapter", "Quantity : " + quantity); cs.update(menuIdsList.get(position), "quantity", quantity, context.getApplicationContext()); } catch (Exception e) { Log.w("Menu Adapter", e); cs.add(menuIdsList.get(position), "quantity", 1); } finally { cs.commit(context.getApplicationContext()); Log.d("Menu Adapter", "Changes to cart saved"); }

    java.lang.ClassCastException: java.lang.Long cannot be cast to java.lang.Integer at com.carteasy.v1.lib.Carteasy.getInteger(Carteasy.java:115) at stage.adapters.MenuAdapter$1.onClick(MenuAdapter.java:85) at android.view.View.performClick(View.java:6303) at android.view.View$PerformClick.run(View.java:24828) at android.os.Handler.handleCallback(Handler.java:789) at android.os.Handler.dispatchMessage(Handler.java:98) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6809) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:240) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)

    opened by florianhirson 1
Releases(0.0.6)
Owner
Tosin Onikute
Android & iOS Engineer
Tosin Onikute
Manager of progress using Lottie JSON, compatible for Java and Kotlin.

Progress Lottie IGB Manager of progress using Lottie JSON, compatible for Java and Kotlin. Int Top In Bottom Important Info: To create a raw folder: R

Isaac G. Banda 21 Sep 16, 2022
A Java serialization/deserialization library to convert Java Objects into JSON and back

Gson Gson is a Java library that can be used to convert Java Objects into their JSON representation. It can also be used to convert a JSON string to a

Google 21.7k Jan 5, 2023
A modern JSON library for Kotlin and Java.

Moshi Moshi is a modern JSON library for Android and Java. It makes it easy to parse JSON into Java objects: String json = ...; Moshi moshi = new Mos

Square 8.7k Jan 2, 2023
xls2json - Read in Excel file (.xls, .xlsx, .xlsm) and output JSON

xls2json Read in Excel file (.xls, .xlsx, .xlsm) and output JSON. Evaluates formulas where possible. Preserve type information from Excel via JSON typ

Tammo Ippen 39 Oct 19, 2022
Simple CLI app to convert XML retrieved from a configurable URI to JSON and back

XmlToJsonUtility Simple CLI app written in Kotlin (1.5.31) on Java 11, using Spring Boot. Queries a URI (default) as an XML source. Attempts to valida

Darius Washington 2 Oct 20, 2021
Customizable JSON Schema-based forms for Kotlin and Compose

Kotlin JSON Forms Customizable JSON Schema-based forms for Kotlin and Compose This project aims to reimplement JSON Forms in Kotlin for use in Compose

Copper Leaf 3 Oct 1, 2022
🛒 Add a cart icon with item counter to the Toolbar. You can increment the counter based on the number of unique items the user has in the shopping cart.

Status CartCounter Add a cart icon with item counter to the Toolbar. You can increment the counter based on the number of unique items the user has in

Rowland Oti 30 Sep 23, 2021
Application that allows to search some products and display them in a list, also allows to add some product to the shopping cart and remove it

Application that allows to search some products and display them in a list, also allows to add some product to the shopping cart and remove it

Victor 3 Aug 18, 2022
An android app that show us nike products and user can buy them or add to shopping cart.

Nike Store-Android-App An android app that show us nike products and user can buy them or add to shopping cart. Screenshots Libraries included Materia

mojtaba joshaghani 9 Aug 13, 2022
Online Shopping Application which uses Augmented Reality(AR) for product trials, thus completely changing shopping experiences.

ShopOn This is an Android Native application which is developed as a solution for HackOn with Amazon 2022 for the problem statement related to shoppin

Akshat Kumar Verma 17 Dec 23, 2022
A shopping cart button with a telescopic displacement rotation animation ...一个带伸缩位移旋转动画的购物车按钮

AnimShopButton A shopping cart button with a telescopic displacement rotation animation ... 一个仿饿了么 带伸缩位移旋转动画的购物车按钮 注意,本控件非继承自ViewGroup,而是纯自定义View,实现的仿

张旭童 1.3k Nov 10, 2022
SimpleToDo is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item.

SimpleToDo is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item.

null 0 Jan 3, 2022
Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item

Todo List Application is an android app that allows building a todo list and basic todo items management functionality including adding new items, editing and deleting an existing item

null 0 Jan 22, 2022
[] An Android library which allows developers to easily add animations to ListView items

DEPRECATED ListViewAnimations is deprecated in favor of new RecyclerView solutions. No new development will be taking place, but the existing versions

Niek Haarman 5.6k Dec 30, 2022
Android ListView that mimics a GridView with asymmetric items. Supports items with row span and column span

AsymmetricGridView An Android custom ListView that implements multiple columns and variable sized elements. Please note that this is currently in a pr

Felipe Lima 1.8k Jan 7, 2023
Drag and drop to reorder items in a list, grid or board for Android. Based on RecyclerView. Also supports swiping items in a list.

DragListView DragListView can be used when you want to be able to re-order items in a list, grid or a board. It also supports horizontal swiping of it

Magnus Woxblom 658 Nov 30, 2022
App made using Kotlin to retrieve data from an API and show in a recyclerview with Login and SignUp features

App made using Kotlin to retrieve data from an API and show in a recyclerview with Login and SignUp features.

Altair Wallace 1 Feb 17, 2022
🚀 A very customizable library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet.

SlidingUpMenu A library that allows you to present menu items (from menu resource and/or other sources) to users as a bottom sheet. Gradle Dependency

Rasheed Sulayman 26 Jul 17, 2022
Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose

MVVM Clean Architecture Demo Retrieve Data from an API using MVVM Clean Architecture and Jetpack Compose. It simply shows a list of movies fetched fro

Daniel Kago 2 Sep 16, 2022
MiHawk 🦅👁️ is simple and secure 🔒 Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack DataStore Preferences 💽 to store data.

MiHawk MiHawk ?? ??️ is simple and secure ?? Android Library to store and retrieve pair of key-value data with encryption , internally it use jetpack

Nedal Hasan Ibrahem 5 Sep 3, 2022