This file contains hidden or 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
#If users are clicking on links and they aren’t opening in your application, | |
#then there might be a problem with your intent-filters. You can test your | |
#intent-filters using the command adb shell am start with a VIEW action, a deep linked URL, | |
#and the package id. This checks that the application can handle a deep link which is explicitly sent to it. | |
adb shell am start \ | |
-W -a android.intent.action.VIEW \ | |
-d "https://droidfood.example.com" \ | |
com.example.droidfood |
This file contains hidden or 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 class ColorWheel(diameter: Int) { | |
private val radius = diameter / 2f | |
private val sweepGradient = SweepGradientShader( | |
colors = listOf( | |
Color.Red, Color.Magenta, Color.Blue, | |
Color.Cyan, Color.Green, Color.Yellow, Color.Red | |
), | |
center = Offset(radius, radius) | |
) |
This file contains hidden or 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
@RequiresApi(Build.VERSION_CODES.LOLLIPOP) | |
fun View.hide() { | |
// get the center for the clipping circle | |
val cx = this.width / 2 | |
val cy = this.height / 2 | |
// get the initial radius for the clipping circle | |
val initialRadius = hypot(cx.toDouble(), cy.toDouble()).toFloat() | |
// create the animation (the final radius is zero) | |
val anim = ViewAnimationUtils.createCircularReveal(this, cx, cy, initialRadius, 0f) |
This file contains hidden or 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
inline fun View.snack( | |
@StringRes messageRes: Int, | |
length: Int = Snackbar.LENGTH_LONG, | |
f: Snackbar.() -> Unit | |
) { | |
snack(resources.getString(messageRes), length, f) | |
} | |
inline fun View.snack(message: String, length: Int = Snackbar.LENGTH_LONG, f: Snackbar.() -> Unit) { | |
val snack = Snackbar.make(this, message, length) |
This file contains hidden or 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 TextInputEditText.textChangedDebounce(debounceTime: Long = 100L, action: (text: String) -> Unit) { | |
this.addTextChangedListener(object : TextWatcher { | |
private var lastTextChangedTime: Long = 0 | |
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) {} | |
override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) {} | |
override fun afterTextChanged(s: Editable?) { | |
if (SystemClock.elapsedRealtime() - lastTextChangedTime < debounceTime) return | |
else action(s.toString()) |
This file contains hidden or 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
if (manager.hasPermission(device)) { | |
try { | |
val openUsbDevice = manager.openDevice(device) | |
logArray.add( | |
LogItem( | |
"openUsbDevice Connection", | |
"$openUsbDevice" | |
) | |
) | |
try { |
This file contains hidden or 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 UsbDeviceHelper { | |
/** | |
* Returns first interface on USB Smart Card Device or throws an UsbInterfaceNotFound | |
* exception if device is not Smart Card or Interface does not exist | |
* | |
* @param usbDevice | |
* @return UsbEndpoint | |
* @throws UsbEndpointNotFound | |
*/ |
This file contains hidden or 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
UsbDevice[ | |
mName=/dev/bus/usb/001/014, | |
mVendorId=2414, | |
mProductId=1539, | |
mClass=0, | |
mSubclass=0, | |
mProtocol=0, | |
mManufacturerName=FeiTian Ltd, | |
mProductName=JavaCard Token V1.0, | |
mVersion=1.06, |
This file contains hidden or 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 String.toTransparentColor(num: Int): String { | |
return "#" + when (num) { | |
100 -> "FF" | |
99 -> "FC" | |
98 -> "FA" | |
97 -> "F7" | |
96 -> "F5" | |
95 -> "F2" | |
94 -> "F0" |