Skip to content

Instantly share code, notes, and snippets.

@hector6872
hector6872 / StickySectionItemDecoration.kt
Last active March 22, 2019 09:54
StickySectionItemDecoration Kotlin
class StickySectionItemDecoration(
private val recyclerView: RecyclerView,
private val callback: Callback
) : RecyclerView.ItemDecoration() {
private var headerViewCache: View? = null
private var isInLayout = false
interface Callback {
fun isHeader(position: Int): Boolean
@hector6872
hector6872 / NoAnimationItemAnimator.kt
Created April 20, 2018 14:26
NoAnimationItemAnimator Kotlin Android RecyclerView
class NoAnimationItemAnimator : SimpleItemAnimator() {
override fun animateRemove(holder: RecyclerView.ViewHolder): Boolean {
dispatchRemoveFinished(holder)
return false
}
override fun animateAdd(holder: RecyclerView.ViewHolder): Boolean {
dispatchAddFinished(holder)
return false
}
@hector6872
hector6872 / MultiState.kt
Last active April 24, 2018 14:53
MultiStateFrameLayout Kotlin Android
enum class MultiState {
CONTENT,
EMPTY,
LOADING,
ERROR
}
@hector6872
hector6872 / AspectRatioCardView.kt
Created May 9, 2018 16:21
AspectRatioCardView Android - Kotlin
class AspectRatioCardView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : CardView(context, attrs, defStyleAttr) {
private var ratio = 1.0f
init {
attrs?.let {
@hector6872
hector6872 / gh2bb_migrate_cheapass.py
Created June 8, 2018 18:53
Migrate all your private github repos to bitbucket because you're CHEAP.
__author__ = 'schwa'
import os
import subprocess
import glob
from github import Github # pip install PyGithub
from bitbucket.bitbucket import Bitbucket # pip install --user bitbucket-api
GH_USERNAME = '[email protected]'
GH_PASSWORD = '1234'
#!/usr/bin/env python
#################
## CREDENTIALS ##
#################
GH_PERSONAL_ACCESS_TOKEN = ''
BB_USERNAME = ''
BB_APP_PASSWORD = ''
BB_OAUTH_KEY = ''
@hector6872
hector6872 / AutoMaxLinesTextView.kt
Last active August 13, 2018 09:10
AutoMaxLinesTextView for Android (Kotlin)
class AutoMaxLinesTextView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = android.R.attr.textViewStyle
) : AppCompatTextView(context, attrs, defStyleAttr) {
override fun onLayout(
changed: Boolean,
left: Int,
top: Int,
@hector6872
hector6872 / MarqueeAnimateView.kt
Last active August 17, 2018 15:16
MarqueeAnimateView for Android (Kotlin)
class MarqueeAnimateView @JvmOverloads constructor(
context: Context,
attrs: AttributeSet? = null,
defStyleAttr: Int = 0
) : View(context, attrs, defStyleAttr) {
companion object {
private const val STATE_START = 0
private const val STATE_STOP = 1
@hector6872
hector6872 / extract-strings-android.sh
Created September 11, 2018 15:51
extract-strings-android script
#!/bin/bash
if [ -z "$1" ]
then
path="."
else
path=$1
fi
for filename in $path"/strings"*.xml; do
@hector6872
hector6872 / CHANGELOG.md
Created October 16, 2018 15:24
CHANGELOG.md template

${project-name} Changelog

All notable changes to this project will be documented in this file.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

[Unreleased]

Changed

Added

Removed