Skip to content

Instantly share code, notes, and snippets.

View shahzadafridi's full-sized avatar

Shahzad Afridi shahzadafridi

View GitHub Profile
@10zgurr
10zgurr / AppPermissionsExtension.kt
Last active November 7, 2022 11:29
AppPermissionsExtension
# your package name
import android.Manifest
import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.net.Uri
import android.os.Build
import android.provider.Settings
import android.util.Log
@shahzadafridi
shahzadafridi / database.rules.json
Created April 10, 2020 15:55 — forked from codediodeio/database.rules.json
Common Database Rules for Firebase
// No Security
{
"rules": {
".read": true,
".write": true
}
}
@Kolyall
Kolyall / FavMainAdapter.kt
Last active February 2, 2022 16:43
FragmentStatePagerAdapter
class FavMainAdapter constructor(
val context: Context?,
fragmentManager: FragmentManager
) : BaseFragmentPagerAdapter(fragmentManager) {
override fun createItem(position: Int): BaseFragment {
return when (position) {
0 -> MyCollectionsFragment()
1 -> MyPlaylistsFragment()
else -> throw IndexOutOfBoundsException("IndexOutOfBounds $position")
@mandybess
mandybess / ItemDecoration.java
Last active April 6, 2024 09:56
RecyclerView extension that "sticks" items in the center on scroll
import android.graphics.Rect;
import android.support.v7.widget.RecyclerView;
import android.view.View;
public class ItemDecoration extends RecyclerView.ItemDecoration {
/**
*
* {@link #startPadding} and {@link #endPadding} are final and required on initialization
* because {@link android.support.v7.widget.RecyclerView.ItemDecoration} are drawn
@emoralest
emoralest / LocationService.java
Created April 10, 2015 03:53
The best way for get location in background service in Android
/*
* LocationService
* La mejor forma de obtener Lat y Long dependiendo el proveedor.
* Usando un BroadcastReceiver para la obtención de location
*
* import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;