Giter Site home page Giter Site logo

smileyrating's Introduction

Smiley Rating

SmileyRating is a simple rating bar for android. It displayes animated smileys as rating icon.

  • Drawn completely using android canvas
  • Inspired by Bill Labus

Demo

Integration

Integrating SmileyRating in your project is very simple.

Step 1:

Add this dependency in your project's build.gradle file which is in your app folder

compile 'com.github.sujithkanna:smileyrating:1.4'

add this to your dependencies.

Step 2:

Now place the SmileyRating in your layout.

Note: The height of the SmileyRating will be automatically adjusted according to the width of this component.
<com.hsalf.smilerating.SmileRating
        android:id="@+id/smile_rating"
        android:layout_width="match_parent"
        android:layout_height="wrap_content" />

Step 3:

Initialize your view

SmileRating smileRating = (SmileRating) findViewById(R.id.smile_rating);

Set this SmileySelectionListener to get notified when user selects a smiley

smileRating.setOnSmileySelectionListener(new SmileRating.OnSmileySelectionListener() {
            @Override
            public void onSmileySelected(int smiley) {
                switch (smiley) {
                    case SmileRating.BAD:
                        Log.i(TAG, "Bad");
                        break;
                    case SmileRating.GOOD:
                        Log.i(TAG, "Good");
                        break;
                    case SmileRating.GREAT:
                        Log.i(TAG, "Great");
                        break;
                    case SmileRating.OKAY:
                        Log.i(TAG, "Okay");
                        break;
                    case SmileRating.TERRIBLE:
                        Log.i(TAG, "Terrible");
                        break;
                }
            }
        });

If you want to know the level of user rating, You can listen for OnRatingSelectedListener

smileRating.setOnRatingSelectedListener(new SmileRating.OnRatingSelectedListener() {
            @Override
            public void onRatingSelected(int level) {
                // level is from 1 to 5
            }
        });

You can set selected smiley without user interaction

Without animation

smileRating.setSelectedSmile(BaseRating.GREAT);

OR

smileRating.setSelectedSmile(BaseRating.GREAT, false);

The smiley will be selected without any animation and the listeners won't be triggered

With animation

smileRating.setSelectedSmile(BaseRating.GREAT, true);

Smiley will be selected with animation and listeners will also be triggered(Only if the second param is true)

smileyrating's People

Contributors

sujithkanna avatar

Watchers

 avatar  avatar

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.