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
object UIJobScheduler { | |
private const val MAX_JOB_TIME_MS: Float = 4f | |
private var elapsed = 0L | |
private val jobQueue = ArrayDeque<() -> Unit>() | |
private val isOverMaxTime get() = elapsed > MAX_JOB_TIME_MS * 1_000_000 | |
private val handler = Handler() | |
fun submitJob(job: () -> Unit) { | |
jobQueue.add(job) |
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 SmoothListAdapter(val context: Context) : ListAdapter<ListItem, ListItemViewHolder>(MyDiffCallback()) { | |
data class ListItem(val id: String, val text: String) | |
class ListItemViewHolder(view: View) : ViewHolder(view) { | |
fun populateFrom(listItem: ListItem) { | |
//TODO: populate your view | |
} | |
} |
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
/* | |
* Copyright (C) 2015 Jake Wharton | |
* Modified work Copyright 2019 Phil Olson | |
* | |
* Licensed under the Apache License, Version 2.0 (the "License"); | |
* you may not use this file except in compliance with the License. | |
* You may obtain a copy of the License at | |
* | |
* http://www.apache.org/licenses/LICENSE-2.0 | |
* |
NewerOlder