Skip to content

Instantly share code, notes, and snippets.

@EmmanuelGuther
EmmanuelGuther / ViewChangeColor.java
Last active March 8, 2019 05:35
Change color of background view
/*
* Copyright (c) 2016. Emmanuel Gutierrez Hernandez
* 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
* distributed under the License is distributed on an "AS IS" BASIS,
@EmmanuelGuther
EmmanuelGuther / ListViewToFlatList.js
Last active May 5, 2017 11:01
REACT-NATIVE: ListView to the new FlatView
import React from 'react'
import { Text } from 'react-native'
import FlatList from 'react-native/Libraries/Lists/FlatList'
import dataList from './dataList'
export default class ListViewToFlatList extends React.Component {
renderItem ({ item, index }) {
return <Text>{item}</Text>
}
@EmmanuelGuther
EmmanuelGuther / getFlatList.bash
Created May 5, 2017 11:51 — forked from cooperka/getFlatList.bash
How to download FlatList and its related dependencies directly into your node_modules.
mkdir -p node_modules/react-native/Libraries/Lists/ && \
for file in 'FlatList' 'MetroListView' 'SectionList' 'VirtualizedList' 'VirtualizedSectionList' 'ViewabilityHelper' 'VirtualizeUtils'; \
do curl https://raw.githubusercontent.com/facebook/react-native/master/Libraries/Lists/${file}.js > node_modules/react-native/Libraries/Lists/${file}.js; \
done
@EmmanuelGuther
EmmanuelGuther / gettingNewFlatList.bash
Created May 5, 2017 11:57
At the moment it is not available, we must take it from the master branch
mkdir -p node_modules/react-native/Libraries/Lists/ && \
for file in 'FlatList' 'MetroListView' 'SectionList' 'VirtualizedList' 'VirtualizedSectionList' 'ViewabilityHelper' 'VirtualizeUtils'; \
do curl https://raw.githubusercontent.com/facebook/react-native/master/Libraries/Lists/${file}.js > node_modules/react-native/Libraries/Lists/${file}.js; \
done
@EmmanuelGuther
EmmanuelGuther / latAndlonGenerator.js
Last active May 9, 2017 13:04
These functions are for to generate points uniformly, randomly, and independently within a circle of radius r around a location (x0, y0),
/*These functions are for to generate points uniformly, randomly, and independently
within a circle of radius r around a location (x0, y0),
*/
function latAndlonGenerator (radius) {
const RADIUS_IN_METERS = 70000
let r = RADIUS_IN_METERS / 111300, // Convert meters in degrees (111,300 meters = a degree.)
y0 = 40.416775, // Central point where to generate more coordinates, inside a circle
x0 = -3.70379, // In this case, Madrid.
u = Math.random(),
v = Math.random(),
@EmmanuelGuther
EmmanuelGuther / simpsonsNames.java
Created May 11, 2017 10:40
Array of Simpsons names
[
"Homer J. Simpson",
"Marge Simpson (née Bouvier)",
"Bart Simpson",
"Lisa Simpson",
"Maggie Simpson",
"Grandpa Abe Simpson",
"Patty Bouvier",
"Selma Bouvier",
"Mona Simpson",
@EmmanuelGuther
EmmanuelGuther / goToActivity.java
Created August 1, 2017 12:44
ANDROID - Go to activity with transition
private void goToActivity(View view, Activity fromActivity,
final Class<? extends Activity> toActivity) {
Intent i = new Intent(fromActivity, toActivity);
Bundle bundle;
if (Build.VERSION.SDK_INT >= 23) {
bundle = ActivityOptions.makeClipRevealAnimation(view, 0, 0, view.getWidth(),
view.getHeight()).toBundle();
} else {
bundle = ActivityOptions.makeScaleUpAnimation(view, 0, 0, view.getWidth(),
view.getHeight()).toBundle();
@EmmanuelGuther
EmmanuelGuther / SimpleViewAnimation.java
Created August 1, 2017 13:29
ANDROID - Class to animate views
import android.content.Context;
import android.os.Build;
import android.view.View;
import android.view.animation.AnimationUtils;
public class SimpleViewAnimation {
public static final int SLOW_ANIM = 1900;
public static final int FAST_ANIM = 800;
public static final int DELAY_ANIM_DEFAULT = 500;
@EmmanuelGuther
EmmanuelGuther / KOTLINExampleFragmentOnClickFragment.kt
Created October 21, 2017 19:14
An example to how implements a button Onclick in Kotlin - Android Fragment
class ExmpleFragment : Fragment(), View.OnClickListener {
override fun onCreateView(inflater: LayoutInflater?, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view: View = inflater!!.inflate(R.layout.fragment, container, false)
val btn: Button = view.find(R.id.button2)
btn.setOnClickListener(this)
return view
}
@EmmanuelGuther
EmmanuelGuther / material_texts.xml
Last active May 14, 2018 09:58
Android Text material design
?xml version="1.0" encoding="utf-8"?>
<resources>
<dimen name="material_text_button">14sp</dimen>
<dimen name="material_text_menu">14sp</dimen>
<dimen name="material_text_caption">12sp</dimen>
<dimen name="material_text_body1">14sp</dimen>
<dimen name="material_text_body2">13sp</dimen>
<dimen name="material_text_subhead">16sp</dimen>
<dimen name="material_text_title">20sp</dimen>
<dimen name="material_text_headline">24sp</dimen>