Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@oradkovsky
oradkovsky / gist:421574ac813593baade5a82bad0bf07e
Created February 21, 2019 08:54
androiddriver setup and simple use case
public class BasicTests {
private static final String PACKAGE_NAME = "com.noname.pharma";
private AndroidDriver<AndroidElement> driver;
@Before
public void setup() throws Exception {
DesiredCapabilities capabilities = new DesiredCapabilities();
capabilities.setCapability("deviceName", "emulator-5554");
capabilities.setCapability("platformVersion", "7.1.1");
@oradkovsky
oradkovsky / gist:ed9924a0d007ed10be44d244becb862b
Last active April 16, 2021 06:23
Glide shadow transformation
/**
* Quick and hacky way, tested under SDK19 and newer.
* How to use (key: in conjunction with CircleCrop):
* <code>transform(new CircleCrop(), new CircleShadowTransformation())</code>
*/
public class CircleShadowTransformation extends BitmapTransformation {
private static final int SHADOW_RADIUS = 10;
private static final String ID = "a.b.c.transformations.CircleShadowTransformation";
private static final byte[] ID_BYTES = ID.getBytes(Charset.forName(STRING_CHARSET_NAME));
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<ruleset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" name="ruleset"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xsi:noNamespaceSchemaLocation="http://pmd.sf.net/ruleset_xml_schema.xsd"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<description>Android Rule Sets 1.0</description>
<exclude-pattern>.*/R.java</exclude-pattern>
//Firebase UI
implementation 'com.firebaseui:firebase-ui-auth:6.2.0'
//Google Auth
implementation group: 'com.google.api-client', name: 'google-api-client-android', version: '1.30.9'
//GMail api
implementation 'com.google.apis:google-api-services-gmail:v1-rev20200203-1.30.9'
if (FirebaseAuth.getInstance().currentUser == null) {
// user needs to authenticate
val providers = arrayListOf(
AuthUI.IdpConfig.GoogleBuilder().build()
)
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setAvailableProviders(providers)
val credential = GoogleAccountCredential.usingOAuth2(
applicationContext, listOf(GmailScopes.GMAIL_READONLY)
)
.setBackOff(ExponentialBackOff())
.setSelectedAccount(
Account(
FirebaseAuth.getInstance().currentUser?.email,
BuildConfig.APPLICATION_ID
)
)
// You may have guessed this is body of suspend function as I'm using Kotlin coroutines.
// Service is com.google.api.services.gmail.Gmail.
try {
val executeResult: ListMessagesResponse? =
withContext(Dispatchers.IO) {
service.users().messages()?.list("me")?.setQ("to:me")?.execute()
}
// For the sake of test, let's get 1st message on the list
def koin_version = '2.1.5'
implementation "org.koin:koin-androidx-viewmodel:$koin_version"
implementation "org.koin:koin-androidx-fragment:$koin_version"
implementation "org.koin:koin-androidx-scope:$koin_version"
//typically in a separate file
val appModule = module { }
//in a separate file as well
val viewModelsModule = module { }
//called in onCreate of your application class
startKoin {
androidLogger()
androidContext(applicationContext)
val appModule = module {
single<Gson> { GsonBuilder().setPrettyPrinting().create() }
}