Skip to content

Instantly share code, notes, and snippets.

Arman armcha

Block or report user

Report or block armcha

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@armcha
armcha / SimpleDecorator.kt
Last active Mar 18, 2019
Decorator pattern simple exmple
View SimpleDecorator.kt
fun main() {
val capitalizeDec = decorateCapitalize(::capitalize)
val text = capitalizeDec("HeLLo")
print(text)
}
fun capitalize(hello: String): String {
return hello.capitalize()
}
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"
@armcha
armcha / Kotlin Date Iterator
Created Oct 15, 2017 — forked from elye/Kotlin Date Iterator
Kotlin Date Iterator
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)
You can’t perform that action at this time.