Skip to content

Instantly share code, notes, and snippets.

@NLLAPPS
NLLAPPS / drive.kt
Created June 12, 2024 08:01
Migrating Android Google Drive authorization from Deprecated GoogleSignin API to authorization
import android.app.Activity
import android.content.Context
import android.content.Intent
import android.content.IntentSender.SendIntentException
import androidx.core.app.ActivityCompat.startIntentSenderForResult
import com.google.android.gms.auth.api.identity.AuthorizationRequest
import com.google.android.gms.auth.api.identity.AuthorizationResult
import com.google.android.gms.auth.api.identity.Identity
import com.google.android.gms.common.api.Scope
import com.google.android.gms.tasks.Tasks
@mengdd
mengdd / RecyclerHeadersDecoration.java
Created June 29, 2017 07:54
ItemDecoration for RecyclerView, use View as Header
public class RecyclerHeadersDecoration extends RecyclerView.ItemDecoration {
private HeaderAdapter adapter;
private SparseArray<View> headers;
public interface HeaderAdapter {
boolean hasHeader(int position);
View getHeaderView(int position);
}
@tatocaster
tatocaster / RealPathUtil.java
Last active December 23, 2024 10:34
Real Path Utility class for Android, works for all API
public class RealPathUtil {
public static String getRealPath(Context context, Uri fileUri) {
String realPath;
// SDK < API11
if (Build.VERSION.SDK_INT < 11) {
realPath = RealPathUtil.getRealPathFromURI_BelowAPI11(context, fileUri);
}
// SDK >= 11 && SDK < 19
else if (Build.VERSION.SDK_INT < 19) {
@vedant1811
vedant1811 / Spinner.java
Created January 6, 2015 19:16
Custom Spinner to differentiate between user selected and prorammatically selected item. Make sure to call correct method to use this feature
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.AdapterView;
/**
* Used this to differentiate between user selected and prorammatically selected
* Call {@link Spinner#programmaticallySetPosition} to use this feature.
* Created by vedant on 6/1/15.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8"/>
<uses-permission android:name="android.permission.READ_CONTACTS" />
<application android:label="@string/app_name">