Skip to content

Instantly share code, notes, and snippets.

@vidyesh95
vidyesh95 / sample.json
Created September 25, 2024 07:49
Sample api
{
"version": 1,
"data": {
"1491148717": {
"am": "https://panels-cdn.imgix.net/static/artists/a~adammolina/AdamMolina.jpg?crop=faces%2Ccenter&expires=1728262583176&fit=crop&fm=avif&h=144&w=144&s=0eb2857e5f08fae5a9cda8695a217a4f",
"as": "https://panels-cdn.imgix.net/static/artists/a~adammolina/AdamMolina.jpg?crop=faces%2Ccenter&expires=1728262583176&fit=crop&fm=avif&h=98&w=98&s=bcaee12443f9753e9a4c45b242999b41"
},
"327195036": {
"am": "https://panels-cdn.imgix.net/static/artists/a~anaispays/profile.png?crop=faces%2Ccenter&expires=1728262583176&fit=crop&fm=avif&h=144&w=144&s=4a2e305d849407f27c5e37baaeec9b19",
"as": "https://panels-cdn.imgix.net/static/artists/a~anaispays/profile.png?crop=faces%2Ccenter&expires=1728262583176&fit=crop&fm=avif&h=98&w=98&s=d68bca297305b6a1957445dc6c065786"
@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 March 29, 2024 14:18
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;