StarBar


Source link: https://github.com/badoo/StarBar

StarBar

A custom View class implementing a rating bar with 10 stars. The user can touch or swipe to select a rating between 1 and 10. The StarBar supports three rating ranges (red, yellow and green) that are indicated by different colored stars.

Usage

For a working example of how to use StarBar see the Android project in the sample folder.

1. Including the StarBar library project

StarBar is provided as an Android library project. See the Android developer website for information on how include and use library projects.

Referencing a Library Project

**2. Add StarBar to your layout**


 <com.badoo.starbar.StarBar

android:id="@+id/starBar"

android:layout_width="fill_parent"

android:layout_height="wrap_content"

android:layout_alignParentBottom="true" />  </RelativeLayout> 

There are some restrictions on what you can specify for layout_width and layout_height.

  • layout_width must either be match_parent / fill_parent or fixed width.
  • layout_height must be wrap_content.

**3. Configuring rating ranges**

StarBar has three rating ranges. These ranges control what colour should be used when the rating stars are drawn. By default the following ranges are used:

  • 1-3: Red
  • 4-6: Yellow
  • 7-10: Green

If you want to override these are use different ranges it can be done by calling the following method in RatingBar.

public void setRanges(int yellow, int green) 

Example: To set the ranges to the defaults listed above use:

starBar.setRanges(4, 7);
 

**4. Setting a listener to handle rating callbacks**

After adding the StarBar to your layout it should already work but it will not do anything when the user picks a rating.

StarBar starBar = (StarBar) findViewById(R.id.starBar);
 starBar.setOnRatingSliderChangeListener(new OnRatingSliderChangeListener() {

@Override
  public boolean onStartRating() {

// The user has initiated a rating by touching the StarBar. This call will

// immediately followed by a call to onPendingRating with the initial rating

// value.

  
}

@Override
  public void onPendingRating(int rating) {

// This method will first be called when the user initiates a rating and then

// subsequently as the rating is updated (by the user swiping his finger along

 // the bar).
  
}

@Override
  public void onFinalRating(int rating, boolean swipe) {

// If the rating is completed successfully onFinalRating is called with the

// final result. The swipe parameter specifies if the rating was done using

// a tap (false) or a swipe (true).
  
}

@Override
  public void onCancelRating() {

// Called if the user cancels the rating by swiping away from the StarBar and releasing.
  
}
 
}
);
 

Credits

StarBar is is brought to you by Badoo Trading Limited and it is released under the MIT License.

Created by Erik Andre

Resources

Put some bubble in your tabs and give your apps a supa fresh style!

Simple yet powerful skeleton animation for all view in android.

CursorMock is a library for Android that helps testing SQLite related code without need to create testing databases, managing database connections, etc in/for testing environment. CursorMock gives ability to build a Cursor in a fast and reliable way from manually provided values or from data objects.

CookieBar is a lightweight library for showing a brief message at the top or bottom of the screen.

A RxJava library to fetch search suggestions backed by Google Suggest.

Its a library to add customer-support module to any android app. Its fully built on firebase and easy to integrate. It also has inbuilt admin section to monitor and resolve tickets raised.

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