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

Customizable Timeline View for Android, Create a simple timeline list with few lines of code. You can adjust the image, image size, line color and line size.

This Project contains source code of Weather Android Application, designed similar to Yahoo Weather App, Based on World Weather Online.

Meet detekt, a static code analysis tool for the Kotlin programming language. It operates on the abstract syntax tree provided by the Kotlin compiler.

Espresso is a great tool to test our Android apps via instrumental tests. With them, we can mimic user actions like clicking a button, scrolling a list, selecting an item on a spinner or swiping on a pager. Then, we can assert that a text appears in the screen, an image is visible or invisible, or a button is enabled or not.

On the other hand, if you tried Espresso, you’ll agree that its API is not discoverable.

Barista introduces a discoverable API for the Espresso features. So, you and all the Android team will write instrumental tests with no effort.

Library uses SYSTEM_ALERT_WINDOW to show a build number and name over the top of apps.

Show image as a popup on a click event or any event. Simply set the image as drawable and thats it! And also you can set width, height & background color as you want.

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