Skip to content

Instantly share code, notes, and snippets.

View stepango's full-sized avatar
👁️
Making devs happier with Bazel

Stepan Goncharov stepango

👁️
Making devs happier with Bazel
View GitHub Profile
@stepango
stepango / final.java
Created June 18, 2016 05:53 — forked from Diolor/final.java
Final example
private final PublishSubject<Void> viewClickedSubject = PublishSubject.create();
private final CompositeSubscription startStopCompositeSubscription = new CompositeSubscription();
@Override
protected void onStart() {
super.onStart();
view.setOnClickListener(v-> viewClickedSubject.onNext(null));
Subscription subscription = viewClickedSubject
@stepango
stepango / filter.regexp
Created June 12, 2016 02:40
Filter for logcat
^(?!(NotificationManager|Timeline|SensorManager|Configs|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow))
override fun onDraw(canvas: Canvas?) {
paint.setShadowLayer(8f, 0f, 0f, currentTextColor)
super.onDraw(canvas)
canvas?.drawRect(0f, 0f, measuredWidth.toFloat(), measuredHeight.toFloat(), shaderPaint)
paint.clearShadowLayer()
super.onDraw(canvas)
}
@stepango
stepango / RainbowText.kt
Created June 9, 2016 13:22
Drawing text with gradient
override fun onMeasure(widthMeasureSpec: Int, heightMeasureSpec: Int) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec)
val height = measuredHeight.toFloat()
val width = measuredWidth.toFloat()
val shader = LinearGradient(
0f, 0f, width, height,
intArrayOf(Color.RED, Color.BLUE, Color.GREEN),
null,
Shader.TileMode.CLAMP
)
^(?!(NotificationManager|Timeline|SensorManager|Configs|LayerSDK|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow))
@SuppressWarnings("MagicNumber")
class ColorPicker @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
val colors = intArrayOf(RED, GREEN, BLUE)
val strokeSize = 2 * context.resources.displayMetrics.density
val rainbowPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
@stepango
stepango / colors.kt
Last active May 25, 2016 13:51
Color array init
// Original colors
val colors = intArrayOf(RED, GREEN, BLUE)
// Modified colors
val colors = intArrayOf(0xFF0000, 0xFFFF00, 0xFF00FF, RED, BLUE, GREEN)
@stepango
stepango / rainbow.kt
Created May 24, 2016 14:38
kotlin apply example
val rainbowPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply {
style = Paint.Style.STROKE
strokeCap = Paint.Cap.ROUND
}
@stepango
stepango / colors.kt
Last active May 29, 2016 04:44
Gradient color utils
fun interpColor(@FloatRange(from = 0.0, to = 1.0) unit: Float, colors: IntArray): Int {
if (unit <= 0) return colors[0]
if (unit >= 1) return colors[colors.size - 1]
var p = unit * (colors.size - 1)
val i = p.toInt()
// take fractional part
p -= i
val c0 = colors[i]
new JsonBuilder<String, String>()
.put("$email", "mail@google.com")
.put("$username", "username")
.put("$name", "Name Name")
.build()