Skip to content

Instantly share code, notes, and snippets.

View momvart's full-sized avatar

Mohammad Omidvar momvart

  • Simon Fraser University
  • BC, Canada
  • LinkedIn in/momvart
View GitHub Profile
@momvart
momvart / StartLinearSmoothScroller.kt
Last active August 3, 2019 07:02
A simple android LinearSmoothScroller which scrolls to put the target item to the top of the RecyclerView
class StartLinearSmoothScroller(context: Context): LinearSmoothScroller(context) {
override fun getVerticalSnapPreference() = SNAP_TO_START
}
//Example
val smoothScroller = StartLinearSmoothScroller(context)
smoothScroller.targetPosition = 0 //replace with your target position
layoutManager.startSmoothScroll(smoothScroller)
@momvart
momvart / ScrollLockableGridLayoutManager.kt
Last active May 3, 2020 10:46
A simple extension of GridLayoutManager which makes it possible to lock/disable/set the read-only scroll properties for your recyclerview
import android.content.Context
import androidx.recyclerview.widget.GridLayoutManager
class ScrollLockableGridLayoutManager(context: Context, spansCount: Int) : GridLayoutManager(context, spansCount) {
var canScrollVertically = true
override fun canScrollVertically(): Boolean =
if (!canScrollVertically) false
else super.canScrollVertically()
@momvart
momvart / EpochConverter.asm
Last active January 29, 2019 06:53
MIPS assembly code that converts epoch to date and time parts
#MIPS equivalent of .NET DateTime.GetDatePart
#https://referencesource.microsoft.com/mscorlib/R/ff06f271f088f1a8.html
.macro push(%value)
addi $sp, $sp, -4
sw %value, 0($sp)
.end_macro
.macro pop(%storeTo)
lw %storeTo, 0($sp)
addi $sp ,$sp, 4