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
apply plugin: 'com.android.application' | |
// version information | |
def versionMajor = 1 | |
def versionMinor = 0 | |
def versionPatch = 0 | |
android { | |
compileSdkVersion 26 | |
buildToolsVersion "26.0.2" |
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
android { | |
applicationVariants.all { variant -> | |
variant.outputs.all { | |
def fileName = "app" | |
switch (variant.buildType.name) { | |
case "debug": | |
fileName = "${appNameDebug}-${variant.versionCode}" | |
break | |
case "release": | |
fileName = "${appNameRelease}-${variant.versionCode}" |
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
./gradlew clean buildRelease publish |
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
import android.app.Activity | |
import android.util.Log | |
import android.view.ViewTreeObserver | |
import androidx.annotation.MainThread | |
import androidx.lifecycle.Lifecycle | |
import androidx.lifecycle.LifecycleOwner | |
import com.******************.Barrier | |
import com.******************.Closure | |
import com.*******************.Once |
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
import java.util.concurrent.atomic.AtomicInteger | |
/** | |
* Construct that helps to restrict the code execution frequency to 1. It will not allow the snippet passed through the close to be executed more than once. | |
* The first client to execute run() will execute this and other calls to run() will not be respected till reset is called. | |
*/ | |
class Once { | |
private val mCounter = AtomicInteger(0) |
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
import android.os.Handler; | |
import android.os.Looper; | |
import android.util.Log; | |
import androidx.annotation.NonNull; | |
import androidx.annotation.VisibleForTesting; | |
import java.lang.ref.WeakReference; | |
import java.util.concurrent.atomic.AtomicBoolean; | |
import java.util.concurrent.atomic.AtomicReference; |
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
import android.view.View | |
interface LazyLifecycleCallbacks { | |
/** | |
* Lazy version of activity onCreate() callback. Should be used for one time initialisations that could be done after the | |
* screen has finished rendering. Should not be used for complementary calls that set/reset their state in | |
* onCreate/onDestroy | |
*/ | |
fun onLazyCreate() |
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
import androidx.lifecycle.ViewModel | |
import kotlinx.coroutines.flow.MutableStateFlow | |
import kotlinx.coroutines.flow.StateFlow | |
sealed class ViewModelStateFlow<T>(stateFlow: StateFlow<T>) : StateFlow<T> by stateFlow | |
private class ViewModelStateFlowImpl<T>( | |
initial: T, | |
val wrapped: MutableStateFlow<T> = MutableStateFlow(initial) | |
) : ViewModelStateFlow<T>(wrapped) |
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
class MainViewModel : ViewModel() { | |
sealed class Event { | |
object NavigateToSettings: Event() | |
data class ShowSnackBar(val text: String): Event() | |
data class ShowToast(val text: String): Event() | |
} | |
private val eventChannel = Channel<Event>(Channel.BUFFERED) | |
val eventsFlow = eventChannel.receiveAsFlow() |
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
@OptIn(ExperimentalTextApi::class) | |
@Composable | |
fun fontFamily() = FontFamily( | |
Font(LocalContext.current.assets,"myfont.ttf") | |
) | |
@Composable | |
fun typography() = Typography( | |
h1 = TextStyle( |
OlderNewer