Skip to content

Instantly share code, notes, and snippets.

View virendersran01's full-sized avatar
💻
Working from home

Virender Srxn virendersran01

💻
Working from home
  • India
View GitHub Profile
@virendersran01
virendersran01 / SliceMenu.kt
Created December 1, 2024 02:16 — forked from ardakazanci/SliceMenu.kt
Slice Menu in Jetpack Compose
@Composable
fun SliceMenu(modifier: Modifier = Modifier, onSliceClick: (Int) -> Unit) {
val slices = 6
val colors = listOf(
Brush.linearGradient(listOf(Color(0xFFFF1744), Color(0xFFFFC400))),
Brush.linearGradient(listOf(Color(0xFF1A237E), Color(0xFF2962FF))),
Brush.linearGradient(listOf(Color(0xFF00C853), Color(0xFF64DD17))),
Brush.linearGradient(listOf(Color(0xFFFF6D00), Color(0xFFFFAB00))),
Brush.linearGradient(listOf(Color(0xFFD500F9), Color(0xFF6200EA))),
Brush.linearGradient(listOf(Color(0xFF00BFA5), Color(0xFF00E5FF)))
@virendersran01
virendersran01 / Maze.kt
Created November 26, 2024 12:20 — forked from ardakazanci/Maze.kt
Maze Generator Jetpack Compose
enum class CellType {
Space, Wall
}
data class MazeTile(val x: Int, val y: Int, var type: CellType = CellType.Wall)
@RequiresApi(Build.VERSION_CODES.VANILLA_ICE_CREAM)
class Maze(private val width: Int, private val height: Int) {
val maze: Array<Array<MazeTile>> = Array(height) { y ->
Array(width) { x -> MazeTile(x, y) }
@virendersran01
virendersran01 / AnimatedTextSwitcher.kt
Created June 29, 2024 06:38 — forked from ardakazanci/AnimatedTextSwitcher.kt
Animated Text in Jetpack Compose
@Composable
fun AnimatedTextSwitcher() {
var isYellowBoxVisibility by remember { mutableStateOf(true) }
LaunchedEffect(Unit) {
while (true) {
delay(3000)
isYellowBoxVisibility = !isYellowBoxVisibility
}
}
@virendersran01
virendersran01 / ExtNavController.kt
Created June 23, 2024 14:41 — forked from ImaginativeShohag/ExtNavController.kt
"MainActivity.kt" example indicates that calling `navigateUp()` multiple times will recreate the `Activity`. To solve the black issue 2 extension function given in "ExtNavController.kt" file.
import android.app.Activity
import android.content.Context
import androidx.lifecycle.Lifecycle
import androidx.navigation.NavController
/**
* Attempts to pop the controller's back stack.
* If the back stack is empty, it will finish the activity.
*
* @param context Activity context.
<application
android:name=".di.Application"
android:icon="${appIcon}"
android:roundIcon="${appIcon}"
....
</aplication>
@virendersran01
virendersran01 / setPlaceHolders.gradle
Created February 5, 2024 01:26 — forked from giovanileitevitor/setPlaceHolders.gradle
Setting a manifestPlaceHolders
buildTypes {
release {
minifyEnabled false
shrinkResources false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
testCoverageEnabled false
manifestPlaceholders = [
appIcon: "@mipmap/ic_release"
]
}
@virendersran01
virendersran01 / Speedometer.kt
Created October 30, 2023 13:09 — forked from saurabharora90/Speedometer.kt
Speedometer in Jetpack Compose
import androidx.annotation.FloatRange
import androidx.compose.animation.core.Animatable
import androidx.compose.animation.core.LinearOutSlowInEasing
import androidx.compose.animation.core.tween
import androidx.compose.foundation.Canvas
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredSize
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Slider
@virendersran01
virendersran01 / ConcurrencyHelpers.kt
Created October 26, 2023 13:05 — forked from objcode/ConcurrencyHelpers.kt
Helpers to control concurrency for one shot requests using Kotlin coroutines.
/* Copyright 2019 The Android Open Source Project
*
* 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
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
@virendersran01
virendersran01 / NetworkModule.kt
Created October 8, 2023 13:52 — forked from whytarun/NetworkModule.kt
Including support for TLS/SSL
@Singleton
@Provides
fun provideOkhttpClient(authInterceptor: AuthInterceptor,
certificateHelper: CertificateHelper
) :OkHttpClient{
val trustManagers = certificateHelper.createTrustManagers()
val sslContext = SSLContext.getInstance("TLS")
sslContext.init(null, trustManagers, null)
return OkHttpClient().newBuilder()
.readTimeout(2, TimeUnit.MINUTES)