This file contains 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
package com.kotlin.utils.singleton | |
/** | |
* What if you need pass some arguments for initialization jus like parameterized constructor? | |
* Since we can't use constructor with the object keyword. So, we need to find some other way of | |
* doing the same. | |
* | |
* We can archive this by using a SingletonHolder class. | |
* Also, to make it thread-safe, we need to have a way of synchronized a double check locking principle. | |
*/ |
This file contains 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 Foundation | |
enum PokemonType : Int { | |
case Water = 0 | |
case Fire | |
case Plant | |
case Electro | |
static var count: Int { return PokemonType.Electro.rawValue + 1} |
This file contains 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
sealed class AuthState { | |
object Idle : AuthState() | |
object Authenticating : AuthState() | |
class Authenticated(val user: FirebaseUser? = null) : AuthState() | |
object Unauthenticated : AuthState() | |
class AuthError(val message: String? = null) : AuthState() | |
} |
This file contains 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 MainActivity : AppCompatActivity() { | |
private lateinit var appBarConfiguration: AppBarConfiguration | |
private lateinit var binding: ActivityMainBinding | |
private val mViewModel by viewModels<AuthViewModel> { | |
AuthViewModelFactory(this.application) | |
} | |
private val auth by lazy { | |
FirebaseAuth.getInstance() |
This file contains 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 FirstFragment : Fragment() { | |
private var _binding: FragmentFirstBinding? = null | |
private val binding get() = _binding!! | |
val viewModel by activityViewModels<MyViewModel>() | |
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View { |
This file contains 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
package com.example.testmenu | |
import android.os.Bundle | |
import android.view.ActionMode | |
import android.view.Menu | |
import android.view.MenuItem | |
import android.widget.Toast | |
import androidx.appcompat.app.AppCompatActivity | |
import androidx.navigation.findNavController | |
import androidx.navigation.ui.AppBarConfiguration |
This file contains 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.util.Patterns | |
import java.util.regex.Pattern | |
object YoutubeUtils { | |
private fun extractYoutubeId(url: String): String? { | |
val pattern = "([/|?|&]vi?[/|=]|youtu.be/|embed/)([a-zA-Z0-9_-]+)".toRegex() | |
return pattern.find(url)?.groupValues?.last() |
This file contains 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 ClickManager( | |
private val sp: SharedPreferences, | |
private val triggerTask: (Int) -> Unit, | |
private val triggerClick: Int = TRIGGER_CLICK, | |
private val uid: String? = null | |
) { | |
companion object { | |
private const val KEY_CLICKS_COUNT = "clicks_count" | |
private val TRIGGER_CLICK = 5 | |
} |
This file contains 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
package com.webserveis.app.testradiogridlayout | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.View | |
import android.view.ViewGroup | |
import android.view.accessibility.AccessibilityEvent | |
import android.view.accessibility.AccessibilityNodeInfo | |
import android.widget.CompoundButton | |
import androidx.appcompat.widget.AppCompatRadioButton |
This file contains 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
package com.pascalwelsch.extensions | |
import android.app.Activity | |
import android.content.Context | |
import android.content.Intent | |
import android.os.Build | |
import android.os.Bundle | |
/** | |
* Extensions for simpler launching of Activities |