Skip to content

Instantly share code, notes, and snippets.

View delacrixmorgan's full-sized avatar
💭
🙉🙈🙊

Morgan Koh delacrixmorgan

💭
🙉🙈🙊
View GitHub Profile
@delacrixmorgan
delacrixmorgan / RawResourceFileSharing.md
Last active February 27, 2019 03:19
RAW to File Sharing

RAW to File Sharing

Android Manifest

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.fileProvider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
@delacrixmorgan
delacrixmorgan / AlertDialogs.md
Last active March 17, 2019 01:14
AlertDialog Single Choice Item, Date Picker
@delacrixmorgan
delacrixmorgan / FixOrientation.md
Created March 1, 2019 09:41
Fix Orientation for Photo Captured

Fix Orientation for Photo Captured

@Throws(IOException::class)
fun File.optimizedFromFile(
        maxImageDimension: Int,
        shouldFixRotation: Boolean,
        overwriteFile: Boolean,
        compressFormat: Bitmap.CompressFormat = Bitmap.CompressFormat.JPEG,
        quality: Int = 100
@delacrixmorgan
delacrixmorgan / CutHoleLayout.md
Created March 6, 2019 00:30
Cut a Hole in a Layout

Cut a Hole in a Layout

class CardOverlayFrameLayout(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs) {
    private var shapeRectF: RectF? = null

    init {
        setLayerType(LAYER_TYPE_SOFTWARE, null)
    }
@delacrixmorgan
delacrixmorgan / AndroidInstrumentedTests.md
Last active November 27, 2019 07:02
Android Instrumented Test
@delacrixmorgan
delacrixmorgan / LocalDateTimeCheatSheet.md
Last active February 7, 2022 22:07
LocalDateTime Cheat Sheet - Lost in Java Time with Android

LocalDateTime Cheat Sheet

Lost in Java Time with Android

LocalDateTime

String to LocalDateTime

val ISO_8601 = "yyyy-MM-dd'T'HH:mm:ss'Z'"
LocalDateTime.parse(this, DateTimeFormatter.ofPattern(ISO_8601))
@delacrixmorgan
delacrixmorgan / CapitalizeWords.md
Created March 11, 2019 03:24
Capitalize Words

Capitalize Words

fun String.capitalizeWords(): String {
    return this.toLowerCase()
            .replace("/", " / ")
            .split(" ")
            .joinToString(" ")
            { it.capitalize() }
}
@delacrixmorgan
delacrixmorgan / FlakyCamera.md
Last active March 31, 2020 21:21
Camera2 Infinite Loop in `CONTROL_AF_STATE_PASSIVE_FOCUSED`

Camera2 Infinite Loop in CONTROL_AF_STATE_PASSIVE_FOCUSED

There's a few reasons.

a) While you are capturePicture(), the AutoFocus state is stucked at CONTROL_AF_STATE_PASSIVE_FOCUSED and there is no way to shake it off.

Thus, you'll need to manually restart the focus and get a lock on it again.

b) setRepeatingRequest() from captureSession is overwhelming it.

@delacrixmorgan
delacrixmorgan / FullHeightScreenshots.md
Last active March 15, 2019 02:19
Full Height Screenshots

Full Height Screenshots

There's 3 Segments that would allow you achieve screenshoting full height of a scrollView.

a) FilePath and AndroidManifest

b) Intent Uri Share

c) BitmapExtensions (Where the actual magic happens)

@delacrixmorgan
delacrixmorgan / ViewPagerPeeking.md
Created March 18, 2019 02:37
Animate ViewPager to Peek when Tapped on It

Animate ViewPager to Peek when Tapped on It

Calling Method

this.viewPager.animatePeekingEffect(offset = 10, delay = 250)

Extension Methods

fun ViewPager.animatePeekingEffect(offset: Int, delay: Int) {