This file contains hidden or 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.text.Editable | |
import android.text.TextWatcher | |
abstract class SimpleTextWatcher : TextWatcher { | |
override fun afterTextChanged(s: Editable?) { | |
} | |
override fun beforeTextChanged(s: CharSequence?, start: Int, count: Int, after: Int) { | |
} |
This file contains hidden or 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.content.Context | |
import android.content.SharedPreferences | |
import androidx.security.crypto.EncryptedSharedPreferences | |
import androidx.security.crypto.MasterKeys | |
import com.example.app.BuildConfig | |
class SecurePreferences(context: Context) { | |
private val _encryptedSharedPreferences: SharedPreferences |
This file contains hidden or 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
buildScript { | |
ext { | |
def appcompat_version = '1.1.0' | |
def constraint_layout_version = '1.1.3' | |
def coroutines_android_version = '1.3.2' | |
def reflect_android_version = '1.3.61' | |
def lifecycle_version = '2.1.0' | |
def livedata_version = '2.2.0-rc02' | |
def material_version = '1.0.0' | |
def security_version = '1.0.0-alpha02' |
This file contains hidden or 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 Event<out T>(private val content: T) { | |
var hasBeenUsed = false | |
private set | |
fun getContentIfNotUsed(): T? { | |
return if (hasBeenUsed) { | |
null | |
} else { | |
hasBeenUsed = true |
This file contains hidden or 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.databinding.ViewDataBinding | |
import androidx.recyclerview.widget.RecyclerView | |
open class BindingViewHolder<T, V : ViewDataBinding, L : BindingListener<T>>( | |
private val binding: V, | |
private val listener: L? | |
) : RecyclerView.ViewHolder(binding.root) { | |
fun bind(data: T) { | |
binding.setVariable(BR.viewmodel, data) |
This file contains hidden or 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
# in case u need it (common) | |
sudo apt-get install curl wget unzip | |
# install mysql | |
sudo apt-get install mysql-server | |
# setup mysql | |
sudo mysql_secure_installation | |
# Optional step - if mysql can't login using other users |
This file contains hidden or 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.content.Context | |
import android.graphics.Canvas | |
import android.graphics.Color | |
import android.graphics.Paint | |
import android.graphics.Region | |
import android.os.Build | |
import android.util.AttributeSet | |
import android.view.View | |
class ClipBoxView(ctx: Context, attrs: AttributeSet) : View(ctx, attrs) { |
This file contains hidden or 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.fragment.app.Fragment | |
import androidx.fragment.app.FragmentManager | |
import androidx.fragment.app.FragmentPagerAdapter | |
import androidx.viewpager.widget.ViewPager | |
import com.google.android.material.tabs.TabLayout | |
open class AnyFragmentPagerAdapter( | |
fm: FragmentManager, | |
private val mPages: List<AnyPagerableFragment> | |
) : FragmentPagerAdapter(fm, BEHAVIOR_RESUME_ONLY_CURRENT_FRAGMENT) { |
This file contains hidden or 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
<?xml version="1.0" encoding="utf-8"?> | |
<selector xmlns:android="http://schemas.android.com/apk/res/android"> | |
<item android:state_enabled="false" android:drawable="@drawable/btn_rounded_primary_disabled"/> | |
<item android:state_pressed="true" android:drawable="@drawable/btn_rounded_primary_pressed"/> | |
<item android:drawable="@drawable/btn_rounded_primary_normal"/> | |
</selector> |
This file contains hidden or 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.room.TypeConverters | |
import java.util.* | |
class FieldConverters { | |
@TypeConverters | |
fun fromTimestamp(value: Long?): Date? { | |
return value?.let { Date(it) } | |
} |