Skip to content

Instantly share code, notes, and snippets.

@baeyeongpyo
baeyeongpyo / DataStoreManager.kt
Last active November 1, 2023 02:37
Android DataStore Manager
import android.content.Context
import android.content.ContextWrapper
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
private typealias PreferenceKey<T> = Preferences.Key<T>
package test;
import android.arch.lifecycle.LiveData;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.IntentFilter;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
<templateSet group="Custom">
<template name="live" value="private val _$first$ = MutableLiveData&lt;$second$&gt;()&#10;val $first$ : LiveData&lt;$second$&gt; = _$first$" description="Live Data POJO" toReformat="false" toShortenFQNames="true">
<variable name="first" expression="" defaultValue="" alwaysStopAt="true" />
<variable name="second" expression="" defaultValue="" alwaysStopAt="true" />
<context>
<option name="KOTLIN" value="true" />
</context>
</template>
<template name="loggeri" value="Logging.info(&quot;$TAG$&quot;, &quot;$METHOD_NAME$: $content$&quot;);" toReformat="false" toShortenFQNames="true">
<variable name="TAG" expression="kotlinClassName()" defaultValue="" alwaysStopAt="true" />
import android.annotation.SuppressLint
import android.content.Context
import android.graphics.*
import android.graphics.drawable.Drawable
import android.util.AttributeSet
import android.view.View
import com.example.shadowtestproject.R
class CustomBlurView(
context: Context,
import android.annotation.SuppressLint
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import kotlinx.android.synthetic.main.activity_main.*
class MainActivity : AppCompatActivity() {
var count = 0
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<RadioButton
android:id="@+id/radio1"
class HelperRadioGroup @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintHelper(context, attributeSet, defStyleAttr) {
private lateinit var radioButtonGroup: Array<CompoundButton?>
private var mProtectFromCheckedChange = false
private var mCheckedId = -1
class HelperRadioGroup @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintHelper(context, attributeSet, defStyleAttr) {
private lateinit var radioButtonGroup: Array<CompoundButton?>
private var mProtectFromCheckedChange = false
private var mCheckedId = -1
class HelperRadioGroup @JvmOverloads constructor(
context: Context,
attributeSet: AttributeSet? = null,
defStyleAttr: Int = 0
) : ConstraintHelper(context, attributeSet, defStyleAttr) {
private lateinit var radioButtonGroup: Array<CompoundButton?>
private var mProtectFromCheckedChange = false
private var mCheckedId = -1
LISTVIEW.addItemDecoration(DividerItemDecoration(context, LinearLayoutManager(context).orientation))