This file contains hidden or 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
data class Data( | |
val id: Int, | |
var rotated: Boolean = false | |
) |
This file contains hidden or 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
override fun onBindViewHolder(holder: ViewHolder, position: Int) { | |
val dataItem = data[position] | |
holder.textView.text = dataItem.id.toString() | |
holder.textView.animate().rotation( | |
if (dataItem.rotated) 180.0f else 0.0f | |
).setDuration(400).start() | |
} |
This file contains hidden or 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
private fun flipRotation(adapter: Adapter) { | |
val newList = adapter.data.mapIndexed { i, data -> | |
if (i == 0) data.copy(rotated = data.rotated.not()) else data | |
} | |
} |
This file contains hidden or 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.example.ui.views | |
import android.content.Context | |
import android.util.AttributeSet | |
import android.view.GestureDetector | |
import android.view.MotionEvent | |
import android.widget.FrameLayout | |
typealias TapListener = () -> Unit |