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
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 |
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
^(?!(NotificationManager|Timeline|SensorManager|Configs|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow)) |
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
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) | |
} |
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
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 | |
) |
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
^(?!(NotificationManager|Timeline|SensorManager|Configs|LayerSDK|libc-netbsd|art|stetho|Choreographer|CliptrayUtils|BubblePopupHelper|ViewRootImpl|libEGL|System.out|PhoneWindow)) |
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
@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 { |
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 colors | |
val colors = intArrayOf(RED, GREEN, BLUE) | |
// Modified colors | |
val colors = intArrayOf(0xFF0000, 0xFFFF00, 0xFF00FF, RED, BLUE, GREEN) |
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
val rainbowPaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { | |
style = Paint.Style.STROKE | |
strokeCap = Paint.Cap.ROUND | |
} |
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
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] |
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
new JsonBuilder<String, String>() | |
.put("$email", "mail@google.com") | |
.put("$username", "username") | |
.put("$name", "Name Name") | |
.build() |