This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/*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(), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//Use like: vPager.setPageTransformer(true, ParallaxPageTransformer) | |
class ParallaxPageTransformer : ViewPager.PageTransformer { | |
override fun transformPage(view: View, position: Float) { | |
val pageWidth = view.width | |
when { | |
position < -1 -> view.alpha = 1f | |
position <= 1 -> dummyImageView.setTranslationX(-position * (pageWidth / 2)) //Half the normal speed | |
else -> view.alpha = 1f |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Instrumentation.ActivityMonitor activityBackMonitor = getInstrumentation().addMonitor(StationsActivity.class.getName(), null, false); | |
//CHECK IF ACTIVITY IS LAUNCHED | |
StationDetailActivity nextActivity = (StationDetailActivity) getInstrumentation().waitForMonitorWithTimeout(activityMonitor, 5000); | |
// next activity is opened and captured. | |
assertNotNull(nextActivity); | |
try { | |
Thread.sleep(2000); | |
} catch (InterruptedException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fun animationAppBarDown(appBar: AppBarLayout) { | |
object : CountDownTimer(300, 1) { | |
override fun onTick(millisUntilFinished: Long) { | |
appBar.translationY = (-appBar.height).toFloat() | |
} | |
override fun onFinish() { | |
appBar.animate() | |
.translationY(0f) | |
.setDuration(500).start() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
buildscript { | |
repositories { | |
mavenCentral() | |
maven { | |
url 'https://oss.sonatype.org/content/repositories/snapshots/' | |
} | |
} | |
dependencies { | |
classpath 'com.android.tools.build:gradle:0.9.+' | |
classpath 'com.squareup.gradle:gradle-android-test-plugin:0.9.1-SNAPSHOT' |
OlderNewer