Skip to content

Instantly share code, notes, and snippets.

View viniciusalvesmello's full-sized avatar

Vinícius Alves Mello viniciusalvesmello

View GitHub Profile
@viniciusalvesmello
viniciusalvesmello / keychron_linux.md
Created March 14, 2022 11:18 — forked from andrebrait/keychron_linux.md
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

@viniciusalvesmello
viniciusalvesmello / keychron_linux.md
Created March 14, 2022 11:18 — forked from andrebrait/keychron_linux.md
Keychron keyboards on Linux + Bluetooth fixes

Here is the best setup (I think so :D) for K-series Keychron keyboards on Linux.

Most of these commands have been tested on Ubuntu 20.04 and should also work on most Debian-based distributions. If a command happens not to work for you, take a look in the comment section.

Make Fn + F-keys work

Keychron Keyboards on Linux use the hid_apple driver (even in Windows/Android mode), both in Bluetooth and Wired modes. By default, this driver uses the F-keys as multimedia shortcuts and you have to press Fn + the key to get the usual F1 through F12 keys.

@viniciusalvesmello
viniciusalvesmello / sample_mvp_hilt_with_assisted_injection.kt
Created March 28, 2021 21:44
Exemplo Simples de MVP com Hilt + Dagger assisted injection
interface SampleRepository {
fun getSample(): String
}
class SampleRepositoryImpl: SampleRepository {
override fun getSample() = "Sample"
}
interface SamplePresenter {
fun initView()
@viniciusalvesmello
viniciusalvesmello / sample_mvp_hilt.kt
Created March 28, 2021 21:32
Exemplo Simples de MVP com Hilt
interface SampleRepository {
fun getSample(): String
}
class SampleRepositoryImpl: SampleRepository {
override fun getSample() = "Sample"
}
interface SamplePresenter {
fun initView()
@viniciusalvesmello
viniciusalvesmello / sample_mvp_hilt_with_error.kt
Last active March 28, 2021 21:29
Exemplo de MVP com o Hilt que gera o erro MissingBinding (Antes funcionava com o Dagger 2)
interface SampleRepository {
fun getSample(): String
}
class SampleRepositoryImpl: SampleRepository {
override fun getSample() = "Sample"
}
interface SamplePresenter {
fun initView()
@viniciusalvesmello
viniciusalvesmello / sample_hilt.kt
Last active March 28, 2021 20:55
Exemplo Dagger Hilt de como prover a mesma interface com duas implementações diferentes.
interface Sample {
fun getSample(): String
}
class SampleXImpl: Sample {
override fun getSample() = "Sample X"
}
class SampleYImpl: Sample {
override fun getSample() = "Sample Y"
@viniciusalvesmello
viniciusalvesmello / sample.kt
Created March 28, 2021 20:18
Exemplo de módulos provendo a mesma interface no Dagger 2
interface Sample {
fun getSample(): String
}
class SampleXImpl: Sample {
override fun getSample() = "Sample X"
}
class SampleYImpl: Sample {
override fun getSample() = "Sample Y"
@viniciusalvesmello
viniciusalvesmello / MyFragment.kt
Created March 26, 2021 18:19
Intância ViewModel com Dagger Hilt sem a Fragment KTX
@AndroidEntryPoint
class MyFragment : Fragment() {
...
private val viewModel: MyViewModel by lazy {
ViewModelProvider(this).get(MyViewModel.class)
}
...
}
@viniciusalvesmello
viniciusalvesmello / MyFragment.kt
Last active March 26, 2021 18:17
Instância ViewModel com Dagger Hilt + Fragment KTX
@AndroidEntryPoint
class MyFragment : Fragment() {
...
private val viewModel: MyViewModel by viewModels()
...
}
@viniciusalvesmello
viniciusalvesmello / MyFragment.kt
Created March 26, 2021 18:13
Instância ViewModel Dagger 2
@AndroidEntryPoint
class MyFragment : Fragment() {
...
@Inject
lateinit var viewModelFactory: ViewModelFactory
private val viewModel: MyViewModel by lazy {
ViewModelProvider(this, viewModelFactory)[MyViewModel::class.java]
}
...