Skip to content

Instantly share code, notes, and snippets.

@JakeWharton
JakeWharton / gist:f50f3b4d87e57d8e96e9
Created February 7, 2015 01:59
Rise and Shine™, unlock and wake up your device automatically when you deploy from the IDE. Put this somewhere in your `src/debug/` code and run it when the application or main activity starts. Apache 2.
/**
* Show the activity over the lockscreen and wake up the device. If you launched the app manually
* both of these conditions are already true. If you deployed from the IDE, however, this will
* save you from hundreds of power button presses and pattern swiping per day!
*/
public static void riseAndShine(Activity activity) {
activity.getWindow().addFlags(FLAG_SHOW_WHEN_LOCKED);
PowerManager power = (PowerManager) activity.getSystemService(POWER_SERVICE);
PowerManager.WakeLock lock =
@nbarraille
nbarraille / OrientationChangeAction.java
Last active January 30, 2023 00:04
An Espresso ViewAction that changes the orientation of the screen
/*
* The MIT License (MIT)
*
* Copyright (c) 2015 - Nathan Barraille
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
@daverix
daverix / Testing.java
Last active December 30, 2017 11:38
Dagger2 sub components example
package com.example;
import javax.inject.Scope;
import javax.inject.Singleton;
import dagger.Component;
import dagger.Module;
import dagger.Provides;
import dagger.Subcomponent;
@MichaelRocks
MichaelRocks / MathExtensions.kt
Last active August 5, 2022 01:08
Math extension functions and float-math functions for Kotlin
/*
* Copyright 2015 Michael Rozumyanskiy
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@lenguyenthanh
lenguyenthanh / Dagger 2.md
Last active May 7, 2020 19:55
Dagger 2 configuration

Small gist shows how to config Dagger 2 to an Android project

library(reshape)
library(ggplot2)
id = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)
# Clean build, no Gradle daemon
java_clean_nodaemon = c(24.831, 26.247, 24.109, 23.338, 24.567, 25.349, 23.388, 24.930, 22.830, 25.635)
kotlin_clean_nodaemon = c(30.936, 33.065, 35.062, 31.953, 31.666, 33.907, 31.047, 31.104, 32.922, 32.150)
# Clean build, Gradle daemon running
;,_ ,
_uP~"b d"u,
dP' "b ,d" "o
d" , `b d"' "b
l] [ " `l, d" lb
Ol ? " "b`"=uoqo,_ "l
,dBb "b "b, `"~~TObup,_
,d" (db.`" "" "tbc,_ `~"Yuu,_
.d" l`T' '= ~ `""Yu,
@jayde-bog
jayde-bog / layout.xml
Created February 4, 2020 01:40
Android SwitchCompat custom style
<androidx.appcompat.widget.SwitchCompat
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:checked="false"
android:thumb="@drawable/more_switch_thumb"
app:track="@drawable/more_switch_track" />