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
println("List ====> ") | |
listOf(1, 2, 3) | |
.filter { println("Filter: $it"); it % 2 == 0 } | |
.map { println("Map: $it"); it + 1 } | |
.forEach { println("Each: $it") } | |
println("Sequence ====> ") | |
sequenceOf(1, 2, 3) | |
.filter { println("Filter: $it"); it % 2 == 0 } | |
.map { println("Map: $it"); it + 1 } |
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
println("List ====> ") | |
listOf(1, 2, 3) | |
.filter { | |
println("Filter: $it") | |
it % 2 == 0 | |
} | |
.map { | |
println("Map: $it") | |
it | |
} |
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
fun BottomNavigationView.setFont(@FontRes rId: Int) { | |
val menuView = this.getChildAt(0) as BottomNavigationMenuView | |
val menuCount = menuView.childCount | |
(0 until menuCount).forEach { | |
val itemView = menuView.getChildAt(it) as BottomNavigationItemView | |
val titleView = itemView.getChildAt(1) as BaselineLayout | |
val smallLabel = titleView.getChildAt(0) as TextView | |
val largeLabel = titleView.getChildAt(1) as TextView |
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
fun rotateBitmap(bitmap: Bitmap, orientation: Int): Bitmap? { | |
val matrix = Matrix() | |
when (orientation) { | |
ExifInterface.ORIENTATION_FLIP_HORIZONTAL -> matrix.setScale(-1F, 1F) | |
ExifInterface.ORIENTATION_ROTATE_180 -> matrix.setRotate(180F) | |
ExifInterface.ORIENTATION_FLIP_VERTICAL -> { | |
matrix.setRotate(180F) | |
matrix.postScale(-1F, 1F) | |
} |
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
@SuppressLint("RestrictedApi") | |
fun BottomNavigationView.disableShiftMode() { | |
val menuView = this.getChildAt(0) as BottomNavigationMenuView | |
try { | |
val shiftingMode = menuView.javaClass.getDeclaredField("mShiftingMode") | |
shiftingMode.isAccessible = true | |
shiftingMode.setBoolean(menuView, false) | |
shiftingMode.isAccessible = false |
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
public final class BuildConfig { | |
public static final boolean DEBUG = false; | |
public static final String APPLICATION_ID = "my.app"; | |
public static final String BUILD_TYPE = "local"; | |
public static final String FLAVOR = ""; | |
public static final int VERSION_CODE = 1; | |
public static final String VERSION_NAME = "0.1.0"; | |
// Fields from build type: local | |
public static final String API_URL = "http://192.165.36.44:5000/api/v1"; | |
} |
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
buildTypes { | |
local { | |
buildConfigField("String", "API_URL", "\"http://${getIPAddress()}:5000/api/v1\"") | |
} | |
debug { | |
buildConfigField("String", "API_URL", "\"http://my.staging.server/api/v1\"") | |
} | |
release { |
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
static def getIPAddress() { | |
Enumeration<NetworkInterface> interfaces = NetworkInterface.getNetworkInterfaces() | |
while (interfaces.hasMoreElements()) { | |
Enumeration<InetAddress> addresses = interfaces.nextElement().getInetAddresses() | |
while (addresses.hasMoreElements()) { | |
InetAddress address = addresses.nextElement() | |
if (!address.isLoopbackAddress() && address.isSiteLocalAddress()) { |
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
GsonBuilder().registerTypeAdapterFactory(NullStringToEmptyAdapterFactory()) | |
.create() | |
.run { | |
return fromJson(this@toObject, T::class.java) | |
} | |
class NullStringToEmptyAdapterFactory : TypeAdapterFactory { | |
override fun <T> create(gson: Gson, type: TypeToken<T>): TypeAdapter<T>? { | |
if (type.rawType != String::class.java) { |
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
headers = /path/to/header/hello.h |
NewerOlder