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
<!-- RED --> | |
<color name="red_50">#fde0dc</color> | |
<color name="red_100">#f9bdbb</color> | |
<color name="red_200">#f69988</color> | |
<color name="red_300">#f36c60</color> | |
<color name="red_400">#e84e40</color> | |
<color name="red_500">#e51c23</color> | |
<color name="red_600">#dd191d</color> | |
<color name="red_700">#d01716</color> | |
<color name="red_800">#c41411</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
Integer getVersionCode() { | |
def sout = new StringBuffer() | |
def proc = 'git rev-list HEAD --count'.execute() | |
proc.consumeProcessOutput(sout, new StringBuffer()) | |
proc.waitForOrKill(1000) | |
return sout.toInteger() | |
} |
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
public class App extends Application { | |
public void onCreate() { | |
super.onCreate(); | |
AsyncTask.execute(new Runnable() { | |
@Override | |
public void run() { | |
Glide.get(App.this).register(GlideUrl.class, InputStream.class, | |
new OkHttpUrlLoader.Factory(new OkHttpClient())); | |
} | |
}); |
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
[ERROR]: cannot generate view binders java.lang.NoClassDefFoundError: kotlin/jvm/internal/ExtensionFunctionImpl | |
at java.lang.ClassLoader.defineClass1(Native Method) | |
at java.lang.ClassLoader.defineClass(ClassLoader.java:760) | |
at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) | |
at java.net.URLClassLoader.defineClass(URLClassLoader.java:455) | |
at java.net.URLClassLoader.access$100(URLClassLoader.java:73) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:367) | |
at java.net.URLClassLoader$1.run(URLClassLoader.java:361) | |
at java.security.AccessController.doPrivileged(Native Method) | |
at java.net.URLClassLoader.findClass(URLClassLoader.java:360) |
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 String?.isEmpty() :Boolean = this == null || "".equals(this) | |
val a :String? = null | |
a.isEmpty() // true |
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
import android.app.Activity | |
import android.widget.Toast | |
import android.view.View | |
import kotlin.properties.Delegates | |
import android.app.Fragment | |
fun Activity.toast(s: CharSequence, length: Int = Toast.LENGTH_SHORT) = | |
Toast.makeText(this, s, length).show() | |
fun <T : View?>Activity.find(id: Int) = |
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() |
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
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
@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 { |
OlderNewer