IncDec


Source link: https://github.com/Hariofspades/IncDec

IncDec Android UI Library

Incrementor and Decrementor (IncDec)

IncDec library will allow you to perform increment and decrement operation. As it supports single click and long press, it enhances UX solving the delay problem in the typical number picker.

Usecase of IncDec ?

  • IncDec can be used as an alternate for numberpicker, for fast number picking. User need not scroll the wheel for long time. He can just press and hold the button and IncDec will do it's magic.
  • For usecases like shopping cart quantity, medicine units, setting up time and medicine quantity, IncDec will hold good

Why IncDec ?

  • It is based on skeuomorphism concept of picking a number.
  • simple and auto-explanatory to the user
  • Allows user to quickly pick things
  • Supports Array values, Integer and float values
  • Highly flexible (supporting color, drawable, speed etc.)
  • Long press and single tap support
  • FAB and ImageButton support

Find this project useful ? ❤?

  • Support it by clicking the ⭐? button on the upper right of this page. ✌?

Requirements

IncDec Library can be included in any Android application.

IncDec Library supports Android 2.3 (Gingerbread) and later.

What's new in 0.0.5?

  • Migrated all thread related operations to Reactive Extensions (Rx)
  • Bug Fixes for Pre lollipop devices

Using IncDec Library in your application

Add this in your build.gradle

compile 'com.hariofspades.IncDec:incdeclibrary:0.0.5'

Adding IncDec FAB in to the XML

<com.hariofspades.incdeclibrary.IncDecCircular

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:textSize="44"

android:id="@+id/incdec"

app:textColor="@color/white"

app:leftButtonColorTint="@color/colorPrimaryDark"

app:rightButtonColorTinit="@color/colorPrimary"

app:leftDrawableTint="@color/white"

app:rightDrawableTint="@color/white"

app:leftDrawable="@drawable/ic_remove_black_24dp"

app:rightDrawable="@drawable/ic_add_black_24dp"/>

Setting up Array values to IncDec

ArrayList<String> values=new ArrayList<>();

values.add("Apple");

values.add("Ball");

values.add("Cat");

values.add("Dog");

values.add("Elephant");

  IncDecCircular incdec=(IncDecCircular)findViewById(R.id.incdec);
  incdec.setConfiguration(LinearLayout.HORIZONTAL,IncDecCircular.TYPE_ARRAY,

  IncDecCircular.DECREMENT,IncDecCircular.INCREMENT);
  incdec.setArrayList(values);
  incdec.setArrayIndexes(1,3,1);
  incdec.enableLongPress(true,true,500);

Decoding the above function parameters

setConfiguration - Layout's orientation, type(array,integer,float),left button (increment/decrement), right button (increment/decrement)

setArrayList - arraylist values

setArrayIndexes - starting index, stoping index, interval count

enableLongPress - for left button, right button and the speed in ms for counting

Making IncDec behave for float values

IncDecCircular incdec =(IncDecCircular) findViewById(R.id.incdec);
 incdec.setConfiguration(LinearLayout.VERTICAL,IncDecCircular.TYPE_FLOAT,

  IncDecCircular.INCREMENT,IncDecCircular.DECREMENT);
 incdec.setupValues(2,40,(float)0.7,10);
 incdec.setprecision("%.1f");
 incdec.enableLongPress(false,false,500);

Decoding function parameters

setupValues - intial value final value, interval and start value

setprecision - Restricting decimal places

Making IncDec behave for integers

IncDecCircular incdec=(IncDecCircular)findViewById(R.id.incdec);
 incdec.setConfiguration(LinearLayout.HORIZONTAL,IncDecCircular.TYPE_INTEGER,

  IncDecCircular.DECREMENT,IncDecCircular.INCREMENT);
 incdec.setupValues(0,20,1,4);
 incdec.enableLongPress(true,true,500);

Listeners for IncDec

 incdec.setOnClickListener(new IncDecCircular.OnClickListener() {

 @Override

 public void onClick(View view) {

  //For Array

  Toast.makeText(MainActivity.this,

 String.valueOf(incdec.getCurrentIndex()), Toast.LENGTH_SHORT).show();

  //For int and float

  Toast.makeText(MainActivity.this,

 incdec.getValue(), Toast.LENGTH_SHORT).show();

 
}

}
);

incdec.setOnValueChangeListener(new IncDecCircular.OnValueChangeListener() {

 @Override

 public void onValueChange(IncDecCircular view, float oldValue, float newValue) {

  Toast.makeText(MainActivity.this, String.valueOf(oldValue)+"/"+

 String.valueOf(newValue), Toast.LENGTH_SHORT).show();

 
}

}
);

  

IncDec for traditional ImageButton

 <com.hariofspades.incdeclibrary.IncDecImageButton

android:layout_width="wrap_content"

