Skip to content

Instantly share code, notes, and snippets.

View NaingAungLuu's full-sized avatar
👨‍💻
Working

Naing Aung Luu NaingAungLuu

👨‍💻
Working
View GitHub Profile
/**
* Created by Naing Aung Luu on 27/05/2022
*/
fun <T : Any> T.translateToAppLanguage(appLanguage: Language): T {
if (this::class.isData) {
this::class.declaredMemberProperties
.filter(KProperty1<out Any, *>::isATranslationProperty)
.map { it as KProperty1<Any, Translation<*>> }
.forEach {
it.get(this).translateToAppLanguage(appLanguage)
@NaingAungLuu
NaingAungLuu / NumberControlWidget.kt
Last active March 30, 2022 05:18
A Number Control Widget for android with custom validations, min and max value setters, custom xml attributes, and listeners
package com.rwsentosa.mobileapp.widgets
import android.content.Context
import android.util.AttributeSet
import android.view.View
import android.widget.FrameLayout
import android.widget.ImageView
import android.widget.TextView
import androidx.databinding.BindingAdapter
import com.rwsentosa.mobileapp.R
@NaingAungLuu
NaingAungLuu / NumberControlComposable.kt
Created March 30, 2022 04:21
A Number Control Composable for android Jetpack Compose UI with validators and animations
package com.rwsentosa.mobileapp.components
import androidx.annotation.DrawableRes
import androidx.compose.animation.AnimatedContent
import androidx.compose.animation.ExperimentalAnimationApi
import androidx.compose.animation.SizeTransform
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
import androidx.compose.animation.slideInVertically
import androidx.compose.animation.slideOutVertically
@NaingAungLuu
NaingAungLuu / GridItem.kt
Last active March 30, 2022 02:58
Zig-zag Grid Layout Composable
@Composable
fun GridItem(
modifier: Modifier = Modifier
) {
val interactionSource = remember { MutableInteractionSource() }
val indication = rememberRipple(bounded = false)
Box(
modifier = modifier.size(160.dp)
) {
Image(
@NaingAungLuu
NaingAungLuu / AppLanguage.kt
Last active February 6, 2023 09:49
Dynamic Localization
enum class AppLanguage(val value: String) {
ENGLISH("English"),
BURMESE("Burmese"),
CHINESE("Chinese");
}
sealed class StatefulData<out T : Any> {
data class Success<T : Any>(val result : T) : StatefulData<T>()
data class Error(val msg : String) : StatefulData<Nothing>()
object Loading : StatefulData<Nothing>()
inline fun <R : Any> map(transform: (T) -> R): StatefulData<R> {
return when(this) {
is Loading -> Loading
is Error -> Error(this.msg)
is Success -> Success(transform(this.result))
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.List;
class bubblesort {
public static void main(String[] args) {
List<String> names ;
try{