Skip to content

Instantly share code, notes, and snippets.

View arunkumar9t2's full-sized avatar

Arunkumar arunkumar9t2

View GitHub Profile
<link rel="import" href="../core-menu/core-submenu.html">
<link rel="import" href="../core-item/core-item.html">
<polymer-element name="my-element">
<template>
<style>
:host {
position: absolute;
width: 100%;
<transitionSet xmlns:android="http://schemas.android.com/apk/res/android"
android:transitionOrdering="sequential">
<changeBounds>
<targets>
<target android:targetId="@+id/image" />
</targets>
</changeBounds>
<fade>
<targets>
<target android:targetId="@+id/text" />
constraintLayout.prepareTransition {
auto {
standardEasing()
exclude(metamorphosisDesc2)
}
transitionSet {
fade()
slide()
accelerateEasing()
+metamorphosisDesc2
snackbarConstraintLayout.prepareTransition {
moveResize { // Move resize uses ChangeBounds
+fab
}
slide {
+snackbarMessage
}
decelerateEasing()
}
snackbarMessage.toggleGone()
rootCoordinatorLayout.prepareTransition {
onStart {
// Started!
}
moveResize {
+image1
}
onEnd {
// I am done :)
}
constraintLayout.prepareTransition {
customTransition<ChangeCardColor> {
+colorChangeCardView
}
}
rootLayout.prepareTransition {
moveResize {
+image1 // Using + operator to add targets
}
fade {
+text
}
}
text.isGone = true // Layout changes
@arunkumar9t2
arunkumar9t2 / PreferencesX.kt
Last active September 6, 2023 15:20
Android PreferenceScreen DSL for using with androidx.preference framework.
@file:Suppress("NOTHING_TO_INLINE")
import android.content.Context
import androidx.annotation.StringRes
import androidx.fragment.app.Fragment
import androidx.preference.*
/**
* DSL marker for restricting access scope when [PreferencesBuilder.preference] is nested.
*/
val AppCompatActivity.hasSourceBounds: Boolean get() = intent?.sourceBounds != null
fun AppCompatActivity.sourceBounds(boundsAction: (Rect) -> Unit) {
intent?.sourceBounds?.let(boundsAction)
}
/**
* Disables upcoming transition when [hasSourceBounds] is true. Should be called before [AppCompatActivity.onCreate]
*/
fun AppCompatActivity.preAnimationSetup() {
@arunkumar9t2
arunkumar9t2 / Gradle block IDE builds.groovy
Created February 27, 2020 14:06
A gradle task that blocks Android builds started from IDE and copies the command to clipboard to quickly start build from terminal. Works only on Max
def validateIdeBuilds = tasks.register("validateIdeBuilds") {
doLast {
if (project.hasProperty("android.injected.invoked.from.ide")) {
def buildCommand = "./gradlew " + gradle.startParameter.taskNames.join(" ")
exec {
commandLine("sh", "-c", "echo \"$buildCommand\" | pbcopy")
}
throw new RuntimeException(
"Please avoid building from IDE and use commandLine instead." +
"The command has been copied to your clipboard"