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
| // Producer is covariant in T | |
| // Class body can only return T, not take T as parameter | |
| class Producer<out T> { | |
| fun produce() : T // ok | |
| fun consume(item: T) // compile error | |
| } | |
| // Then it's possible to: | |
| fun covariantExample(x: Producer<String>) { | |
| val y: Producer<Any> = x // Allowed, producer is covariant in T |
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.compose.animation.core.animateFloat | |
| import androidx.compose.animation.core.infiniteRepeatable | |
| import androidx.compose.animation.core.rememberInfiniteTransition | |
| import androidx.compose.animation.core.tween | |
| import androidx.compose.foundation.background | |
| import androidx.compose.foundation.layout.* | |
| import androidx.compose.foundation.shape.CircleShape | |
| import androidx.compose.runtime.* | |
| import androidx.compose.ui.Modifier | |
| import androidx.compose.ui.composed |
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
| "hide_navigation_samples_button": true, | |
| "hide_settings_menu_parent_tools": true, | |
| "remember_playback_speed_last_selected": false, | |
| "remember_video_quality_last_selected": false |
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
| // 1. Create a State for the ViewModel, which will be observed from the Screen | |
| data class AuthScreenState(...) | |
| class AuthViewModel : ViewModel() { | |
| private var _state = MutableStateFlow(AuthScreenState()) | |
| private val state = _state.stateIn( | |
| scope = viewModelScope | |
| started = SharingStarted.WhileSubscribed(stopTimeoutMillis = 5000) | |
| initialValue = AuthScreenState() | |
| ) |
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
| /* | |
| * Copyright (C) 2017 The Android Open Source Project | |
| * | |
| * Licensed under the Apache License, Version 2.0 (the "License"); | |
| * you may not use this file except in compliance with the License. | |
| * You may obtain a copy of the License at | |
| * | |
| * http://www.apache.org/licenses/LICENSE-2.0 | |
| * | |
| * Unless required by applicable law or agreed to in writing, software |
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 SoftInputAssist(activity: Activity) { | |
| private var contentContainer: ViewGroup? | |
| private var rootView: View? | |
| private val rootViewLayout: FrameLayout.LayoutParams? | |
| private val contentAreaOfWindowBounds: Rect = Rect() | |
| private var viewTreeObserver: ViewTreeObserver? = null | |
| private var usableHeightPrevious = 0 | |
| private val listener = OnGlobalLayoutListener { |
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
| { | |
| "timeStamp": 1767349321188, | |
| "version": "1.68.0", | |
| "userSettings": { | |
| "importedLists": [], | |
| "popupPanelSections": 63 | |
| }, | |
| "selectedFilterLists": [ | |
| "user-filters", | |
| "ublock-filters", |
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.security.keystore.KeyGenParameterSpec | |
| import android.security.keystore.KeyProperties | |
| import java.security.KeyStore | |
| import javax.crypto.Cipher | |
| import javax.crypto.KeyGenerator | |
| import javax.crypto.SecretKey | |
| import javax.crypto.spec.IvParameterSpec | |
| object Cryptography { | |
| private const val KEY_ALIAS = "secret" |
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
| fun maskPhoneNumber(input: String): String { | |
| fun removeNonNumericalChar(input: String): String { | |
| val result = StringBuilder() | |
| for (char in input) { | |
| if (char.isDigit()) { | |
| result.append(char) | |
| } | |
| } | |
| return result.toString() | |
| } |
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.net.Uri | |
| import kotlinx.coroutines.Dispatchers | |
| import kotlinx.coroutines.withContext | |
| class FileManager( | |
| private val context: Context | |
| ) { | |
| suspend fun saveImage( |