View script.sh
#!/usr/bin/env bash | |
# I've found that the "Migrate to AndroidX" converter in Android Studio doesn't work very | |
# well, so I wrote my own script to do the simple job of converting package names. | |
# | |
# You can download a CSV of package names here: https://developer.android.com/topic/libraries/support-library/downloads/androidx-class-mapping.csv | |
# | |
# It'll run faster on a clean build because then there are fewer files to scan over. | |
# | |
# Uses `gsed` because I'm on a Mac. Can easily replace with `sed` if you don't have `gsed`. |
View thing.kt
@Test | |
fun verifySerializedNameMatchesJsonName() { | |
// Reflections library | |
Reflections("com.foobar").getTypesAnnotatedWith(JsonClass::class.java) | |
.flatMap { clz -> | |
// FieldUtils is in Apache Commons | |
FieldUtils.getAllFieldsList(clz).filter { !Modifier.isStatic(it.modifiers) } | |
} | |
.forEach { field -> | |
val serializedNameAnnotation = field.declaredAnnotations.find { it is SerializedName } as? SerializedName |
View themes-debug.xml
<!-- You can change the parent around to whatever you normally use --> | |
<style name="DebugColors" parent="Theme.AppCompat"> | |
<!-- System colors --> | |
<item name="android:windowBackground">@color/__debugWindowBackground</item> | |
<item name="android:colorPressedHighlight">#FF4400</item> | |
<item name="android:colorLongPressedHighlight">#FF0044</item> | |
<item name="android:colorFocusedHighlight">#44FF00</item> | |
<item name="android:colorActivatedHighlight">#00FF44</item> |
View build.gradle
// Follow the five numbered instructions for setting up Crashlytics | |
buildscript { | |
repositories { | |
maven { url 'http://repo1.maven.org/maven2' } | |
// 1. Add the Crashlytics Maven repository to your build script. | |
maven { url 'http://download.crashlytics.com/maven' } | |
} | |
dependencies { |
View keybase.md
Keybase proof
I hereby claim:
- I am dlew on github.
- I am danlew (https://keybase.io/danlew) on keybase.
- I have a public key ASD8v3oTeKIyAZP1WwjzP1Wxej0F_V6CqXZOdQ9A61iewAo
To claim this, I am signing this object:
View gist:3100299
@SuppressWarnings("unchecked") | |
public static <T extends View> T findView(Activity activity, int id) { | |
return (T) activity.findViewById(id); | |
} | |
@SuppressWarnings("unchecked") | |
public static <T extends View> T findView(View view, int id) { | |
return (T) view.findViewById(id); | |
} |
View gist:6554307
public class LazyListManagerUtils { | |
public static <T> List<T> add(List<T> list, T item) { | |
if (list == null) { | |
list = new ArrayList<T>(); | |
list.add(item); | |
} | |
else if (!list.contains(item)) { | |
list.add(item); | |
} |
View RxActivityLifecycleCallbacks.java
package rx.android.lifecycle; | |
import android.app.Activity; | |
import android.app.Application; | |
import android.content.Context; | |
import android.os.Bundle; | |
import rx.Observable; | |
import rx.subjects.BehaviorSubject; | |
import java.util.Map; |
View gist:3fee09af5ff946997551
if (project.android.hasProperty('libraryVariants')) { | |
android.libraryVariants.all { variant -> | |
Task javadocTask = task("generate${variant.name.capitalize()}Javadoc", type: Javadoc) { | |
group = 'artifact' | |
description "Generates Javadoc for $variant.name" | |
// Source files from the variant | |
source = variant.javaCompiler.source | |
// Classpath from the variant + android.jar |
NewerOlder