Skip to content

Instantly share code, notes, and snippets.

View titanwalking's full-sized avatar

Alican Korkmaz titanwalking

View GitHub Profile
@gmk57
gmk57 / CoroutineTimer.kt
Last active September 16, 2024 13:55
Coroutine-based solution for delayed and periodic work
/**
* Coroutine-based solution for delayed and periodic work. May fire once (if [interval] omitted)
* or periodically ([startDelay] defaults to [interval] in this case), replacing both
* `Observable.timer()` & `Observable.interval()` from RxJava.
*
* In contrast to RxJava, intervals are calculated since previous run completion; this is more
* convenient for potentially long work (prevents overlapping) and does not suffer from queueing
* multiple invocations in Doze mode on Android.
*
* Dispatcher is inherited from scope, may be overridden via [context] parameter.
@gmk57
gmk57 / 1 ViewBindingDelegates.kt
Last active September 6, 2024 06:45
Kotlin delegates for Android View Binding with usage examples
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.app.AppCompatActivity
import androidx.fragment.app.DialogFragment
import androidx.fragment.app.Fragment
import androidx.lifecycle.DefaultLifecycleObserver
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.viewbinding.ViewBinding
@qwert2603
qwert2603 / BaseViewModel.kt
Last active September 7, 2022 11:09
ViewModelStateFlow
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)
@karntrehan
karntrehan / ListAdapterTemplate.kt
Last active December 25, 2021 12:48
Kotlin ListAdapter template for RecyclerView in Android
#if (${PACKAGE_NAME} && ${PACKAGE_NAME} != "")package ${PACKAGE_NAME}#end
import androidx.recyclerview.widget.RecyclerView
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.view.View.OnClickListener
import androidx.recyclerview.widget.DiffUtil
import androidx.recyclerview.widget.ListAdapter
@ccampo133
ccampo133 / CurrencyFormatting.kt
Last active April 24, 2023 07:38
Currency formatting
import java.math.BigDecimal
import java.text.NumberFormat
import java.util.Currency
import java.util.Locale
fun main(args: Array<String>) {
val locales = listOf(
Locale.FRANCE,
Locale.GERMANY,
Locale.UK,
@chemickypes
chemickypes / CountDownTime.java
Created April 27, 2017 12:51
CountDownTimer suing RXJava 2
import java.util.concurrent.TimeUnit;
import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;
/**
* Created by Angelo Moroni on 27/04/17.
*/
@akashnimare
akashnimare / README.md
Last active October 16, 2024 18:49
A Beginners Guide to writing a Kickass README ✍

Project title

A little info about your project and/ or overview that explains what the project is about.

Motivation

A short description of the motivation behind the creation and maintenance of the project. This should explain why the project exists.

Build status

Build status of continus integration i.e. travis, appveyor etc. Ex. -

Build Status