Input | Last Input Value | Last Output Value | Formula | Output | |
---|---|---|---|---|---|
1 | 0 | - | - | - | 0 |
2 | 2 | 0 | 0 | 0 + 2 - 0 | 2 |
3 | 8 | 2 | 2 | 2 + 8 - 2 | 8 |
4 | 10 | 8 | 8 | 8 + 10 - 8 | 10 |
5 | 11 | 10 | 10 | 10 + 11 - 10 | 10 |
6 | 100 | 11 | 10 | 10 + 100 - 11 | 10 |
7 | 98 | 100 | 10 | 10 + 98 - 100 | 8 |
8 | 92 | 98 | 8 | 8 + 92 - 98 | 2 |
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, {Component} from "react"; | |
import {Animated, Dimensions, Platform, Text, TouchableOpacity, View} from "react-native"; | |
import {Body, Header, List, ListItem as Item, ScrollableTab, Tab, TabHeading, Tabs, Title} from "native-base"; | |
import LinearGradient from "react-native-linear-gradient"; | |
const {width: SCREEN_WIDTH} = Dimensions.get("window"); | |
const IMAGE_HEIGHT = 250; | |
const HEADER_HEIGHT = Platform.OS === "ios" ? 64 : 50; | |
const SCROLL_HEIGHT = IMAGE_HEIGHT - HEADER_HEIGHT; | |
const THEME_COLOR = "rgba(85,186,255, 1)"; |
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, {Component} from "react"; | |
import {Animated, Text, View} from "react-native"; | |
const SCROLL_HEIGHT = 800; | |
export class Colours extends Component { | |
nativeScroll = new Animated.Value(0); | |
nonNativeScroll = new Animated.Value(0); | |
constructor(props) { |
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
export const diffClamp = function( | |
a: Animated.Value<number>, | |
min: number, | |
max: number, | |
): AnimatedDiffClamp { | |
return new AnimatedDiffClamp(a, min, max); | |
}; | |
class AnimatedDiffClamp { | |
constructor(a: Animated.Value<number>, min: number, max: number) { |
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
export class SwipeableCard extends Component { | |
translateX = new Animated.Value(0); | |
_panResponder = PanResponder.create({ | |
onMoveShouldSetResponderCapture: () => true, | |
onMoveShouldSetPanResponderCapture: () => true, | |
onPanResponderMove: Animated.event([null, {dx: this.translateX}]), | |
onPanResponderRelease: (e, {vx, dx}) => { | |
const screenWidth = Dimensions.get("window").width; | |
if (Math.abs(vx) >= 0.5 || Math.abs(dx) >= 0.5 * screenWidth) { | |
Animated.timing(this.translateX, { |
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, {Component} from "react"; | |
import {LayoutAnimation, UIManager} from 'react-native'; | |
import {Body, Container, Header, Title, View} from "native-base"; | |
import {SwipeableCard} from "./SwipableCard"; | |
export class PanResponderDemo extends Component { | |
titles = new Array(10).fill(null).map((_, i) => `Card #${i}`); | |
state = { | |
closedIndices: [] | |
}; |
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, {Component} from "react"; | |
import {Animated, Dimensions, Easing, PanResponder, StyleSheet, View} from "react-native"; | |
import {Card} from "./Card"; | |
const {width: screenWidth, height: screenHeight} = Dimensions.get("window"); | |
export class Sliding extends Component { | |
bottomPadding = 10; | |
data = new Array(20).fill({ | |
name: "John Smith", |
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
public class Alarm extends BroadcastReceiver { | |
@Override | |
public void onReceive(final Context context, Intent intent) { | |
final Intent service = new Intent(context, AlarmService.class); | |
HeadlessJsTaskService.acquireWakeLockNow(context); | |
UiThreadUtil.runOnUiThread(new Runnable() { | |
@Override | |
public void run() { | |
context.startService(service); |
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
public class AlarmService extends HeadlessJsTaskService { | |
static long lastActive = 0; | |
@Override | |
protected @Nullable | |
HeadlessJsTaskConfig getTaskConfig(Intent intent) { | |
long current = System.currentTimeMillis(); | |
if ((current - lastActive) >= 30 * 1000) { | |
lastActive = current; | |
return new HeadlessJsTaskConfig( |
OlderNewer