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 onClick(view: View) { | |
| val fragmentTransaction = initFragmentTransaction(view) | |
| val copy = createCopyView(view) | |
| root.addView(copy) | |
| view.visibility = View.INVISIBLE | |
| startAnimation(copy, fragmentTransaction) | |
| } |
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
| open class BaseViewHolder<T>(private val binding: ViewDataBinding) : RecyclerView.ViewHolder(binding.root) { | |
| open fun bind(item: T) { | |
| binding.setVariable(BR.obj, item) | |
| } | |
| } |
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
| abstract class BaseRecyclerAdapter<T, VH : BaseViewHolder<T>> : RecyclerView.Adapter<VH>() { | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { | |
| val inflater = LayoutInflater.from(parent.context) | |
| val binding: ViewDataBinding = DataBindingUtil.inflate(inflater, viewType, parent, false) | |
| return createViewHolder(binding) | |
| } | |
| override fun onBindViewHolder(holder: VH, position: Int) { | |
| val obj = getObjectForPosition(position) |
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 createCopyView(view: View): View { | |
| val copy = copyViewImage(view) | |
| // On preLollipop when we create a copy of card view's content its shadow is copied too | |
| // and we do not need additional card view. | |
| return (if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | |
| CardView(view.context).apply { | |
| cardElevation = resources.getDimension(R.dimen.card_elevation) | |
| radius = resources.getDimension(R.dimen.card_corner_radius) |
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
| abstract class BaseAdapter<T, VH : BaseViewHolder<T>> : RecyclerView.Adapter<VH>() { | |
| abstract var dataSet: ArrayList<T> | |
| override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): VH { | |
| val view = parent.inflate(viewType) | |
| return createViewHolder(view) | |
| } | |
| override fun onBindViewHolder(viewHolder: VH, position: Int) { |
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
| class Switcher @JvmOverloads constructor( | |
| context: Context, | |
| attrs: AttributeSet ? = null, | |
| defStyleAttr: Int = 0 | |
| ) : View(context, attrs, defStyleAttr) { | |
| init { | |
| attrs?.let { retrieveAttributes(attrs, defStyleAttr) } | |
| } | |
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
| // ... | |
| var amplitude = BOUNCE_ANIM_AMPLITUDE_IN | |
| var frequency = BOUNCE_ANIM_FREQUENCY_IN | |
| var newProgress = 1f | |
| if (!checked) { | |
| amplitude = BOUNCE_ANIM_AMPLITUDE_OUT | |
| frequency = BOUNCE_ANIM_FREQUENCY_OUT | |
| newProgress = 0f | |
| } |
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 var iconProgress = 0f | |
| set(value) { | |
| if (field != value) { | |
| field = value | |
| val iconOffset = lerp(0f, iconRadius - iconCollapsedWidth / 2, value) | |
| iconRect.left = width - switcherCornerRadius - iconCollapsedWidth / 2 - iconOffset | |
| iconRect.right = width - switcherCornerRadius + iconCollapsedWidth / 2 + iconOffset | |
| postInvalidateOnAnimation() |
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 onDraw(canvas: Canvas ?) { | |
| // draw switcher (green rect) | |
| canvas?.drawRoundRect(switcherRect, switcherCornerRadius, switcherCornerRadius, switcherPaint) | |
| // draw icon (white rect) | |
| canvas?.withTranslation(x = iconTranslateX) { | |
| drawRoundRect(iconRect, switcherCornerRadius, switcherCornerRadius, iconPaint) | |
| } | |
| } |
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 onDraw(canvas: Canvas ?) { | |
| canvas?.withRotation(angle, lightPivotX, lightPivotY) { | |
| drawPath(lightPath, lightPaint) | |
| } | |
| canvas?.drawBitmap(textBitmap, 0f, 0f, textPaint) | |
| } |
OlderNewer