Skip to content

Instantly share code, notes, and snippets.

View syntaxxxxx's full-sized avatar

Fiqri Hafzain Islami syntaxxxxx

View GitHub Profile
@syntaxxxxx
syntaxxxxx / Event.kt
Created August 19, 2022 13:09 — forked from JoseAlcerreca/Event.kt
An event wrapper for data that is exposed via a LiveData that represents an event.
/**
* Used as a wrapper for data that is exposed via a LiveData that represents an event.
*/
open class Event<out T>(private val content: T) {
var hasBeenHandled = false
private set // Allow external read but not write
/**
* Returns the content and prevents its use again.
qiscusMultichannelWidget.setUser(
profile?.id ?: "0",
"${profile?.firstName} ${profile?.lastName}",
""
)
qiscusMultichannelWidget.initiateChat().setChannelId(125149).startChat(
requireContext(),
object : QiscusChatRoomBuilder.InitiateCallback {
override fun onProgress() {
@syntaxxxxx
syntaxxxxx / EndlessRecyclerViewScrollListener.java
Created February 8, 2022 07:25 — forked from rogerhu/EndlessRecyclerViewScrollListener.java
Endless RecyclerView scrolling for different layout managers
public abstract class EndlessRecyclerViewScrollListener extends RecyclerView.OnScrollListener {
// The minimum amount of items to have below your current scroll position
// before loading more.
private int visibleThreshold = 5;
// The current offset index of data you have loaded
private int currentPage = 0;
// The total number of items in the dataset after the last load
private int previousTotalItemCount = 0;
// True if we are still waiting for the last set of data to load.
private boolean loading = true;
@syntaxxxxx
syntaxxxxx / Contact.java
Created February 8, 2022 06:56 — forked from rogerhu/Contact.java
Endless scrolling with RecyclerVIew
package codepath.com.recyclerviewfun;
import java.util.ArrayList;
import java.util.List;
public class Contact {
private String mName;
private boolean mOnline;
public Contact(String name, boolean online) {