Skip to content

Instantly share code, notes, and snippets.

View antoniolg's full-sized avatar

Antonio Leiva antoniolg

View GitHub Profile
antoniolg / PeopleDb.kt
Created July 7, 2020 11:14
Room basic sample in Kotlin
entities = [Person::class],
version = 1
abstract class PeopleDb : RoomDatabase() {
abstract fun personDao(): PersonDao
antoniolg / MainActivity.kt
Last active March 2, 2023 08:10
Shows how to use permissions with registerForActivityResult(). Code for
import android.Manifest.permission.ACCESS_COARSE_LOCATION
import android.content.Context
import android.content.Intent
import android.os.Bundle
import android.provider.Settings
import androidx.activity.ComponentActivity
import androidx.activity.result.contract.ActivityResultContracts.RequestPermission
antoniolg / HomeActivity.kt
Last active April 11, 2024 11:03
Snackbar extensions on Kotlin, to create a useful small DSL.
class HomeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
fab.setOnClickListener {
it.snack("Snack message") {
action("Action") { toast("Action clicked") }
antoniolg / 0_reuse_code.js
Last active August 29, 2015 14:15
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
public class MainActivity extends Activity {
protected void onCreate(Bundle savedInstanceState) {
int size = getResources().getDimensionPixelSize(R.dimen.fab_size);
Outline outline = new Outline();
antoniolg /
Last active July 29, 2019 11:59
An activity that uses a SwipeRefreshLayout as a container for the layout of the classes that extend it.
* Copyright (C) 2014 Antonio Leiva Gordillo.
* 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
* Unless required by applicable law or agreed to in writing, software