Skip to content

Instantly share code, notes, and snippets.

View Pulimet's full-sized avatar
🏠
Working from home

Alexey Korolev Pulimet

🏠
Working from home
View GitHub Profile
@Pulimet
Pulimet / AdbCommands
Last active May 11, 2024 10:19
Adb useful commands list
adb help // List all comands
== Adb Server
adb kill-server
adb start-server
== Adb Reboot
adb reboot
adb reboot recovery
adb reboot-bootloader
// Short way to collect StateFlow on coroutine when Activity Started.
// Useful when you need to collect one StateFlow, but could be used for many.
fun <T> StateFlow<T>.collectIt(lifecycleOwner: LifecycleOwner, function: (T) -> Unit) {
lifecycleOwner.lifecycleScope.launch {
lifecycleOwner.repeatOnLifecycle(Lifecycle.State.STARTED) {
collect {
function.invoke(it)
}
}
}
# Gradle files
.gradle/
# Intellij
.idea/
*.iml
# Build
build/
@Pulimet
Pulimet / logger.gradle
Last active June 15, 2020 18:30
MyLog Library Article
android {
Properties properties = new Properties()
if (project.rootProject.file("local.properties").exists()) {
properties.load(project.rootProject.file("local.properties").newDataInputStream())
}
defaultConfig {
buildConfigField "boolean", "isThreadNameVisible", properties.getProperty("logger.isThreadNameVisible", "false")
buildConfigField "boolean", "isTimeVisible", properties.getProperty("logger.isTimeVisible","false")
buildConfigField "boolean", "isPackageNameVisible", properties.getProperty("logger.isPackageNameVisible", "false")
@Pulimet
Pulimet / build.gradle
Last active June 15, 2020 18:30
MyLog Library Article 2
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply from: 'logger.gradle'
@Pulimet
Pulimet / SetParamsFromLocalProperties.kt
Last active June 15, 2020 18:30
MyLog Library Article 3
private fun setParamsFromLocalProperties() {
MyLogKt.isThreadNameVisible = BuildConfig.isThreadNameVisible
MyLogKt.isTimeVisible = BuildConfig.isTimeVisible
MyLogKt.isPackageNameVisible = BuildConfig.isPackageNameVisible
MyLogKt.isClassNameVisible = BuildConfig.isClassNameVisible
MyLogKt.isMethodNameVisible = BuildConfig.isMethodNameVisible
MyLogKt.isSpacingEnabled = BuildConfig.isSpacingEnabled
MyLogKt.isLengthShouldWrap = BuildConfig.isLengthShouldWrap
MyLogKt.classNameLength = BuildConfig.classNameLength
MyLogKt.methodNameLength = BuildConfig.methodNameLength
@Pulimet
Pulimet / proguard-rules.pro
Last active June 15, 2020 18:29
MyLog Library Article 4
# Removes all the logging functions
-assumenosideeffects class net.alexandroid.utils.mylogkt.MyLogKtKt { *; }
# Removes only logD() and logV() function
-assumenosideeffects class net.alexandroid.utils.mylogkt.MyLogKtKt {
public static *** logD$default(...);
public static *** logV$default(...);
}
@Pulimet
Pulimet / NavComponent.kt
Last active December 26, 2019 17:37
Navigation component + ToolBar + Drawer (Navigation icon click behavior and animation fix)
private var navController: NavController? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
setNavigationAndToolBar()
}
private fun setNavigationAndToolBar() {
setSupportActionBar(toolbar)
@Pulimet
Pulimet / GDPR_Countries_List.txt
Created November 19, 2018 12:14
GDPR Countries 2 Letter Country Code
private String gdprCounries[] = new String[]{
"US", //United States
"UM", //United States Minor Outlying Islands
"AT", //Austria
"BE", //Belgium
"BG", //Bulgaria
"HR", //Croatia
"CY", //Cyprus
"CZ", //Czech Republic
"DK", //Denmark
@Pulimet
Pulimet / Get Extras Info
Created December 4, 2014 11:03
To get information on an undocumented (3rd-party) intent:
for (String key : bundle.keySet()) {
Object value = bundle.get(key);
Log.d(TAG, String.format("%s %s (%s)", key,
value.toString(), value.getClass().getName()));
}