Skip to content

Instantly share code, notes, and snippets.

@Sefford
Sefford / ExampleRendererFactory.kt
Last active January 5, 2020 12:34
Example of how my renderers work
class RecyclerRendererAdapter : RecyclerView.Adapter() {
val factory : RendererFactory
/*...*/
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
return factory.getRenderer(viewType,
...,
getInflater(parent.context).inflate(viewType, parent, false)) as RecyclerView.ViewHolder
}
}
### Download Vysor App
https://play.google.com/store/apps/details?id=com.koushikdutta.vysor
- Execute Vysor on Phone
- Enable ADB Settings (Open Developer Options -> Back)
- Enable ADB Debugging
### Download ADB drivers & Install
https://adb.clockworkmod.com/
<!-- For XML -->
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:elevation="@dimen/elevation_level_3">
<!-- Elevation is ignored in XMLs pre-Lollipop, but remember
that in those versions, to preserve Z-axis order in
layouts, Android handles it on a strict top-bottom
ordering (the lower, the higher) -->
@Sefford
Sefford / export.sh
Last active September 3, 2015 16:10
Bash Script for using Inkscape to convert from vectorial to PNG
#!/bin/sh
#Usage: export.sh <name of file> <width> <height>
mkdir -p drawable-mdpi
mkdir -p drawable-hdpi
mkdir -p drawable-xhdpi
mkdir -p drawable-xxhdpi
mkdir -p drawable-xxxhdpi
inkscape $1 --export-png=./drawable-mdpi/${1%.*}.png -w$2 -h$3 --export-area-page
import com.google.android.*;
import com.anderwebs.Ander;
import com.warthon.Jake;
public class App extends AnderApp {
public void onCreate(Bundle bundle) {
Anderwebs.noHacks()
.runAtFps(60)
.noHexagonal()
@Sefford
Sefford / Debouncer
Last active August 29, 2015 14:14
Debouncer class will allow to avoid fast clicking into views
import android.support.v4.util.LongSparseArray;
import javax.inject.Inject;
/**
* Debouncer class will allow to avoid fast clicking into views
*
* @author Saul Diaz
*/
public class Debouncer {
@Sefford
Sefford / CreditCardWatcher
Created January 27, 2015 11:15
Credit Card Watcher
package com.feverup.fever.ui.textwatchers;
/**
* Created by sefford on 14/02/14.
*/
import android.text.Editable;
import android.text.TextUtils;
import android.text.TextWatcher;
@Sefford
Sefford / Select Tabs
Created December 18, 2014 11:54
Helper method to gradually crossfade two tabs
void selectTab(Float scroll, int direction) {
float localOffset = scroll - scroll.intValue();
int intValue = scroll.intValue();
switch (direction) {
case 1:
views[intValue].setTextColor((int) argbEvaluator.evaluate(localOffset, selectedColor, unselectedColor));
if (intValue + 1 <= views.length - 1) {
views[intValue + 1].setTextColor((int) argbEvaluator.evaluate(localOffset, unselectedColor, selectedColor));
}
@Sefford
Sefford / ScrollAwareListView
Created August 28, 2014 15:41
ListView that knows how much has been scrolled downwards
public class ScrollAwareListView extends ListView {
/**
* Vertical offset listener
*/
OnVerticalScrollOffsetListener offsetListener;
/**
* Maximum vertical size
*/
int verticalRange = 0;
@Sefford
Sefford / Switching
Created July 25, 2014 14:06
This method will switch minSDKVersion of RecyclerLibrary on compile time for version 13
applicationVariants.all{ variant ->
// This is a terrible hacky way of compile-time changing all the libraries
// minSDKs to SDK 13. This script has to be mantained everytime you update
// any of these libraries or the plugin updates.
variant.processManifest.doFirst {
File manifestFile = file("${buildDir}/intermediates/exploded-aar/com.android.support/recyclerview-v7/21.0.0-rc1/AndroidManifest.xml")
if (manifestFile.exists()) {
println("Replacing minSdkVersion of RecyclerView-V7 library")
String content = manifestFile.getText('UTF-8')
content = content.replaceAll(/minSdkVersion="L"/, 'minSdkVersion=\"13\"')