Skip to content

Instantly share code, notes, and snippets.

View RicardoBelchior's full-sized avatar
🏠
Working for Dice.fm

Ricardo Belchior RicardoBelchior

🏠
Working for Dice.fm
View GitHub Profile
@RicardoBelchior
RicardoBelchior / ScreenshotsAutomator.java
Last active February 25, 2020 18:39
ScreenshotsAutomator sample
@RunWith(AndroidJUnit4.class)
public class ScreenshotsAutomator {
@BeforeClass
public static void setUpOnce() {
EspressoTestSetup.injectScreenshotsData(...);
// Tell AndroidX to process each screenshot with our 'processor'
// See https://github.com/android/android-test/blob/master/runner/android_junit_runner/java/androidx/test/runner/screenshot/BasicScreenCaptureProcessor.java
Screenshot.setScreenshotProcessors(
@RicardoBelchior
RicardoBelchior / FragmentTestWithAndroidX.kt
Last active March 13, 2019 19:08
Fragment test example, using AndroidX
private lateinit var scenario: FragmentScenario<SearchFragment>
private val parentActivity = mock<SearchFragment.ParentActivity>()
@Before
fun setUp() {
// Prepare fake data for SearchFragment
// ...
// Setup the FragmentScenario and attach any required mock data to it
scenario = launchFragmentInContainer<SearchFragment>(Bundle.EMPTY, R.style.Theme_AppCompat_Light)
@RicardoBelchior
RicardoBelchior / FragmentTestWithRobolectric.kt
Last active March 13, 2019 18:20
Fragment test example, using Robolectric
private lateinit var activity: MyActivity
@Before
fun setUp() {
// Prepare fake data for MyActivity and MyFragment
// ...
// Open the activity that contains the Fragment under test
activity = Robolectric.setupActivity(MyActivity::class.java)
@RicardoBelchior
RicardoBelchior / MyActivity.java
Created June 29, 2018 08:18
PublisherAdView sample
/*
* Copyright (C) 2013 Google, Inc.
*
* 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
07-25 16:50:56.807 1715-8736/com.mirror.account.sample D/GigyaRequest: sendRequest[comments.getComments]:
{
"UID": "_guid_L-E_Ea7bHymrSJwNpVuJrvlfXMrhd6rivj2_s4uUS30=",
"categoryID": "News",
"includeStreamInfo": true,
"includeUserOptions": true,
"start": "",
"streamID": "mirror-10663290",
"threadDepth": 5,
"threadLimit": 5
07-25 16:49:49.607 1715-1086/com.mirror.account.sample D/GigyaRequest: sendRequest[comments.vote]:
{
"UID": "_guid_L-E_Ea7bHymrSJwNpVuJrvlfXMrhd6rivj2_s4uUS30=",
"categoryID": "News",
"commentID": "85c4d352f6014ce2bd20deab234de6db",
"streamID": "mirror-10663290",
"vote": "pos"
}
07-25 16:49:50.131 1715-1715/com.mirror.account.sample D/GigyaRequest: sendRequest[comments.vote]: errorCode:0
07-25 16:47:31.812 1715-4811/com.mirror.account.sample D/GigyaRequest: sendRequest[comments.getComments]:
{
"UID": "_guid_L-E_Ea7bHymrSJwNpVuJrvlfXMrhd6rivj2_s4uUS30=",
"categoryID": "News",
"includeStreamInfo": true,
"includeUserOptions": true,
"start": "",
"streamID": "mirror-10663290",
"threadDepth": 5,
"threadLimit": 5
@RicardoBelchior
RicardoBelchior / svg-to-android.sh
Last active December 8, 2017 21:32 — forked from deepankarb/svg-to-android.sh
A script to generate android assets from a SVG file. Requires inkscape to resize and convert.
#!/bin/bash
USAGE="Usage is: ./svg-to-android.sh <svg_file> <exported_png_name> <width_dp> <height_dp> [resources_dir] \n \
If 'resources_dir' is ommited, a new folder is created in the current directory, named after the svg name.\n \
Param 'exported_png_name' does not need extension.\n \
On Mac OS specify full path for svg file and resources directory.\n \
Exiting."
if [[ -z "$1" ]];
then
package com.ryanharter.android.util;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Keeps track of the number of app launches, and days since first launch, and
* provides an easy way to determine whether you should show a rating prompt
* or not.
*/