Skip to content

Instantly share code, notes, and snippets.

View mertceyhan's full-sized avatar
🎯
Focusing

Cafer Mert Ceyhan mertceyhan

🎯
Focusing
View GitHub Profile
@JoseAlcerreca
JoseAlcerreca / Event.kt
Created April 26, 2018 10:25
An event wrapper for data that is exposed via a LiveData that represents an event.
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
@iammert
iammert / BottomBackStackController.kt
Last active December 19, 2023 19:50
Multiple Back Stack Controller + Navigation Component (Instagram-like backstack)
import androidx.fragment.app.FragmentManager
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
import androidx.navigation.NavController
import androidx.navigation.fragment.NavHostFragment
import com.google.android.material.bottomnavigation.BottomNavigationView
import java.util.Stack
import kotlin.collections.HashMap
class BottomBackStackController {
@Target(AnnotationTarget.CLASS)
@Retention(AnnotationRetention.SOURCE)
/**
* Friendly reminder that this might not be the best place to do major changes. Or any changes at all.
* Use the [reason] arg to point your teammates and your future-self to some documentation.
*/
annotation class HereBeDragons(val reason: String)
import org.json.JSONObject
import java.io.File
const val tinyPngApiKey = "<YOUR-API-KEY-GOES-HERE>"
val projectDir = File("<PATH-TOPROJECT-ROOT>")
val supportedExtensions = listOf("png", "jpg")
fun main() {
projectDir.walk().forEach { srcFile ->
if (supportedExtensions.contains(srcFile.extension)) {