• Stars
    star
    409
  • Rank 105,709 (Top 3 %)
  • Language
    Java
  • Created about 9 years ago
  • Updated about 7 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Inspired by stock android RatingBar. Simpler, has features that original lacks.

Android Arsenal

ProperRatingBar

Inspired by stock android RatingBar. Simpler, has features that original lacks.

What is this about

Whatever you need to display some rating or pricing category - just use ProperRatingBar so this:

<io.techery.properratingbar.ProperRatingBar
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:textSize="22sp"
        android:textStyle="bold"
        app:prb_defaultRating="4"
        app:prb_symbolicTick="$"
        app:prb_symbolicTickNormalColor="@android:color/darker_gray"
        app:prb_symbolicTickSelectedColor="@android:color/holo_green_dark"
        app:prb_totalTicks="5"
        />

becomes this:

Readme Screenshot 1

Example

See video below for possible usage scenarios.

Demo Gif

Motivation

Why bother and design our own element?

Well, stock Android RatingBar lacks some styling attributes that you would expect from it and sometimes offers unexpected behavior.

Besides that, we needed to use symbols like '$' as rating bar ticks in our project - none of third-patry libraries out there provides that functionality.

Installation

Library's minSdkVersion is set to 14.

We use jitpack, so you can obtain made-up library right from our github sources in your module's build.gradle file:

compile 'com.github.techery:properratingbar:{version_name}'

Also you need to add jitpack as repository in the same file:

repositories {
        // ...
        maven { url "https://jitpack.io" }
    }

API Reference

So far we only support customising via xml layout. Here is the list of applicable attributes:

  • prb_totalTicks: total number of ticks to show. Default is '5'

  • prb_defaultRating: use this to set rating from xml. Default is '3'

  • prb_clickable: if set to 'true' - use will be able to change rating by clicking. Default is 'false'

  • prb_symbolicTick: symbol to be used as a tick. Default is '$'

  • android:textSize: text size of symbolic tick. Default is '15sp'

  • android:textStyle: text style of symbolic tick. Possible: 'bold', 'italic', 'normal'. Default is 'normal'

  • prb_symbolicTickNormalColor: color of symbolic tick that is not selected (not rated). Default is '#FF000000' (black)

  • prb_symbolicTickSelectedColor: color of symbolic tick that is selected (rated). Default is '#FF888888' (gray)

  • prb_tickNormalDrawable: drawable resource to use as a tick that is not selected (not rated). No default value

  • prb_tickSelectedDrawable: drawable resource to use as a tick that is selected (rated). No default value

  • prb_tickSpacing: margin to be applied to tick drawables. Only applies to drawable-type ticks. Default is '1dp' (gray)

Also there's a number of methods to operate on ProperRatingBar programmatically:

public boolean isClickable();

/**
 * Nifty sugar method to just toggle clickable to opposite state.
 */
public void toggleClickable();

public void setClickable(boolean clickable);

/**
* Get the attached {@link RatingListener}
* @return listener or null if none was set
*/
@Nullable
public RatingListener getListener();

/**
* Set the {@link RatingListener} to be called when user taps rating bar's ticks
* @param listener listener to set
*/
public void setListener(RatingListener listener);

/**
* Remove listener
*/
public void removeRatingListener();

/**
* Get the current rating shown
* @return rating
*/
public int getRating();

/**
* Set the rating to show
* @param rating new rating value
*/
public void setRating(int rating);

Tests

No test coverage is supplied so far - might be added later.

Versions

Actual version can be found here

Be warned that given code is likely to be refactored and partly re-done (including possible API changes with no backward-compatibility).

Contribution

PR's are welcome. Just follow the general code style (both xml and java).

Proper code style setup might be added later and included to repository.

License

The MIT License (MIT)

Copyright (c) 2016 Techery (http://techery.io/)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

More Repositories

1

progresshint

ProgressBar/SeekBar delegate to show floating progress with style
Java
375
star
2

presenta

Easy MVP upon Mortar and Flow
Java
50
star
3

janet

Command-based architecture in reactive manner
Java
43
star
4

snapper

NoSQL fast-serializable storage with DataViews, Sorting, Filtering and more
Java
40
star
5

Naga

Simplified Java NIO asynchronous sockets
Java
31
star
6

FLUX

FLUX implementation in Objective-C
Objective-C
25
star
7

CellAdapter

Java
14
star
8

janet-http

REST service for Janet. Supports fully customizable requests, http-clients and converters
Java
13
star
9

WebRTC-iOS

C++
10
star
10

Oscar

Actors programming model framework for Objective-C
Objective-C
8
star
11

janet-async

Janet Service for Async server interaction, e.g. socket.io
Java
7
star
12

mappery

Simple kotlin/java mapping tool
Kotlin
7
star
13

janet-command

ActionService for Janet which delegates job execution back to command action
Java
7
star
14

janet-architecture-sample

Java
6
star
15

janet-analytics

Janet-powered analytics handling service
Java
5
star
16

janet-kotlin

Using Janet with Kotlin
Kotlin
5
star
17

flux-todo-app

FLUX example project
Objective-C
5
star
18

immutabler

Immutabler gem
Ruby
5
star
19

janet-ts

TypeScript
4
star
20

RxListAdapter

Easy to integrate RecyclerView's Adapter with Rx support
Java
4
star
21

janet-retrofit-converter

Small tool to generate janet-http actions using retrofit source file
Kotlin
3
star
22

OperationActionSubscriber

Java
3
star
23

Tesla

Command-based architecture in reactive swifty manner
Swift
2
star
24

vacancies

2
star
25

janet-sample-api-integration

Java
2
star
26

android-defaults

Common files for dev. environemnt
Java
2
star
27

hermet

Techery internal service for proxying third party services and stub them if needed.
TypeScript
2
star
28

TEArrayDiffCalculator

Objective-C
2
star
29

PonyDebuggerApp

OS X application for run/stop pony debugger server
Python
2
star
30

janet-http-android-sample

Sample app to show Janet + Http Service power for Android
Java
2
star
31

DroidBilling

Helper classes for working with android in-app purchase v3. Based on official Google code example
Java
2
star
32

janet-ts-http

JavaScript
1
star
33

janet-proxy

ActionService for Janet which delegates actions to another services
Java
1
star
34

dotfiles

ApacheConf
1
star
35

OscarSampleProject

Objective-C
1
star
36

BridgeCRM

Testing purpose repo with small login/reg (via parse) android application
Java
1
star
37

techery.github.io

Techery Engineering
HTML
1
star
38

code-review-checklists

Code review checklists
1
star
39

Frameworks-Embedding-Demo-app

Demo app with different approaches for dynamic frameworks embedding
Objective-C
1
star
40

JSCore

Objective-C
1
star
41

janet-converters

Set of popular object-to-bytes converters for Janet
Java
1
star
42

Swactors

Swactors
Perl
1
star
43

JenkinsPipelineTest

JavaScript
1
star
44

janet-flux-todo

Java
1
star
45

frontend-corner

Repository with code examples for presentations
Svelte
1
star
46

immutables-gson-adapters-provider

Annotation Processor to generate List of generated Gson's TypeAdapterFactory(s) for Immutables.org
Java
1
star
47

android-assignment

1
star