Skip to content

Instantly share code, notes, and snippets.

View sebaslogen's full-sized avatar

Sebas LG sebaslogen

View GitHub Profile
Button(
modifier = Modifier.testTag("First Button"),
onClick = clickListener) {
Text("Push first destination")
}
android {
testOptions {
unitTests {
includeAndroidResources = true
}
}
}
dependencies {
testImplementation 'junit:junit:4.+'
@RunWith(AndroidJUnit4::class) // Update: back in 2022, this used to be @RunWith(RobolectricTestRunner::class)
class MyTests {
@get:Rule val composeTestRule = createComposeRule()
@Test fun `when I test, then it works`() {
// Some test code here
}
}
@sebaslogen
sebaslogen / MyAndroidApplication.kt
Created January 28, 2018 17:06
Finish all opened activities in my Android app (also across different tasks)
class MainApplication : Application() {
private val createdActivities = mutableListOf<WeakReference<Activity>>()
override fun onCreate() {
super.onCreate()
registerActivityLifecycleCallbacks(activityLifecycleCallbacks())
}
fun closeAllActivities() {
@Before
@Throws(Exception::class)
fun setUp() {
ShadowLog.stream = System.out // Redirect Logcat to console
}
@sebaslogen
sebaslogen / Picasso idlingresource.md
Last active April 27, 2021 22:54 — forked from Maragues/Picasso idlingresource.md
Implementation and usage of an IdlingResource that waits for Picasso actions to finish.

Note that the file lives in the package as Picasso (src/androidTest/java/com/squareup/picasso). Otherwise we don't have access to targetToAction

package com.squareup.picasso;

import android.app.Activity;
import android.os.Handler;
import android.support.test.espresso.IdlingResource;
import android.support.test.runner.lifecycle.ActivityLifecycleCallback;
import android.support.test.runner.lifecycle.Stage;
@sebaslogen
sebaslogen / MyCustomView.kt
Created March 3, 2018 10:34
Kotlin Android CustomView without default parameters
class MyCustomView : View {
constructor(context: Context) : super(context)
constructor(context: Context, attrs: AttributeSet?) : super(context, attrs)
constructor(context: Context, attrs: AttributeSet?, attributeSetId: Int) : super(context, attrs, attributeSetId)
}
@sebaslogen
sebaslogen / create-playlist-button.json
Last active January 27, 2020 13:02
Create playlist button from Server Driven UI JSON example for post
"button": {
"title": "Create your first playlist",
"action": {
"type": "command",
"url": "/command/endpoint?path=%2Fcommand%2Fcreate-playlist",
"prompt": {
"type": "textInput",
"message": "Give your playlist a name.",
"placeholder": "My first playlist",
"confirmButtonTitle": "Create"
@sebaslogen
sebaslogen / main.dart
Created January 12, 2020 22:00
Flutter Neumorphism
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
@sebaslogen
sebaslogen / main.dart
Created January 10, 2020 20:33
Flutter colored slider experiment
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
debugShowCheckedModeBanner: false,