android:layout_height="wrap_content"

app:textSizeB="24"

android:id="@+id/incdec"

android:layout_marginTop="20dp"

app:textColorB="@color/white"

app:leftButtonColorTintB="@color/colorPrimaryDark"

app:rightButtonColorTinitB="@color/colorPrimary"

app:leftDrawableTintB="@color/white"

app:rightDrawableTintB="@color/white"

app:leftDrawableB="@drawable/ic_remove_black_24dp"

app:rightDrawableB="@drawable/ic_add_black_24dp"/>

For Adding your own Background for ImageButton

 IncDecImageButton incdecImg2=(IncDecImageButton) findViewById(R.id.incdecbut2);

  incdecImg2.setBackgroundforButton(ContextCompat.getDrawable(this,R.drawable.round),

ContextCompat.getDrawable(this,R.drawable.round));

#Decoding function parameters setBackground - leftbutton background, right button background

Note : By default, the background of the image button will be transparent. You can add lefttint and righttint for colours.

##Happy Coding!!

Let's get connected

License


Copyright (C) 2016 Hari Vignesh Jayapalan
 Copyright (C) 2011 Android Open Source Project
  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. 

Resources

Android developers should collect the following utils.

Generating reactiveX methods using annotations.

SimpleHttp is a library that will help you to make Http Restful in easy way for Android.

Android indoor map view.

Clickable ImageView that expands to full screen and is dismissible by swiping the image off-screen.

Memory efficient shimmering effect for views.

Topics


2D Engines   3D Engines   9-Patch   Action Bars   Activities   ADB   Advertisements   Analytics   Animations   ANR   AOP   API   APK   APT   Architecture   Audio   Autocomplete   Background Processing   Backward Compatibility   Badges   Bar Codes   Benchmarking   Bitmaps   Bluetooth   Blur Effects   Bread Crumbs   BRMS   Browser Extensions   Build Systems   Bundles   Buttons   Caching   Camera   Canvas   Cards   Carousels   Changelog   Checkboxes   Cloud Storages   Color Analysis   Color Pickers   Colors   Comet/Push   Compass Sensors   Conferences   Content Providers   Continuous Integration   Crash Reports   Credit Cards   Credits   CSV   Curl/Flip   Data Binding   Data Generators   Data Structures   Database   Database Browsers   Date &   Debugging   Decompilers   Deep Links   Dependency Injections   Design   Design Patterns   Dex   Dialogs   Distributed Computing   Distribution Platforms   Download Managers   Drawables   Emoji   Emulators   EPUB   Equalizers &   Event Buses   Exception Handling   Face Recognition   Feedback &   File System   File/Directory   Fingerprint   Floating Action   Fonts   Forms   Fragments   FRP   FSM   Functional Programming   Gamepads   Games   Geocaching   Gestures   GIF   Glow Pad   Gradle Plugins   Graphics   Grid Views   Highlighting   HTML   HTTP Mocking   Icons   IDE   IDE Plugins   Image Croppers   Image Loaders   Image Pickers   Image Processing   Image Views   Instrumentation   Intents   Job Schedulers   JSON   Keyboard   Kotlin   Layouts   Library Demos   List View   List Views   Localization   Location   Lock Patterns   Logcat   Logging   Mails   Maps   Markdown   Mathematics   Maven Plugins   MBaaS   Media   Menus   Messaging   MIME   Mobile Web   Native Image   Navigation   NDK   Networking   NFC   NoSQL   Number Pickers   OAuth   Object Mocking   OCR Engines   OpenGL   ORM   Other Pickers   Parallax List   Parcelables   Particle Systems   Password Inputs   PDF   Permissions   Physics Engines   Platforms   Plugin Frameworks   Preferences   Progress Indicators   ProGuard   Properties   Protocol Buffer   Pull To   Purchases   Push/Pull   QR Codes   Quick Return   Radio Buttons   Range Bars   Ratings   Recycler Views   Resources   REST   Ripple Effects   RSS   Screenshots   Scripting   Scroll Views   SDK   Search Inputs   Security   Sensors   Services   Showcase Views   Signatures   Sliding Panels   Snackbars   SOAP   Social Networks   Spannable   Spinners   Splash Screens   SSH   Static Analysis   Status Bars   Styling   SVG   System   Tags   Task Managers   TDD &   Template Engines   Testing   Testing Tools   Text Formatting   Text Views   Text Watchers   Text-to   Toasts   Toolkits For   Tools   Tooltips   Trainings   TV   Twitter   Updaters   USB   User Stories   Utils   Validation   Video   View Adapters   View Pagers   Views   Watch Face   Wearable Data   Wearables   Weather   Web Tools   Web Views   WebRTC   WebSockets   Wheel Widgets   Wi-Fi   Widgets   Windows   Wizards   XML   XMPP   YAML   ZIP Codes