This file contains hidden or 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
<resources> | |
<declare-styleable name="SwagPoints"> | |
<attr name="points" format="integer" /> | |
<attr name="max" format="integer" /> | |
<attr name="min" format="integer"/> | |
<attr name="step" format="integer"/> | |
<attr name="indicatorIcon" format="reference" /> | |
<attr name="progressWidth" format="dimension" /> |
This file contains hidden or 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
public static Observable<String> getUserInfo(final Context context, | |
final String userId) { | |
return Observable.create(new ObservableOnSubscribe<String>() { | |
@Override | |
public void subscribe(ObservableEmitter<String> subscriber) throws Exception { | |
try { | |
HttpUrl url = new HttpUrl.Builder() | |
.scheme(SCHEME_HTTPS) | |
.host(API_HOST) | |
.addPathSegment(API_VERSION).addPathSegment(MODULE_NAME).addPathSegment(PATH_GET_USER_INFO) |
This file contains hidden or 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
private void init(Context context, AttributeSet attrs) { | |
float density = getResources().getDisplayMetrics().density; | |
// Defaults, may need to link this into theme settings | |
int arcColor = ContextCompat.getColor(context, R.color.color_arc); | |
int progressColor = ContextCompat.getColor(context, R.color.color_progress); | |
int textColor = ContextCompat.getColor(context, R.color.color_text); | |
mProgressWidth = (int) (mProgressWidth * density); | |
mArcWidth = (int) (mArcWidth * density); |
This file contains hidden or 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
@Override | |
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { | |
final int width = getDefaultSize(getSuggestedMinimumWidth(), widthMeasureSpec); | |
final int height = getDefaultSize(getSuggestedMinimumHeight(), heightMeasureSpec); | |
final int min = Math.min(width, height); | |
mTranslateX = (int) (width * 0.5f); | |
mTranslateY = (int) (height * 0.5f); |
This file contains hidden or 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
@Override | |
protected void onDraw(Canvas canvas) { | |
if (!mClockwise) { | |
canvas.scale(-1, 1, mArcRect.centerX(), mArcRect.centerY()); | |
} | |
// draw the text | |
String textPoint = String.valueOf(mPoints); | |
mTextPaint.getTextBounds(textPoint, 0, textPoint.length(), mTextRect); | |
// center the text |
This file contains hidden or 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
@Override | |
public boolean onTouchEvent(MotionEvent event) { | |
if (mEnabled) { | |
this.getParent().requestDisallowInterceptTouchEvent(true); | |
switch (event.getAction()) { | |
case MotionEvent.ACTION_DOWN: | |
if (mOnSwagPointsChangeListener != null) | |
mOnSwagPointsChangeListener.onStartTrackingTouch(this); | |
updateOnTouch(event); |
This file contains hidden or 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
private void init(Context context, AttributeSet attrs) { | |
// ... | |
mArcPaint = new Paint(); | |
mArcPaint.setColor(arcColor); | |
mArcPaint.setAntiAlias(true); | |
mArcPaint.setStyle(Paint.Style.STROKE); | |
mArcPaint.setStrokeWidth(mArcWidth); | |
mProgressPaint = new Paint(); |
This file contains hidden or 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
private double convertTouchEventPointToAngle(float xPos, float yPos) { | |
// transform touch coordinate into component coordinate | |
float x = xPos - mTranslateX; | |
float y = yPos - mTranslateY; | |
x = (mClockwise) ? x : -x; | |
double angle = Math.toDegrees(Math.atan2(y, x) + (Math.PI / 2)); | |
angle = (angle < 0) ? (angle + 360) : angle; | |
return angle; | |
} |
This file contains hidden or 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
# Add project specific ProGuard rules here. | |
# By default, the flags in this file are appended to flags specified | |
# You can edit the include path and order by changing the proguardFiles | |
# directive in build.gradle. | |
# | |
# For more details, see | |
# http://developer.android.com/guide/developing/tools/proguard.html | |
# Add any project specific keep options here: |
This file contains hidden or 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
#!/usr/bin/python3 | |
# -*- coding: utf8 -*- | |
import requests | |
from bs4 import BeautifulSoup | |
__author__ = "Engine Bai" | |
url = "https://medium.com/dualcores-studio/make-an-android-custom-view-publish-and-open-source-99a3d86df228" | |
req = requests.get(url) | |
html = BeautifulSoup(req.text, "html.parser") |