Skip to content

Instantly share code, notes, and snippets.

View BracketCove's full-sized avatar

Ryan BracketCove

  • Victoria, BC, Canada
View GitHub Profile
@BracketCove
BracketCove / OrderOfExecution.kt
Created October 29, 2022 21:46
An example of the order in which computer programs are executed.
//take two Integers, a and b, and give me the result of adding them as an Integer
fun add(a: Int, b: Int): Int {
return a + b
}
//The computer begins reading at the line below this comment
fun main() {
val result = add(1, 2)
println(result)
}
@BracketCove
BracketCove / LoadingSpinner.kt
Created October 21, 2022 16:17
Easy animated loading spinner with Glide (or whatever image loading library)
//use this in your Recyclerview or whereever for asynchornous image loading
Glide.with(holder.itemView.context)
.load(avatarUrl)
.centerCrop()
.placeholder(
CircularProgressDrawable(holder.itemView.context).apply {
setColorSchemeColors(
ContextCompat.getColor(holder.itemView.context, R.color.colorPrimary)
)
public class TodoAdapter extends RecyclerView.Adapter<TodoAdapter.CustomViewHolder> {
private LayoutInflater inflater;
private List<Todo> listData;
private ItemClickCallback itemClickCallback;
public TodoAdapter (List<Todo> listData, Context c){
inflater = LayoutInflater.from(c);
this.listData = listData;
}