Skip to content

Instantly share code, notes, and snippets.

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

Seyyed davud hosseiny DHosseiny

🏠
Working from home
View GitHub Profile
@DHosseiny
DHosseiny / DataStoreExts.kt
Last active November 9, 2021 07:57
DataStore Delegation
import androidx.datastore.core.DataStore
import androidx.datastore.preferences.core.Preferences
import androidx.datastore.preferences.core.edit
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.DelicateCoroutinesApi
import kotlinx.coroutines.GlobalScope
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.launch
import kotlinx.coroutines.runBlocking
@DHosseiny
DHosseiny / DeleteBuildFolders.bat
Last active June 8, 2020 11:25
Runnable Kotlin Script example with windows batch(double click .bat file to run) -- This example Searches all neighbor folders for android projects and deletes project and it's modules "build" folders(For reducing disk size). *need one time set "kotlinc" enviroment variable(See comments for guidance).
%kotlinc% -script DeleteBuildFolders.kts -- -dir .
:: "." is default path you can change it to any folder you want to work on that folder ^
:: (script workes on current folder without "-dir" argument)"
:: "^" can be used for multiline commands
@DHosseiny
DHosseiny / Theme.kt
Created March 28, 2020 11:16
Theme Switcher Code snippets
class Theme : BaseObservable() {
@Bindable val colorPrimary: String = "colorPrimary"
@Bindable val colorPrimaryDark: String = "colorPrimaryDark"
...
}
@DHosseiny
DHosseiny / BaseAdapter.java
Created February 16, 2018 08:12
Databinding BaseAdapter based on george mount's medium post.
import android.databinding.DataBindingUtil;
import android.databinding.ViewDataBinding;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
/**
* Created by Davud. MyApplication project.
*/
@ph0b
ph0b / build.gradle
Last active February 12, 2023 07:45
sample build.gradle for generating split APKs per ABI
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig{
minSdkVersion 14
targetSdkVersion 21
versionCode 101