Skip to content

Instantly share code, notes, and snippets.

@thegarlynch
thegarlynch / DebounceCompose.kt
Created January 4, 2022 07:54
Debounce Action Compose.. So click won't triggered twice
import android.os.SystemClock
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
/**
* Use this for debouncing action.
* This will returned a closure that will transformed the [action]
* so into debounced closure
*
* How to use :
@thegarlynch
thegarlynch / appmodule.kt
Last active October 22, 2021 09:43
Manual Dependency Injection
class TitanApplication : Application(), ApplicationComponentOwner {
override lateinit var component : ApplicationComponent
fun onCreate(){
component = ApplicationComponentImpl()
}
}
@thegarlynch
thegarlynch / SlackWebHook.kt
Created September 29, 2021 09:42
SlackWebHook untuk Mengirim Remote File ke Slack
import androidx.appcompat.app.AppCompatActivity
import com.cpssoft.mobile.titan.BuildConfig
import com.cpssoft.mobile.titan.common.extentions.formatDate
import com.cpssoft.mobile.titan.common.global.App
import com.cpssoft.mobile.titan.common.view.dialog.ApproveDialog
import com.cpssoft.mobile.titan.server.RemoteModule
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.launch
import okhttp3.*
import android.content.Context
import android.view.View
import android.view.inputmethod.InputMethodManager
import android.widget.EditText
private fun View.getMethodManager() : InputMethodManager {
return context.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
}
@thegarlynch
thegarlynch / ViewModel.kt
Created August 2, 2021 05:35
Parent Fragment ViewModel Access
import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import androidx.lifecycle.ViewModel
import androidx.lifecycle.ViewModelStoreOwner
inline fun <reified VM : ViewModel> Fragment.parentViewModel() : Lazy<VM>{
return viewModels(
ownerProducer = {
parentFragmentManager as ViewModelStoreOwner
}
object StringUtil {
/**
* String Format :
*
* <<Regular Text>> <<Clickable Bold Text>>
*
* Don't forget this line to made clicking work,
* apply it into textView.
<?php
class PDF extends Pdftc {
//Page header
public function Header() {
if ($this->page == 1)
{
$this->SetFont('times', '', 10);
$this->SetXY(110,8);
$this->hal='{nb}';
$this->SetX(10);
# Daemon config file for PipeWire version "0.3.26" #
context.properties = {
## Configure properties in the system.
#library.name.system = support/libspa-support
#context.data-loop.library.name.system = support/libspa-support
#support.dbus = true
#link.max-buffers = 64
link.max-buffers = 16 # version < 3 clients can't handle more
#mem.warn-mlock = false
@thegarlynch
thegarlynch / LocationFinder.kt
Last active August 13, 2020 06:23
Implementasi Location Finder
package com.thegar.example.helper.location
import android.Manifest
import android.app.Activity
import android.content.IntentSender
import android.content.pm.PackageManager
import android.os.Looper
import androidx.core.app.ActivityCompat
import com.google.android.gms.common.api.ResolvableApiException
import com.google.android.gms.location.*
import android.content.Context
import android.view.View
import android.widget.LinearLayout
import io.reactivex.Observable
interface Input {
val mandatory : Boolean
val focusIds : Array<Int>
fun buildView(context : Context) : View