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 RestServiceMockUtils { | |
public static String convertStreamToString(InputStream is) throws Exception { | |
BufferedReader reader = new BufferedReader(new InputStreamReader(is)); | |
StringBuilder sb = new StringBuilder(); | |
String line = null; | |
while ((line = reader.readLine()) != null) { | |
sb.append(line).append("\n"); | |
} | |
reader.close(); |
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 initialiseOnlinePresence() { | |
final DatabaseReference onlineRef = databaseReference.child(".info/connected"); | |
final DatabaseReference currentUserRef = databaseReference.child("/presence/" + userId); | |
onlineRef.addValueEventListener(new ValueEventListener() { | |
@Override | |
public void onDataChange(final DataSnapshot dataSnapshot) { | |
Log.d(TAG, "DataSnapshot:" + dataSnapshot); | |
if (dataSnapshot.getValue(Boolean.class)){ | |
currentUserRef.onDisconnect().removeValue(); | |
currentUserRef.setValue(true); |
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
#! /bin/bash | |
today=$(date +%Y%m%d) | |
for path in $(adb shell ls /sdcard/Pictures/Screenshots/*"${today}"*); do | |
name=$(basename "$path") | |
if [ ! -f "$name" ]; then | |
adb pull "$path" | |
fi | |
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
// Why use inline classes? 🤔 | |
// 🎯 Compile time safety | |
// 🎯 Less runtime overhead than a normal wrapper class as it "inlines" the data into its usages | |
// More info : https://kotlinlang.org/docs/reference/inline-classes.html | |
// Without inline classes 😞 | |
data class Recipe(id: UUID) | |
data class Ingredient(id: UUID, recipeId: UUID) |
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
SpringAnimation(this, floatPropertyAnimY, point.y).apply { | |
setStartVelocity(TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 5000f, resources.displayMetrics)) | |
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
private fun animateToPoint(point: Point) { | |
SpringAnimation(this, floatPropertyAnimX, point.x).apply { | |
spring.stiffness = SpringForce.STIFFNESS_MEDIUM | |
spring.dampingRatio = SpringForce.DAMPING_RATIO_MEDIUM_BOUNCY | |
start() | |
} | |
SpringAnimation(this, floatPropertyAnimY, point.y).apply { | |
spring.stiffness = SpringForce.STIFFNESS_MEDIUM |
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 val floatPropertyAnimX = object : FloatPropertyCompat<ColorDropperView>(PROPERTY_X) { | |
override fun setValue(dropper: ColorDropperView?, value: Float) { | |
dropper?.setDropperX(value) | |
} | |
override fun getValue(dropper: ColorDropperView?): Float { | |
return dropper?.getDropperX() ?: 0f | |
} | |
} |
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 fun animateToPoint(point: Point) { | |
val propertyX = PropertyValuesHolder.ofFloat(ColorDropperView.PROPERTY_X, dropperPoint.x, point.x) | |
val propertyY = PropertyValuesHolder.ofFloat(ColorDropperView.PROPERTY_Y, dropperPoint.y, point.y) | |
val animator = ValueAnimator() | |
animator.setValues(propertyX, propertyY) | |
animator.interpolator = OvershootInterpolator() | |
animator.duration = 100 | |
animator.addUpdateListener { animation -> | |
val animatedX = animation.getAnimatedValue(ColorDropperView.PROPERTY_X) as Float |
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
canvas.withTranslation(200f, 300f) { | |
drawCircle(150f, 150f, RADIUS, circlePaint) | |
withRotation(45f) { | |
drawRect(rect, rectPaint) | |
} | |
} |
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
canvas.withTranslate(200f, 300f) { | |
drawCircle(...) | |
} |