Code Monkey home page Code Monkey logo

ratingview's Introduction

RatingView

Android Arsenal

Simple android widget that can replace standard inconvenient RatingBar in your app.

Screenshot ##Description The default Android RatingBar widget hardly can satisfy developers' needs. It's a pain to customize it at all. This simple view can take a huge advantage of setting and scaling drawables for rating view easily. ##Usage You can download this library with the following line in your app module build.gradle:

compile 'com.github.ornolfr:rating-view:0.1.2@aar'

##Example Declare RatingView in your XML with app attributes:

<com.github.ornolfr.ratingview.RatingView
	android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    app:drawable_empty="@drawable/ic_star_empty"
    app:drawable_filled="@drawable/ic_star_filled"
    app:drawable_half="@drawable/ic_star_half"
    app:drawable_margin="4dp"
    app:drawable_size="24dp"
    app:is_indicator="false"
    app:max_count="5"
    app:rating="3.5" />

And use it through RatingView instance in your code. Goog luck!

ratingview's People

Contributors

ornolfr 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

Watchers

 avatar  avatar  avatar

ratingview's Issues

RatingView width = "wrap_content"

Hey, I know in your example you used 'wrap_content' as the width of the RatingView but I think you might want to state that in your description/wiki as well as without that, the view will behave erratic. I spent almost two hours sorting out why events were not fired correctly until I realised that I assigned a specific width to the view. This might save others using the library. You can go ahead and close this issue or assign a label to it. Thanks for the amazingness.

RatingView does not save state on view recreation

First of all thanks for this great widget because default RatingBar widget really sucks. This one is a good replacement. There's one issue, though. If you change rating and rotate the screen then RatingView is recreated but previously set rating is not reset. It resets to default. I have code that solves this problem. Consider adding it to the RatingView class.

@Override
protected Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();
    SavedState savedState = new SavedState(superState);
    savedState.mRating = mRating;
    return savedState;
}

@Override
protected void onRestoreInstanceState(Parcelable state) {
    if (state instanceof SavedState) {
        SavedState savedState = (SavedState) state;
        super.onRestoreInstanceState(savedState.getSuperState());
        mRating = savedState.mRating;
    } else {
        super.onRestoreInstanceState(state);
    }
}

static class SavedState extends BaseSavedState {

    float mRating;

    SavedState(Parcelable superState) {
        super(superState);
    }

    private SavedState(Parcel in) {
        super(in);
        this.mRating = in.readFloat();
    }

    @Override
    public void writeToParcel(Parcel out, int flags) {
        super.writeToParcel(out, flags);
        out.writeFloat(this.mRating);
    }

    public static final Parcelable.Creator<SavedState> CREATOR = new Parcelable.Creator<SavedState>() {
                public SavedState createFromParcel(Parcel in) {
                    return new SavedState(in);
                }

                public SavedState[] newArray(int size) {
                    return new SavedState[size];
                }
            };
}

Step Size not provided

Hi,
Very good stuff, it really helps my need.
But the only problem is when my is_indicator is false i can increase the rating by one star only, and not even by half star.

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.