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
dependencies { | |
testImplementation 'io.github.ivanshafran:shared-preferences-mock:1.2.4' | |
} |
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
allprojects { | |
repositories { | |
... | |
mavenCentral() | |
} | |
} |
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
class AnimatedGameObject( | |
private val bitmaps: List<Bitmap>, | |
private val duration: Long | |
) { | |
fun getBitmap(timeInMillis: Long): Bitmap { | |
val mod = timeInMillis % duration | |
val index = (mod / duration.toFloat()) * bitmaps.size | |
return bitmaps[index.toInt()] | |
} | |
} |
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 scorePaint = Paint(Paint.ANTI_ALIAS_FLAG).apply { | |
color = Color.GREEN | |
textSize = context.resources.getDimension(R.dimen.score_size) | |
} | |
private var score: Int = 0 | |
private var scorePoint = PointF() | |
private fun initializeScore() { | |
val bounds = Rect() | |
scorePaint.getTextBounds("0", 0, 1, bounds) | |
val scoreMargin = resources.getDimension(R.dimen.score_margin) |
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
// Move the cake off the screen right away | |
private fun initializeCake() { | |
cakeSize = height / 8 | |
moveCakeToStartPoint() | |
} | |
private fun moveCakeToStartPoint() { | |
// Choose a random position | |
cakeRect.left = width + width * Random.nextFloat() | |
cakeRect.right = cakeRect.left + cakeSize | |
// Choose a random line |
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 var playerSize = 0 | |
private var playerRect = RectF() | |
// Initialize size depending on screen size | |
private fun initializePlayer() { | |
playerSize = height / 4 | |
playerRect.left = playerSize / 2f | |
playerRect.right = playerRect.left + playerSize | |
} | |
// Saving emotion flags | |
private var flags: EmotionFlags |
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
// Inside FaceDetectorProcessor.java | |
public class FaceDetectorProcessor extends VisionProcessorBase<List<Face>> { | |
public static class Emotion { | |
public final float smileProbability; | |
public final float leftEyeOpenProbability; | |
public final float rightEyeOpenProbability; | |
public Emotion(float smileProbability, float leftEyeOpenProbability, float rightEyeOpenProbability) { | |
this.smileProbability = smileProbability; | |
this.leftEyeOpenProbability = leftEyeOpenProbability; |
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
<meta-data | |
android:name="com.google.mlkit.vision.DEPENDENCIES" | |
android:value="face"/> | |
<activity | |
android:name=".CameraXLivePreviewActivity" | |
android:exported="true" | |
android:theme="@style/AppTheme"> | |
<intent-filter> | |
<action android:name="android.intent.action.MAIN"/> | |
<category android:name="android.intent.category.LAUNCHER"/> |
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
val image: FirebaseVisionImage | |
try { | |
val uri = Uri.fromFile(imageFile) | |
image = FirebaseVisionImage.fromFilePath(context, uri) | |
val detector: FirebaseVisionTextRecognizer = FirebaseVision.getInstance().onDeviceTextRecognizer | |
val task = detector.processImage(image) | |
.addOnSuccessListener { result -> | |
val text = result.text | |
} | |
.addOnFailureListener { error -> |
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
package com.abbyy.rtr.ui.sample.imagecapture.flexicapture; | |
import org.junit.Rule; | |
import org.junit.Test; | |
import java.io.IOException; | |
import java.util.concurrent.CountDownLatch; | |
import okhttp3.Call; | |
import okhttp3.Callback; |
NewerOlder