Skip to content

Instantly share code, notes, and snippets.

@AlecKazakova
AlecKazakova / BriteDatabaseUtils.kt
Last active February 7, 2021 15:36
Extension functions on SQLBrite's BriteDatabase to make working with SQLDelight easier
fun BriteDatabase.createQuery(query: SqlDelightStatement) = createQuery(query.tables, query.statement, *query.args)
inline fun <T: SqlDelightCompiledStatement> BriteDatabase.bindAndExecute(compiledStatement: T, bind: T.() -> Unit): Long {
synchronized(compiledStatement) {
compiledStatement.bind()
return when (compiledStatement) {
is SqlDelightCompiledStatement.Insert -> {
executeInsert(compiledStatement.table, compiledStatement.program)
}
is SqlDelightCompiledStatement.Update -> {
private ObjectAnimator animateRegularProgress(int finalProgress) {
ObjectAnimator animation = ObjectAnimator.ofInt(regularProgressBar, PROPERTY_NAME, 0, finalProgress);
animation.setDuration(ANIM_PROGRESS);
animation.setInterpolator(new LinearInterpolator());
return animation;
}
private void animateTextProgress(float end, float total, ObjectAnimator barAnimationToCoupleTo) {
@homj
homj / DrawerIconDrawable.java
Last active April 6, 2017 10:11
This Drawable implements the "Drawer-Indicator to Arrow"-Animation as seen in several Material-Design-Apps; NOTE: Mind the updated constructors in Revision 5!
/*
* Copyright 2014 Johannes Homeier
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@chrisbanes
chrisbanes / SystemUiHelper.java
Last active March 2, 2024 18:57
SystemUiHelper
/*
* Copyright (C) 2014 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@Jogan
Jogan / FloatingActionButton.java
Last active December 4, 2023 12:48
Implementation of Android L's floating action button pattern. API 14+
package your_package;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
@staltz
staltz / introrx.md
Last active April 25, 2024 04:18
The introduction to Reactive Programming you've been missing
@JakeWharton
JakeWharton / Truss.java
Last active June 9, 2023 07:35
Extremely simple wrapper around SpannableStringBuilder to make the API more logical and less awful. Apache 2 licensed.
import android.text.SpannableStringBuilder;
import java.util.ArrayDeque;
import java.util.Deque;
import static android.text.Spanned.SPAN_INCLUSIVE_EXCLUSIVE;
/** A {@link SpannableStringBuilder} wrapper whose API doesn't make me want to stab my eyes out. */
public class Truss {
private final SpannableStringBuilder builder;
private final Deque<Span> stack;
@ficusk
ficusk / GsonRequest.java
Last active April 9, 2024 09:03
A Volley adapter for JSON requests that will be parsed into Java objects by Gson.
import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException;
import com.android.volley.AuthFailureError;
import com.android.volley.NetworkResponse;
import com.android.volley.ParseError;
import com.android.volley.Request;
import com.android.volley.Response;
import com.android.volley.Response.ErrorListener;
import com.android.volley.Response.Listener;
@DeltaWhy
DeltaWhy / gist:5432349
Created April 22, 2013 03:55
GTwifi configuration
CONNECTION='wireless'
DESCRIPTION=''
INTERFACE='wlp3s0'
SECURITY='wpa-configsection'
IP='dhcp'
CONFIGSECTION='
ssid="GTwifi"
key_mgmt=WPA-EAP
proto=RSN
eap=PEAP