-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
258 additions
and
44 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 41 additions & 9 deletions
50
ratingtrendlib/src/main/java/com/ritwik/ratingtrendlib/Rating.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,58 @@ | ||
package com.ritwik.ratingtrendlib; | ||
|
||
import android.content.Context; | ||
import android.graphics.Canvas; | ||
import android.graphics.Paint; | ||
import android.graphics.RectF; | ||
|
||
public class Rating { | ||
|
||
private int mValue; | ||
private int mStrokeColor; | ||
private int mFillColor; | ||
private Context mContext; | ||
private Paint mStrokePaint; | ||
private Paint mFillPaint; | ||
private float mCornerRadius; | ||
private RectF filledRect; | ||
private RectF strokeRect; | ||
|
||
public Rating(int value, float cornerRadius) { | ||
|
||
public Rating(int value) { | ||
this.mValue = value; | ||
this.mCornerRadius = cornerRadius; | ||
filledRect = new RectF(); | ||
strokeRect = new RectF(); | ||
|
||
} | ||
|
||
public void setmValue(int mValue) { | ||
this.mValue = mValue; | ||
} | ||
|
||
public void setmStrokePaint(Paint mStrokePaint) { | ||
this.mStrokePaint = mStrokePaint; | ||
} | ||
|
||
public void setmFillPaint(Paint mFillPaint) { | ||
this.mFillPaint = mFillPaint; | ||
} | ||
|
||
public int getmValue() { | ||
return mValue; | ||
} | ||
|
||
public Paint getmStrokePaint() { | ||
return mStrokePaint; | ||
} | ||
|
||
public Paint getmFillPaint() { | ||
return mFillPaint; | ||
} | ||
|
||
private int getAppropriateStrokeColor(int value){ | ||
int color = 0xff000000; | ||
switch (value){ | ||
public void drawSelf(float left, float top, float right, float bottom, Canvas canvas){ | ||
|
||
filledRect.set(left, top, right, bottom); | ||
strokeRect.set(left, top, right, bottom); | ||
canvas.drawRoundRect(filledRect, mCornerRadius, mCornerRadius, mFillPaint); | ||
canvas.drawRoundRect(strokeRect, mCornerRadius, mCornerRadius, mStrokePaint); | ||
|
||
} | ||
return color; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<vector xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:width="49.94dp" | ||
android:height="49.94dp" | ||
android:viewportWidth="49.94" | ||
android:viewportHeight="49.94"> | ||
<path | ||
android:fillColor="#FF000000" | ||
android:pathData="M48.856,22.73c0.983,-0.958 1.33,-2.364 0.906,-3.671c-0.425,-1.307 -1.532,-2.24 -2.892,-2.438l-12.092,-1.757c-0.515,-0.075 -0.96,-0.398 -1.19,-0.865L28.182,3.043c-0.607,-1.231 -1.839,-1.996 -3.212,-1.996c-1.372,0 -2.604,0.765 -3.211,1.996L16.352,14c-0.23,0.467 -0.676,0.79 -1.191,0.865L3.069,16.622c-1.359,0.197 -2.467,1.131 -2.892,2.438c-0.424,1.307 -0.077,2.713 0.906,3.671l8.749,8.528c0.373,0.364 0.544,0.888 0.456,1.4L8.224,44.701c-0.183,1.06 0.095,2.091 0.781,2.904c1.066,1.267 2.927,1.653 4.415,0.871l10.814,-5.686c0.452,-0.237 1.021,-0.235 1.472,0l10.815,5.686c0.526,0.277 1.087,0.417 1.666,0.417c1.057,0 2.059,-0.47 2.748,-1.288c0.687,-0.813 0.964,-1.846 0.781,-2.904l-2.065,-12.042c-0.088,-0.513 0.083,-1.036 0.456,-1.4L48.856,22.73z"/> | ||
</vector> |
Oops, something went wrong.