Skip to content

Instantly share code, notes, and snippets.

View lucamtudor's full-sized avatar

Tudor Luca lucamtudor

View GitHub Profile
@lucamtudor
lucamtudor / Permissions.kt
Created August 18, 2021 11:43 — forked from objcode/Permissions.kt
Quick demo of compose permissions using activity result API. Uses Flow instead of State to make it reusable outside of Compose.
/*
* Copyright 2020 The Android Open Source Project
*
* 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
<!-- **NOTE** This must be in /debug/ -->
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.codingwithmitch.daggerhiltplayground">
<application>
<activity
android:name="com.codingwithmitch.daggerhiltplayground.HiltTestActivity"
android:exported="false" />
</application>
@lucamtudor
lucamtudor / flutter_redux_firebase_sync.dart
Last active March 11, 2018 13:17
Flutter: sync redux store with Firebase
// This pattern makes it easier to keep a redux store in sync with Firebase.
// I used Firebase firestore, but the same thing applies to the Firebase real-time database.
// - Flutter -
void main() {
runApp(new ShiftStudioApp());
}
class ShiftStudioApp extends StatefulWidget {
@override
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src='https://cdnjs.cloudflare.com/ajax/libs/babel-core/5.8.23/browser-polyfill.min.js'></script>
</head>
<body>
@lucamtudor
lucamtudor / colors.xml
Last active August 29, 2015 14:17 — forked from mpost/colors.xml
<?xml version="1.0" encoding="utf-8"?>
<resources>
<color name="action_pause">#FF8F00</color>
<color name="action_resume">#43A047</color>
</resources>
@lucamtudor
lucamtudor / AutoResizeTextView.java
Created October 18, 2014 18:11
AutoResizeTextView
/**
* DO WHAT YOU WANT TO PUBLIC LICENSE
* Version 2, December 2004
*
* Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>
*
* Everyone is permitted to copy and distribute verbatim or modified
* copies of this license document, and changing it is allowed as long
* as the name is changed.
*
@lucamtudor
lucamtudor / Example.java
Created September 18, 2014 12:33
An array adapter that uses the last item as a hint. Use with a spinner
String[] strings = getResources().getStringArray(R.array.spinner_options);
HintAdapter<String> hintAdapter = new HintAdapter<String>(this, android.R.layout.simple_spinner_item, strings);
hintAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
mSpinner.setAdapter(hintAdapter);
mSpinner.setSelection(hintAdapter.getCount());
public class ColorUtils {
private static final double LM_RED_COEFFICIENT = 0.2126;
private static final double LM_GREEN_COEFFICIENT = 0.7152;
private static final double LM_BLUE_COEFFICIENT = 0.0722;
public static int calculateRelativeLuminance(int color) {
int red = (int) (Color.red(color) * LM_RED_COEFFICIENT);
int green = (int) (Color.green(color) * LM_GREEN_COEFFICIENT);
int blue = (int) (Color.blue(color) * LM_BLUE_COEFFICIENT);
return red + green + blue;
@lucamtudor
lucamtudor / .gitignore
Created January 10, 2014 23:06
Android .gitignore, both for Eclipse ADT and Android Studio/Intellij IDEA based projects.
# OSX files
.DS_Store
# Ignore gradle files
.gradle
.gradletasknamecache
# generated files
bin/
<provider
android:name=".providers.AssetProvider"
android:authorities="@string/provider_asset"
android:multiprocess="true"
android:exported="true"/>
<provider
android:name=".providers.AssetTagProvider"
android:authorities="@string/provider_assettags"
android:multiprocess="true"