Skip to content

Instantly share code, notes, and snippets.

👨‍💻

wiki de pasquale diareuse

👨‍💻
Block or report user

Report or block diareuse

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
@diareuse
diareuse / DrawingConfig.kt
Created Sep 13, 2018
Simple config builder to allow fairly easy and boiler-less drawing over bitmap (or drawable)
View DrawingConfig.kt
import android.graphics.Bitmap
import android.graphics.Canvas
import android.graphics.Paint
import android.graphics.Rect
import android.graphics.drawable.Drawable
import android.text.Layout
import android.text.StaticLayout
import android.text.TextPaint
import androidx.core.graphics.drawable.toBitmap
View HelperExtensions.kt
fun View?.isDescendant(container: ViewGroup): Boolean {
this ?: return false
var p: ViewParent? = parent
while (p != null) {
if (p === container) {
return true
}
p = p.parent
}
return false
View NoMotionScrollManager.kt
import android.support.v7.widget.RecyclerView
import android.view.View
import android.view.ViewTreeObserver
import java.lang.ref.WeakReference
class NoMotionScrollManager(
private val allowCyclicRotation: Boolean = false,
private val viewSelector: ViewSelector = { it }
) {
private var recycler: RecyclerView? = null
@diareuse
diareuse / RecyclerViewExtensions.kt
Created Jul 26, 2018
RecyclerView focus orientation
View RecyclerViewExtensions.kt
import android.support.v7.widget.RecyclerView
fun RecyclerView.getViewByPosition(position: Int): View? {
return findViewHolderForAdapterPosition(position)?.itemView
}
fun RecyclerView.fetchViewAt(position: Int, callback: (View?) -> Unit) {
scrollToPosition(position)
post { callback(getViewByPosition(position)) }
}
You can’t perform that action at this time.