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 ScaleItemOnTouchListener : RecyclerView.OnItemTouchListener { | |
private var previousX = 0f | |
private var previousY = 0f | |
private var previousMotionX = 0f | |
private var previousMotionY = 0f | |
private object Constants { | |
const val SCALE_DEFAULT = 1f |
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 androidx.recyclerview.widget.GridLayoutManager | |
import androidx.recyclerview.widget.LinearLayoutManager | |
import androidx.recyclerview.widget.RecyclerView | |
import androidx.recyclerview.widget.StaggeredGridLayoutManager | |
fun RecyclerView.attachInfiniteScroll(onLoadMoreListener: OnLoadMoreListener) { | |
if (layoutManager != null) | |
setInfiniteScrollGrid(this, layoutManager!!, onLoadMoreListener) | |
else throw RuntimeException("Layout Manager is Not Set") | |
} |
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
%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 |
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 androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelProvider | |
import kotlin.reflect.full.primaryConstructor | |
class AndroidViewModelFactory(private vararg val args: Any) : | |
ViewModelProvider.NewInstanceFactory() { | |
override fun <T : ViewModel> create(modelClass: Class<T>) = | |
modelClass.kotlin.primaryConstructor?.call(*args) | |
?: throw IllegalArgumentException("$modelClass primaryConstructor is null") |
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 androidx.animation.PhysicsBuilder | |
import androidx.animation.Spring.DampingRatioHighBouncy | |
import androidx.animation.Spring.StiffnessLow | |
import androidx.compose.Composable | |
import androidx.compose.Model | |
import androidx.compose.remember | |
import androidx.ui.animation.animate | |
import androidx.ui.core.DrawClipToBounds | |
import androidx.ui.core.Text | |
import androidx.ui.core.drawLayer |
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.content.SharedPreferences | |
import kotlin.properties.ReadWriteProperty | |
import kotlin.reflect.KProperty | |
abstract class BasePreferencesDataSource { | |
protected abstract val preferences : SharedPreferences | |
protected class StringPrefProperty(private val key: String) : ReadWriteProperty<BasePreferencesDataSource, String> { |
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
/* Coming up ~ April 2020 */ | |
package test | |
import arrow.* | |
inline class TwitterHandle(val handle: String) { | |
companion object : Refined<String> { | |
override val validate: String.() -> Map<String, Boolean> = { | |
mapOf( | |
"Should start with '@'" to startsWith("@"), |
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.mrezanasirloo.ganjeh | |
import android.util.SparseArray | |
import androidx.activity.ComponentActivity | |
import androidx.annotation.MainThread | |
import androidx.fragment.app.Fragment | |
import androidx.fragment.app.createViewModelLazy | |
import androidx.lifecycle.LifecycleOwner | |
import androidx.lifecycle.ViewModel | |
import androidx.lifecycle.ViewModelLazy |
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
# This is for ATV only | |
alias adb-dev-options='adb shell am start -n com.android.tv.settings/.system.development.DevelopmentActivity' | |
# For mobile use: | |
#alias adb-dev-options='adb shell am start -n com.android.settings/.DevelopmentSettings' | |
# Animations | |
alias animations-off='adb shell settings put global animator_duration_scale 0' | |
alias animations-slow='adb shell settings put global animator_duration_scale 10' | |
alias animations-normal='adb shell settings put global animator_duration_scale 1' | |
alias animations-fast='adb shell settings put global animator_duration_scale 0.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
public class FileUtils { | |
/** | |
* @return The MIME type for the given file. | |
*/ | |
public static String getMimeType(File file) { | |
String extension = getExtension(file.getName()).toLowerCase(); | |
if (!TextUtils.isEmpty(extension) && extension.length() > 1) |