Skip to content

Instantly share code, notes, and snippets.

View akueisara's full-sized avatar
🎹

Kuei-Jung Hu akueisara

🎹
View GitHub Profile
@akueisara
akueisara / gist:e690fd7c10cc60048b6687129d6ca481
Created July 31, 2021 04:41
Build a Universal iOS Framework
lipo -create -output Kuei.framework KueiDevice.framework/KueiDevice KueiSim.framework/KueiSim
/*
This source file is part of the Swift.org open source project
Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
Licensed under Apache License v2.0 with Runtime Library Exception
See http://swift.org/LICENSE.txt for license information
See http://swift.org/CONTRIBUTORS.txt for Swift project authors
*/
/// An ordered set is an ordered collection of instances of `Element` in which
/// uniqueness of the objects is guaranteed.

Singleton

object MySingelton

Factory

interface Animal {
   val id : Int
@akueisara
akueisara / Add Support for Vector Drawables (SVG).md
Last active November 22, 2020 17:59
Android - Add Support for Vector Drawables (SVG)

1. Enable the use of support library for vector drawables in build.gradle file (app level):

vectorDrawables.useSupportLibrary = true

2. Use app:srcCompat in the image tag in the layout file:

app:srcCompat="@drawable/svg_name"
@akueisara
akueisara / Command.txt
Created July 20, 2020 04:49
When pod lib lint passes and pod spec lint doesn't
rm -rf ~/Library/Caches/Cocoapods /tmp/Cocoapods
@akueisara
akueisara / AppNavigationTestExtension.kt
Created April 20, 2020 11:27
An extension function to click on the navigation button
fun <T : Activity> ActivityScenario<T>.getToolbarNavigationContentDescription(): String {
var description = ""
onActivity {
description = it.findViewById<Toolbar>(R.id.toolbar).navigationContentDescription as String
}
return description
}
import android.view.View
import androidx.databinding.DataBindingUtil
import androidx.databinding.ViewDataBinding
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentActivity
import androidx.fragment.app.testing.FragmentScenario
import androidx.test.core.app.ActivityScenario
import androidx.test.espresso.IdlingResource
import java.util.*
@akueisara
akueisara / MainCoroutineRule.kt
Created April 20, 2020 09:57
Testing Coroutines on Android
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.test.TestCoroutineDispatcher
import kotlinx.coroutines.test.TestCoroutineScope
import kotlinx.coroutines.test.resetMain
import kotlinx.coroutines.test.setMain
import org.junit.rules.TestWatcher
import org.junit.runner.Description
/* JUnit rule: https://junit.org/junit4/javadoc/4.12/org/junit/Rule.html */
import androidx.annotation.VisibleForTesting
import androidx.lifecycle.LiveData
import androidx.lifecycle.Observer
import java.util.concurrent.CountDownLatch
import java.util.concurrent.TimeUnit
import java.util.concurrent.TimeoutException
// version 1
@VisibleForTesting(otherwise = VisibleForTesting.NONE)
fun <T> LiveData<T>.getOrAwaitValue(
@akueisara
akueisara / Animations.kt
Last active April 16, 2020 06:21
Android Property Animations Code Snippets (Udacity)
private fun ObjectAnimator.disableViewDuringAnimation(view: View) {
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationStart(animation: Animator?) {
view.isEnabled = false
}
override fun onAnimationEnd(animation: Animator?) {
view.isEnabled = true
}
})