Skip to content

Instantly share code, notes, and snippets.

@sababado
sababado / KotlinDslScratch.kt
Created May 11, 2022 17:37
Practice at creating a DSL in Kotlin.
import java.lang.IllegalStateException
// Tutorial and inspiration from https://www.baeldung.com/kotlin/dsl
@DslMarker
annotation class SqlDslMarker
@SqlDslMarker
abstract class Condition {
abstract fun addCondition(condition: Condition)
@sababado
sababado / Theming With Jetpack Compose.md
Created April 20, 2022 21:06
Blog Template for Theming with Jetpack Compose
@sababado
sababado / LoopingAnimatedVectorHandler.kt
Created September 14, 2018 12:41
Animated Vector Drawable for a vehicle, spinning wheels, and smoke.
package com.coxautoinc.vehiclekit.core
import android.content.Context
import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable
import android.support.annotation.DrawableRes
import android.support.graphics.drawable.Animatable2Compat
import android.support.graphics.drawable.AnimatedVectorDrawableCompat
/**
@sababado
sababado / back.xml
Last active September 5, 2018 17:34
Vector Drawable
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportHeight="24.0"
android:viewportWidth="24.0">
<path
android:name="long_leg"
android:fillColor="#FFFFFFFF"
android:pathData="M 20 11 L 5 11 L 5 13 L 20 13 Z" />
@sababado
sababado / attrs.xml
Created July 31, 2018 20:25
Custom Attributes in Themes
<?xml version="1.0" encoding="utf-8"?>
<resources>
<attr name="mp_toolbar_style" format="reference" />
<attr name="mp_header_style" format="reference" />
<attr name="mp_select_color" format="reference" />
</resources>
@sababado
sababado / styles.xml
Last active November 28, 2015 22:41
Make spinners show a bottom line and a down arrow easily.
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:spinnerStyle">@style/AppTheme.Form.Spinner</item>
<item name="android:spinnerItemStyle">@style/AppTheme.Form.Spinner.Item</item>
</style>
<!-- Spinner Styles -->
<style name="AppTheme.Form.Spinner" parent="Widget.AppCompat.Spinner">
<item name="android:paddingRight">0dp</item>
@sababado
sababado / SlidingTabLayout.java
Last active August 29, 2015 14:09
This is an adaptation of Google's version of the SlidingTabLayout. It allows for ViewPager implementing SlidingTabPagerAdapter to be set so that icons may be shown on tabs. The customization also provides an option to disable the drawing of the bottom underline and dividers.
import android.content.Context;
import android.graphics.Typeface;
import android.os.Build;
import android.support.v4.view.PagerAdapter;
import android.support.v4.view.ViewPager;
import android.util.AttributeSet;
import android.util.TypedValue;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
@sababado
sababado / FadePageTransformer.java
Last active June 16, 2021 16:35
An Android PageTransformer. Use it on a ViewPager (3.0+) to see the pages fade in and out on top of each other.
/*
* Copyright (C) 2014 Robert Szabo
*
* 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