Skip to content

Instantly share code, notes, and snippets.

View hoc081098's full-sized avatar
✝️
Glory to God

Petrus Nguyễn Thái Học hoc081098

✝️
Glory to God
View GitHub Profile
@hoc081098
hoc081098 / MainActivity.kt
Created March 30, 2024 19:30
MainActivity.kt
package com.example.roomdb;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
package com.example.roomdb;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
private void API_Get_List() {
ExecutorService executor = Executors.newSingleThreadExecutor();
Handler handler = new Handler(Looper.getMainLooper());
executor.execute(new Runnable() {
@Override
public void run() {
final StringRequest request = new StringRequest(Request.Method.POST,
@hoc081098
hoc081098 / MainActivity.kt
Created March 30, 2024 16:38
MainActivity.kt
package com.example.roomdb;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import 'dart:async';
extension SplitExtension<T> on Stream<T> {
Stream<T> split() {
final controllers = <MultiStreamController<T>>[];
var index = -1;
var done = false;
StreamSubscription<T> subscription;
return Stream.multi(
public class ChannelsEventBus {
private val _channels = hashMapOf<KClass<*>, Channel<Any>>()
private fun createChannel(key: KClass<*>) = synchronized(this) { _channels.getOrPut(key) { Channel(Channel.UNLIMITED) } }
public fun send(event: Any): Unit = createChannel(event::class).trySend(event).let { }
@Suppress("UNCHECKED_CAST")
public fun <T : Any> receiveAsFlow(type: KClass<T>): Flow<T> = flow {
createChannel(type)
@hoc081098
hoc081098 / proguard-rules.pro
Created October 17, 2023 08:24
proguard-rules.pro
#### Nav
-keepnames class androidx.navigation.fragment.NavHostFragment
-keepnames class * extends android.os.Parcelable
-keepnames class * extends java.io.Serializable
#### OkHttp, Retrofit and Moshi
-dontwarn okhttp3.**
@hoc081098
hoc081098 / rememberIsScrollingUpState.kt
Created August 19, 2023 18:36
rememberIsScrollingUpState.kt
@Composable
private fun LazyListState.rememberIsScrollingUpState(): State<Boolean> {
var previousIndex by remember(this) { mutableIntStateOf(firstVisibleItemIndex) }
var previousScrollOffset by remember(this) { mutableIntStateOf(firstVisibleItemScrollOffset) }
return remember(this) {
derivedStateOf {
if (previousIndex != firstVisibleItemIndex) {
previousIndex > firstVisibleItemIndex
@hoc081098
hoc081098 / NavHost.kt
Created August 18, 2023 09:46
NavHost.kt
@Composable
fun <T: Any> rememberMutableStateListOf(vararg elements: T): SnapshotStateList<T> {
return rememberSaveable(
saver = listSaver(
save = { stateList ->
if (stateList.isNotEmpty()) {
val first = stateList.first()
if (!canBeSaved(first)) {
throw IllegalStateException("${first::class} cannot be saved. By default only types which can be stored in the Bundle class can be saved.")
import 'package:video_player/video_player.dart';
class VideoQuestion extends StatefulWidget {
final String videoUrl;
VideoQuestion({Key? key, required this.videoUrl})
: super(key: key);
@override
State<VideoQuestion> createState() => _VideoQuestionState();