Skip to content

Instantly share code, notes, and snippets.

@harry-private
harry-private / getYoutubeChannelName.js
Created December 8, 2022 07:19
Simple user script for getting channel name
// ==UserScript==
// @name 2 Open youtube channels on Social Blade
// @namespace Violentmonkey Scripts
// @match https://*.youtube.com/*
// @grant none
// @version 1.0
// @author -
// @description This script will open the Youtube channel in the Social Balde
// ==/UserScript==
@harry-private
harry-private / KeepCheckBoxState.kt
Created May 1, 2022 06:26
when you select an item, and you need to put that item in a list, and keep want to keep the state of checkbox
@Composable
fun SomeScreen(){
val selectedItems:List<Type> = remeber {mutableStateOf(listOf())}
val someList:List<SomeType> = stateFromViewModel
LazyColumn(){
Items(selectItems.size){
selectItems.value[it].someProperty
@harry-private
harry-private / SomeComposeFunction.kt
Last active January 23, 2022 18:39
For medium article How to add WebView in Jetpack Comose
@composable
fun SomeComposeFunction(){
val application = context.applicationContext as App
WebView(
"https://www.google.com",
application
)
// For handling the back press
BackHandler {
@harry-private
harry-private / MyWebView.kt
Last active January 23, 2022 18:33
For medium article How to add WebView in Jetpack Comose
@Composable
fun MyWebView(
urlToRender: String,
application: App,
) {
Column {
AndroidView(factory = { context ->
application.myViewFun(context, urlToRender)
}, update = {
@harry-private
harry-private / Application.kt
Created January 23, 2022 18:21
For medium article How to add WebView in Jetpack Comose
var myView: WebView? = null
@SuppressLint("SetJavaScriptEnabled")
fun myWebViewFun(context: Context, urlToRender: String): WebView {
if (myView == null) {
myView = WebView(context).apply {
layoutParams = ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.MATCH_PARENT
)
webViewClient = object : WebViewClient() {
@harry-private
harry-private / MainAcitvity.kt
Last active February 23, 2021 16:51
How can I customize the addToBackStack behavior, when not using navigation, but using supportFragmentManager.beginTransaction()
package com.example.fragment
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import androidx.databinding.DataBindingUtil
import androidx.fragment.app.Fragment
import com.example.fragment.databinding.ActivityMainBinding
enum class FragmentName {
HOME, PROFILE, ABOUT