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.os.Looper | |
import androidx.annotation.OptIn | |
import androidx.camera.compose.CameraXViewfinder | |
import androidx.camera.core.CameraSelector | |
import androidx.camera.core.ExperimentalGetImage | |
import androidx.camera.core.ImageAnalysis | |
import androidx.camera.core.ImageAnalysis.COORDINATE_SYSTEM_ORIGINAL | |
import androidx.camera.core.Preview | |
import androidx.camera.core.SurfaceRequest | |
import androidx.camera.lifecycle.ProcessCameraProvider |
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
@Composable | |
fun EmojiGrid( | |
onEmojiPicked: (String) -> Unit, | |
modifier: Modifier = Modifier, | |
) { | |
val emojiPickedListener = androidx.core.util.Consumer<EmojiViewItem> { | |
onEmojiPicked(it.emoji) | |
} | |
Box( |
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.support.v4.content.res.ResourcesCompat | |
import android.support.v4.widget.TextViewCompat | |
import android.util.AttributeSet | |
import android.widget.TextView | |
import com.dgmltn.dashboardlayout.R | |
import timber.log.Timber | |
/** |
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 java.util.ArrayList | |
import android.animation.ObjectAnimator | |
import android.animation.ValueAnimator | |
import android.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Paint | |
import android.graphics.Path | |
import android.util.AttributeSet | |
import android.view.View |
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.graphics.Canvas | |
import android.graphics.Paint | |
import android.util.AttributeSet | |
import android.widget.TextView | |
class StrokedTextView(context: Context, attrs: AttributeSet?) : TextView(context, attrs) { | |
val DEFAULT_STROKE_WIDTH = 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
/** | |
* My take on the kotlin iterator presented in this (outdated) document: | |
* | |
* http://jamie.mccrindle.org/2013/01/a-functional-iterate-for-kotlin.html | |
* | |
*/ | |
import org.junit.Test | |
import kotlin.support.AbstractIterator | |
import kotlin.test.assertEquals |
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
// Picks a random value from an arbitrary sequence | |
fun <T: Any> random(input: Observable<T>): Observable<T> { | |
var size = 1 | |
return input | |
.filter { Math.floor(Math.random() * size++) == 0.0 } | |
.last() | |
} | |
// Test whether all items were chosen equally | |
fun test() { |
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/sh | |
FILE_URL=http://speedtest.wdc01.softlayer.com/downloads/test10.zip | |
if [ -e /usr/bin/curl ] && [ -e /usr/bin/bc ] && [ -e /usr/bin/xargs ]; then | |
echo "scale=2; `curl --progress-bar -w "%{speed_download}" $FILE_URL -o /dev/null` / 131072"\ | |
| bc\ | |
| xargs -I {} echo {} mbps | |
elif [ -e /usr/bin/curl ]; then | |
curl -o /dev/null $FILE_URL |
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
/** | |
* This static method determines if we have network connectivity at this moment. | |
* @param context the app context | |
* @return true if network is up and available, false otherwise | |
*/ | |
public static boolean isOnline(Context context) { | |
ConnectivityManager cm = (ConnectivityManager) context.getSystemService(Context.CONNECTIVITY_SERVICE); | |
NetworkInfo ni = cm.getActiveNetworkInfo(); | |
return (ni != null && ni.isAvailable() && ni.isConnected()); | |
} |
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
/** | |
* A semicolon separated list of formatting strings to format. "N" | |
* represents any single digit. [1-9()-] represents an exact digit. The | |
* underscore "_" represents a SPACE (not an underscore). These rules will | |
* be followed sequentially until one is matched. | |
*/ | |
private static final String DIALPLAN = "+1_NNN_NNN_NNNN;1_(NNN)_NNN-NNNN;NNN-NNNN;(NNN)_NNN-NNNN"; | |
/** | |
* Formats a phone number according to the rules defined in |