Skip to content

Instantly share code, notes, and snippets.

View vidyesh95's full-sized avatar
:octocat:
Hello

Vidyesh Churi vidyesh95

:octocat:
Hello
View GitHub Profile
@vidyesh95
vidyesh95 / BackgroundBlur.kt
Created February 14, 2024 21:03
Compose background shadow for white icon
// Entire Background
Icon(
modifier = Modifier
.align(alignment = Alignment.TopEnd)
.padding(top = 8.dp, end = 6.dp)
.size(24.dp)
.drawBehind {
val shadowColor = Color.Black
.copy(alpha = 0.25f)
.toArgb()
// Register the permissions callback, which handles the user's response to the system
// permissions dialog. Save the return value, an instance of ActivityResultLauncher.
// You can use either a val, as shown in this snippet, or a lateinit var in your onAttach() or
// onCreate() method.
private val requestPermissionLauncher = registerForActivityResult(
ActivityResultContracts.RequestPermission()
) { isGranted ->
if (isGranted) {
// Permission is granted. Continue the action or workflow in your app.
Log.i("asdf", "Permission granted")
@vidyesh95
vidyesh95 / Color.kt
Last active February 10, 2023 13:52
Material design color palettes for android compose
package com.<company-name>.<app-name>.ui.theme
import androidx.compose.ui.graphics.Color
val Red50 = Color(0xFFFFEBEE)
val Red100 = Color(0xFFFFCDD2)
val Red200 = Color(0xFFEF9A9A)
val Red300 = Color(0xFFE57373)
val Red400 = Color(0xFFEF5350)
val Red500 = Color(0xFFF44336)
class MainActivity : ComponentActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContent {
MyApp()
}
}
}
@Composable
@vidyesh95
vidyesh95 / MainActivity.java
Last active April 14, 2023 21:28
How to create carousel viewpager2 or infinite loop/endless scroll in android viewpager2
public class MainActivity extends AppCompatActivity {
ViewPager2 viewPager2;
private Handler headerHandler = new Handler();
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
@vidyesh95
vidyesh95 / MainActivity.java
Created February 22, 2020 15:50
Check whether device is receiving data or not always while app is running...
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.coordinatorlayout.widget.CoordinatorLayout;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkRequest;
import android.os.Build;
import android.os.Bundle;