Skip to content

Instantly share code, notes, and snippets.

@rharter
rharter / InjectableActivityTestRule.kt
Last active December 6, 2021 12:07
Test Rule that allows you to use Dagger Android's automatic lifecycle based injection without making your Application class `open`, or overriding it in tests.
package com.pixite.pigment.testing
import android.app.Activity
import android.app.Application
import android.content.Context
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.FragmentManager
@danybony
danybony / screenshot_android.sh
Last active June 30, 2021 12:05
Android screenshot to current dir
#!/bin/bash
while getopts y: flag
do
case "${flag}" in
y) size=${OPTARG};;
esac
done
DEVICES=`adb devices | grep -v devices | grep device | cut -f 1`
@nickbutcher
nickbutcher / LICENSE
Last active October 6, 2020 11:14
Fun with gradients and AnimatedVectorDrawables. Illustration by the wonderful https://twitter.com/VPoltrack
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@beesandbombs
beesandbombs / circleLines.pde
Created July 4, 2017 18:37
lines making circle
int[][] result;
float t, c;
float ease(float p) {
return 3*p*p - 2*p*p*p;
}
float ease(float p, float g) {
if (p < 0.5)
return 0.5 * pow(2*p, g);
@joshbuchea
joshbuchea / semantic-commit-messages.md
Last active April 8, 2025 15:04
Semantic Commit Messages

Semantic Commit Messages

See how a minor change to your commit message style can make you a better programmer.

Format: <type>(<scope>): <subject>

<scope> is optional

Example

String type = intentReader.getType();
if (type.equals("text/plain")){
CharSequence text = intentReader.getText();
textView.setText(text);
}
ShareCompat.IntentReader intentReader = ShareCompat.IntentReader.from(this);
if (intentReader.isShareIntent()) {
// ...
}
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:mimeType="text/plain" />
<data android:mimeType="text/html" />
<data android:mimeType="image/png" />
</intent-filter>
ShareCompat.IntentBuilder intentBuilder = ShareCompat.IntentBuilder.from(this);
Intent intent = intentBuilder
.setType("text/html")
.setText(text)
.setChooserTitle("Choose email client")
.createChooserIntent();
if (intent.resolveActivity(getPackageManager()) != null) {
startActivity(intent);
}