Skip to content

Instantly share code, notes, and snippets.

View Namazed's full-sized avatar

Alexander Namazed

View GitHub Profile
@NamtarR
NamtarR / User.kt
Created March 22, 2019 12:57
Android Room SQLite UPSERT without using actual https://www.sqlite.org/lang_UPSERT.html
package com.namtarr.upsert
import androidx.room.Entity
import androidx.room.PrimaryKey
@Entity
class User(
@PrimaryKey
val id: Long,
val name: String
package com.kaspersky.security_pulse_android.buisness.interactor
import com.kaspersky.security_pulse_android.buisness.repository.ILanguageRepository
import com.kaspersky.security_pulse_android.buisness.repository.ILoginRepository
import kotlinx.coroutines.experimental.async
import java.util.*
interface ILoginRepository {
// Если функции репорзитория всегда планируется запускать из другого треда,
// то разумно позаботиться о том, чтобы они сами для себя решали на каком
@Yazon2006
Yazon2006 / FragmentArg.kt
Created February 20, 2018 07:42
Frgment arg helper
/**
* Eases the Fragment.newInstance ceremony by marking the fragment's args with this delegate
* Just write the property in newInstance and read it like any other property after the fragment has been created
*
* Inspired by Jake Wharton, he mentioned it during his IO/17 talk about Kotlin
*/
class FragmentArg<T : Any?> : kotlin.properties.ReadWriteProperty<Fragment, T?> {
var value: T? = null
@kamikat
kamikat / layout.xml
Last active September 1, 2021 17:40
NestedScrollView + SwipeRefreshLayout + RecyclerView
<android.support.v4.widget.SwipeRefreshLayout
android:id="@+id/refreshLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<android.support.v4.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
@lopspower
lopspower / README.md
Last active June 21, 2024 04:26
Hexadecimal color code for transparency

Hexadecimal color code for transparency

Twitter

How to set transparency with hex value ?

For example, you want to set 40% alpha transparence to #000000 (black color), you need to add 66 like this #66000000.

Download This sample on Google Play Store

@antoniolg
antoniolg / HomeActivity.kt
Last active April 11, 2024 11:03
Snackbar extensions on Kotlin, to create a useful small DSL.
class HomeActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_home)
setSupportActionBar(toolbar)
fab.setOnClickListener {
it.snack("Snack message") {
action("Action") { toast("Action clicked") }
@mjdetullio
mjdetullio / android-sonar.gradle
Last active August 27, 2020 19:53
Configuring Android project for SonarQube
import com.android.build.gradle.AppPlugin
task consolidateJunitXml {
description 'Copies JUnit XML reports into a single directory so SonarQube can import them all'
doLast {
def dest = file("${buildDir}/allJunit")
delete dest
copy {
from "${buildDir}/test-results/debug"
into dest
@lopspower
lopspower / README.md
Last active August 20, 2023 09:32
How to Analyze & Manage Memory on Android Like a Boss

Analyze & Manage Memory on Android Like a Boss

This Blog is all about memory management in Android. It provides information about how you can analyze & reduce memory usage while developing an Android app.

Memory management is a complex field of computer science and there are many techniques being developed to make it more efficient. This guide is designed to introduce you to some of the basic memory management issues that programmers face.

Memory Management in Android

Android is a Linux based operating system. It uses native open source C libraries which power Linux machines. All the basic operating system operations like I/O, memory management and so on are handled by the Linux kernel. Like Java and .NET, Android uses its own run time and virtual machine to manage application memory. Unlike either of these frameworks, the Android run time also manages the lifetime processes. Each Android application runs in a separate process within its own Dalvik instance, relinquishing all responsibility for memo