Skip to content

Instantly share code, notes, and snippets.

View jt-gilkeson's full-sized avatar
:octocat:

J.T. Gilkeson jt-gilkeson

:octocat:
View GitHub Profile
/*
* Based on https://gist.github.com/jamiesanson/d1a3ed0910cd605e928572ce245bafc4
*
* Refactored to use the preferred `DefaultLifecycleObserver` which does not rely on the annotation processor.
* See https://developer.android.com/reference/kotlin/androidx/lifecycle/Lifecycle#init
*
* Usage:
* `private var binding: TheViewBinding by viewLifecycle()`
*/
GsonBuilder().registerTypeAdapterFactory(NullStringToEmptyAdapterFactory())
.create()
.run {
return fromJson(this@toObject, T::class.java)
}
class NullStringToEmptyAdapterFactory : TypeAdapterFactory {
override fun <T> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? {
if (type.rawType != String::class.java) {
@yossorion
yossorion / what-i-wish-id-known-about-equity-before-joining-a-unicorn.md
Last active April 7, 2024 22:55
What I Wish I'd Known About Equity Before Joining A Unicorn

What I Wish I'd Known About Equity Before Joining A Unicorn

Disclaimer: This piece is written anonymously. The names of a few particular companies are mentioned, but as common examples only.

This is a short write-up on things that I wish I'd known and considered before joining a private company (aka startup, aka unicorn in some cases). I'm not trying to make the case that you should never join a private company, but the power imbalance between founder and employee is extreme, and that potential candidates would

@sebaslogen
sebaslogen / Project_Default.xml
Last active October 3, 2016 09:50
Autocorrect suggestion: Escape apostrophes in Android string XMLs (file should be inside .idea/inspectionProfiles/)
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="AndroidLintDrawAllocation" enabled="true" level="ERROR" enabled_by_default="true" />
<inspection_tool class="SSBasedInspection" enabled="true" level="ERROR" enabled_by_default="true">
<replaceConfiguration name="Escape apostrophes in Android string XMLs" text="&lt;string $attributes$&gt;$text$&lt;/string&gt;" recursive="false" caseInsensitive="true" type="XML" reformatAccordingToStyle="true" shortenFQN="true" useStaticImport="true" replacement="&lt;string $attributes$&gt;$fixedText$&lt;/string&gt;">
<constraint name="attributes" minCount="0" maxCount="2147483647" within="" contains="" />
<constraint name="text" regexp=".*[^\\]'.*" maxCount="2147483647" within="" contains="" />
<variableDefinition name="fixedText" script="&quot;text.getValue().replaceAll( &quot;\\\\'|\'&quot;, &quot;\\\\'&quot; )&quot;" />
</replace
@lopspower
lopspower / README.md
Last active May 3, 2024 13:26
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@lopspower
lopspower / README.md
Last active May 11, 2022 02:47
Android Tools Attributes

Android Tools Attributes

Twitter

Android has a dedicated XML namespace intended for tools to be able to record information in XML files, and have that information stripped when the application is packaged such that there is no runtime or download size penalty. The namespace URI is http://schemas.android.com/tools and is usually bound to the tools: prefix:

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
 android:layout_width="match_parent"
@lopspower
lopspower / README.md
Last active January 20, 2024 09:18
Publish AAR to jCenter and Maven Central

Publish AAR to jCenter and Maven Central

Twitter

EDIT: You can find this same updated tutorial here -> Medium

Now I'm going to list how to publish an Android libray to jCenter and then syncronize it with Maven Central:

  1. I use "Android Studio" and I have this simple android lib that I would like to be available on maven: CircularImageView
@morgotth
morgotth / FooAdapter.java
Last active October 26, 2019 14:12
Recycled Pager Adapter inspired by RecyclerView
package com.example;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import com.example.Foo;
import com.example.RecycledPagerAdapter;
public class FooAdapter extends RecycledPagerAdapter<FooViewHolder> {
@CedricGatay
CedricGatay / strip_play_services.gradle
Last active August 29, 2015 14:09 — forked from dmarcato/strip_play_services.gradle
Keep track of previous run to prevent restripping if nothing has changed
// adapted from https://gist.github.com/dmarcato/d7c91b94214acd936e42
def toCamelCase(String string) {
String result = ""
string.findAll("[^\\W]+") { String word ->
result += word.capitalize()
}
return result
}
@iainconnor
iainconnor / Android Studio .gitignore
Created January 24, 2014 20:20
A .gitignore for use in Android Studio
# Built application files
/*/build/
# Crashlytics configuations
com_crashlytics_export_strings.xml
# Local configuration file (sdk path, etc)
local.properties
# Gradle generated files