Skip to content

Instantly share code, notes, and snippets.

View ZieIony's full-sized avatar

ZieIony

View GitHub Profile
@ZieIony
ZieIony / EditTextWithoutMenu.java
Last active October 4, 2015 20:52
EditText without Samsung's Gingerbread copy/paste menu
public class EditTextWithoutMenu extends EditText{
public EditTextWithoutMenu(Context context) {
this(context, null);
}
public EditTextWithoutMenu(Context context, AttributeSet attrs) {
this(context, attrs, R.attr.carbon_editTextStyle);
}
import java.util.ArrayList;
// https://code.sololearn.com/#java
class PrimeNumberChecker {
public static void main(String[] args) {
System.out.println(new PrimeNumberChecker().getPrimeNumbers(100));
}
/**
import java.util.Arrays
// https://code.sololearn.com/#kt
fun getPrimeNumbers(limit:Int) = (1..limit).filter{ isPrime(it) }.toIntArray()
private fun isPrime(number:Int) = (2 until number).none{ number%it==0 }
fun main(args:Array<String>) {
System.out.println(Arrays.toString(getPrimeNumbers(100)))
@ZieIony
ZieIony / TextMarker.java
Created March 9, 2016 16:17
Marker view useful when creating Material layouts with TextViews
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.view.View;
public class TextMarker extends View {
Paint paint;
import android.content.Context
import android.graphics.Bitmap
import android.support.v8.renderscript.Allocation
import android.support.v8.renderscript.Element
import android.support.v8.renderscript.RenderScript
import android.support.v8.renderscript.ScriptIntrinsicBlur
fun blur(context: Context, bitmap: Bitmap, radius: Float) {
val renderScript: RenderScript = RenderScript.create(context)
val blurShader: ScriptIntrinsicBlur = ScriptIntrinsicBlur.create(renderScript, Element.U8_4(renderScript))
@ZieIony
ZieIony / gist:c67ba4e9d803d6bb840e2cc9fd71a551
Last active November 27, 2018 13:59
useful git commands
git -c core.fileMode=false diff // ignore file mode change for this one command
git clean -i // remove unstaged files interactively
git rebase -i --root // rebase entire history interactively
@ZieIony
ZieIony / Card
Created December 31, 2018 14:56
Card with two vertical lines using Carbon
<?xml version="1.0" encoding="utf-8"?>
<carbon.widget.LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/carbon_white">
<carbon.widget.FrameLayout
android:layout_width="match_parent"
android:layout_height="160dp"
@ZieIony
ZieIony / CustomView.java
Last active September 25, 2019 10:41
Custom view styling cheat gist
// declare an attribute, a style and a styleable in attrs.xml
// use attribute only once? Declare and use in one line
// want to reuse android attribute? Use 'android:' namespace
// use prefixes for your attributes to avoid conflicts with other libraries
<resources>
// declaration
<attr name="carbon_rippleColor" format="reference|color"/>
// style reference for use in themes
public class TextView extends android.widget.TextView {
public TextView(Context context) {
super(context);
initTextView(null, android.R.attr.textViewStyle);
}
public TextView(Context context, String text) {
super(context);
initTextView(null, android.R.attr.textViewStyle);
setText(text);
}
open class RadioButton : TextView, Checkable {
@JvmOverloads
constructor(context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = android.R.attr.radioButtonStyle,
defStyleRes: Int = R.style.guide_RadioButton)
: super(context, attrs, defStyleAttr, defStyleRes) {
initRadioButton(attrs, defStyleAttr, defStyleRes)
}
fun initRadioButton(attrs: AttributeSet?, defStyleAttr: Int, defStyleRes: Int) {