Instantly share code, notes, and snippets.

View ArmenianIfElseTest.kt
fun main(args: Array<String>) {
val առաջինՊայման: Բուլյան = ճիշտԷ
val երկրորդՊայման: Բուլյան = սխալԷ
val երրորդՊայման: Բուլյան = ճիշտԷ
եթե(առաջինՊայման) {
առաջինՄեթոդ()
} այլապես եթե(երկրորդՊայման) {
երկրորդՄեթոդ()
View VideoFragment.kt
videoMotionLayout.addTransitionListener(object : MotionLayout.TransitionListener {
override fun onTransitionChange(motionLayout: MotionLayout?, startId: Int, endId: Int, progress: Float) {
val mainActivity = activity as MainActivity
mainActivity.mainMotionLayout.progress = Math.abs(progress)
}
override fun onTransitionCompleted(motionLayout: MotionLayout?, currentId: Int) {
}
})
View main_scene.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetEnd="@id/collapsed"
app:constraintSetStart="@id/expanded">
<KeyFrameSet>
<KeyAttribute
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionLayout ... >
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="@+id/bottomNavigationView"
android:layout_width="match_parent"
android:layout_height="55dp"
app:elevation="10dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
View SingleViewTouchableMotionLayout.kt
class SingleViewTouchableMotionLayout(context: Context, attributeSet: AttributeSet? = null) : MotionLayout(context, attributeSet) {
private val viewToDetectTouch by lazy {
findViewById<View>(R.id.videoViewContainer) //TODO move to Attributes
}
private val viewRect = Rect()
private var touchStarted = false
init {
setTransitionListener(object : MotionLayout.TransitionListener {
View activity_main.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/mainMotionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/container"
android:layout_width="match_parent"
View youtube_scene.xml
<?xml version="1.0" encoding="utf-8"?>
<MotionScene xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<Transition
app:constraintSetEnd="@id/expanded"
app:constraintSetStart="@id/collapsed">
<OnSwipe
app:dragDirection="dragUp"/>
View video_fragment.xml
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.motion.widget.MotionLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/videoMotionLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/transparent">
<ImageView
android:id="@+id/videoViewContainer"
View Kotlin Date Iterator
class TestingClass {
fun testingFunction() {
for (everyday in this year 2017) {
// Do something with everyday
println(everyday.toString())
}
}
private infix fun year(year: Int): DateRange {
return Date(year, 1, 1)..Date(year, 12, 31)
View permissions.txt
android.permission.ACCESS_ALL_DOWNLOADS
android.permission.ACCESS_BLUETOOTH_SHARE
android.permission.ACCESS_CACHE_FILESYSTEM
android.permission.ACCESS_CHECKIN_PROPERTIES
android.permission.ACCESS_CONTENT_PROVIDERS_EXTERNALLY
android.permission.ACCESS_DOWNLOAD_MANAGER
android.permission.ACCESS_DOWNLOAD_MANAGER_ADVANCED
android.permission.ACCESS_DRM_CERTIFICATES
android.permission.ACCESS_EPHEMERAL_APPS
android.permission.ACCESS_FM_RADIO