Skip to content

Instantly share code, notes, and snippets.

View quentin7b's full-sized avatar
🌴
Aloha

Quentin Klein quentin7b

🌴
Aloha
View GitHub Profile
@quentin7b
quentin7b / android-checkstyle.xml
Created October 9, 2014 09:07
Custom Android Studio checkstyle.xml for Android
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Puppy Crawl//DTD Check Configuration 1.3//EN" "http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
<!--
Checkstyle-Configuration: Android Checks (Android Studio)
Description:
Slightly modified version of Sun Checks that better matches the default code formatter setting of Eclipse.
-->
<module name="Checker">
<property name="severity" value="warning"/>
@quentin7b
quentin7b / click_on_button.java
Last active May 21, 2021 11:16
Espresso recycler view item button click
onView(withId(R.id.recycler_view_id))
.perform(
RecyclerViewActions.actionOnItemAtPosition(
itemPosition,
new ViewAction() {
@Override
public Matcher<View> getConstraints() {
return null;
}
@quentin7b
quentin7b / drawer_open.java
Last active August 29, 2015 14:21
Robotium 5.3.1 (App compat API 21+) / Open navigation drawer
/**
* As we use app compat it seems Solo#setNavigationDrawer is not doing well (drawer does not open, but the button is clicked)
* Same result for clickOnView(getView(android.R.id.home))
*
* This code opens the navigation drawer on the main thread
* Be aware : you need to provide your DrawerLayout id (you can do it in params)
*/
public void openCompatNavigationDrawer() {
getInstrumentation().runOnMainSync(new Runnable() {
@Override
@quentin7b
quentin7b / Test_TestMyObject.java
Last active August 29, 2015 14:25
[Robolectric / Jacoco] Test Example
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.ErrorCollector;
import org.junit.runner.RunWith;
import org.robolectric.RobolectricGradleTestRunner;
import org.robolectric.annotation.Config;
import static org.hamcrest.CoreMatchers.equalTo;
import static org.hamcrest.CoreMatchers.not;
@quentin7b
quentin7b / Test_module_build.gradle
Last active August 29, 2015 14:25
[Robolectric / Jacoco] Test module build.gradle
apply plugin: 'jacoco'
android {
testOptions {
unitTests.returnDefaultValues = true
}
jacoco {
version "0.7.1.201405082137"
}
}
@quentin7b
quentin7b / Android_tests.gradle
Last active May 23, 2018 07:24
Android build.gradle adds
// Root build.gradle
allprojects {
repositories {
google()
jcenter()
maven { url 'https://jitpack.io' }
}
}
// Module build.gradle
@quentin7b
quentin7b / TheActivity.kt
Last active June 6, 2019 17:32
Android ViewModel use LiveData as an Event bus
class TheActivity : AppCompatActivity() {
private val theSharedViewModel by viewModel<TheSharedViewModel>()
override fun onCreate(savedInstanceState: Bundle?) {
// bla bla bla
theSharedViewModel.getEvent().observe(this, Observer {
Log.i("TheSharedEvent", "Event Triggered")
})
}
@quentin7b
quentin7b / index.html
Last active October 16, 2019 11:52
CAF_Receiver
<!doctype html>
<html>
<head>
<title>Estimate It</title>
<link href='https://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<style>
body {
background: white;
color: black;
@quentin7b
quentin7b / build.gradle
Last active October 15, 2019 16:04
CAF_Sender_build
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.github.quentin7b.estimateit"
@quentin7b
quentin7b / CastOptionsProvider.kt
Last active November 13, 2018 16:02
CAF_Sender_options
package com.github.quentin7b.estimateit
import android.content.Context
import com.google.android.gms.cast.framework.CastOptions
import com.google.android.gms.cast.framework.OptionsProvider
class CastOptionsProvider : OptionsProvider {
override fun getCastOptions(ctx: Context): CastOptions {
return CastOptions
.Builder()