Coder Social home page Coder Social logo

quantitizer's Introduction

Quantitizer

Jit

Android Arsenal

Android Weekly Kotlin Weekly

✨ A highly customizable quantity stepper for android projects

Demo

demo demo demo demo

Setup

Add it in your root build.gradle at the end of repositories:

allprojects {
    repositories {
        //...omitted for brevity
        maven { url 'https://jitpack.io' }
    }
}

Add the dependency

dependencies {
   implementation "com.github.kojofosu:Quantitizer:$latest_release"
}

Usage

Sample implementation here

Horizontal Quantitizer

  • Add HorizontalQuantitizer in your layout xml file
demo demo
    <com.mcdev.quantitizerlibrary.HorizontalQuantitizer
        android:id="@+id/h_q"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Vertical Quantitizer

  • Add VerticalQuantitizer in your layout xml file
demo demo
    <com.mcdev.quantitizerlibrary.VerticalQuantitizer
        android:id="@+id/v_q"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

No Value Quantitizer

  • Add NoValueQuantitizer in your layout xml file
demo
    <com.mcdev.quantitizerlibrary.NoValueQuantitizer
        android:id="@+id/n_q"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"/>

Get quantity value

    var hQ: HorizontalQuantitizer = findViewById(R.id.h_q)
    var selectedValue = hQ.value    //get current value

Listener

        hQ.setQuantitizerListener(object: QuantitizerListener{
            override fun onIncrease() {
                Toast.makeText(this@MainActivity, "inc", Toast.LENGTH_SHORT).show()
            }

            override fun onDecrease() {
                Toast.makeText(this@MainActivity, "dec", Toast.LENGTH_SHORT).show()
            }

            override fun onValueChanged(value: Int) {
                Toast.makeText(this@ButtonsOnlyActivity, "value changed to : $value", Toast.LENGTH_SHORT).show()
            }
        })

Customize Quantitizer

Change text/value animation style

    hQ.textAnimationStyle = AnimationStyle.SLIDE_IN

List of current animations

ANIMATION DEMO
FALL_IN demo
SLIDE_IN demo
SLIDE_IN_REVERSE demo
SWING demo

Disable button animations

    hQ.isReadOnly = false // Disable value input from keyboard. Default false
    hQ.buttonAnimationEnabled = false //Default true

demo demo

Change animation duration

    hQ.animationDuration = 400L //Default 300L

Change icons

    hQ.setPlusIcon(R.drawable.ic_angle_double_small_right)
    hQ.setMinusIcon(R.drawable.ic_angle_double_small_left)

Change icon backgrounds

    hQ.setPlusIconBackgroundColor(android.R.color.holo_red_dark)
    hQ.setMinusIconBackgroundColor(android.R.color.holo_red_dark)

Change value text and background color

    hQ.setValueBackgroundColor(android.R.color.holo_red_dark)
    hQ.setValueTextColor("#FFFF00")

Change icon colors

    hQ.setMinusIconColor("#FFFF00")
    hQ.setPlusIconColor("#FFFF00")

Licensed under the MIT License

MIT License

Copyright (c) 2021 Kojo Fosu Bempa Edue

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

quantitizer's People

Contributors

kojofosu avatar shahad161 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

quantitizer's Issues

Crash when typing value manually

When I try to insert the quantitizer value with soft keyboard, when it reaches high values (probably exceedes Integer.MAX_INT) the app crash.
I've already set both minValue and maxValue

Min SDK 23?

@kojofosu

Hi, I just tried to add your library (Quantizer) to one of my apps and realized the min SDK supported is 23. Do you happen to know if that's required or just what you used when writing this?

My app goes down to SDK 18 and I know I can override the min SDK but didn't want to cause any crashes on lower versions. I could also look into supporting lower versions if possible..

thanks!
joe

控件尺寸不支持自定义缩放

根据我们UI图的设计,整个控件放上去太大;现在只能通过
android:scaleX="0.66"
android:scaleY="0.66"
的方式调整,但是这样写的话两边会留白

setQuantitizerListener Java

Hey man,

nice library but i cant figure out how to use the Listener in an java instead of Kotlin

hope u can provide me with some sample code

Border color of plus and minus buttons

Hello there. I wanted to ask if there is any possibility to modify the border color of the plus and minus buttons, like in the picture below. If not, I would appreciate it if you could add it, because overall you've done amazing work.
BorderColor

Text doesn't reflect accurate quantity if button is pressed fast

Hey @kojofosu, thanks for the awesome lib. Really appreciate your work.

I added version 1.6.4 to an app that I'm building, and I observed that the quantity text doesn't accurately reflect how many times the plus button is clicked.
Check this screen capture:
https://user-images.githubusercontent.com/22092047/148506863-425bafb7-298c-49ea-ba0f-846c1b0a1f15.mp4

But the log indicates that the current quantity has bumped up to 36, instead of 19, which is what's displayed in the text.

2022-01-07 12:49:06.252 20694-20694/com.sanskar.app D/App: Quantity Increased, now item: InventoryItem(maxQuantity=50, name=Perk, price=50, currentQuantity=35)
2022-01-07 12:49:06.393 20694-20694/com.sanskar.app D/App: Quantity Increased, now item: InventoryItem(maxQuantity=50, name=Perk, price=50, currentQuantity=36)

I know it's extremely unlikely that a potential user will perform this kind of action in the app, but I'd still like to prevent any issues in the future. Let me know if I can do anything to fix this issue.

Thanks!

font and text

Hello, please add the feature of changing the font and font size and face to the middle text.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.