Skip to content

Instantly share code, notes, and snippets.

package com.redplanet.tune.ui.decorations
import android.graphics.Rect
import android.support.annotation.Px
import android.support.v7.widget.GridLayoutManager
import android.support.v7.widget.RecyclerView
import android.view.View
class GridOffsetItemDecoration(@param:Px private val spacing: Int,
private val shouldIncludeEdge: Boolean) : RecyclerView.ItemDecoration() {
object GoogleApiAvailabilityHelper {
private const val REQUEST_CODE_GOOGLE_AVAILABILITY = 999
fun checkAvailability(activity: Activity): Boolean {
val googleApiAvailability = GoogleApiAvailability.getInstance()
val statusCode = googleApiAvailability.isGooglePlayServicesAvailable(activity)
val isResultSuccess = statusCode == ConnectionResult.SUCCESS
class LocationRequestHelper(private val context: Context,
private val locationRequest: LocationRequest,
lifecycle: Lifecycle,
private val onResult: (LocationResult) -> Unit) : LifecycleObserver {
private val locationClient by lazy { FusedLocationProviderClient(context) }
private val settingsClient by lazy { LocationServices.getSettingsClient(context) }
private val locationSettingRequest by lazy {
LocationSettingsRequest.Builder()
@iosandroiddev
iosandroiddev / DialogExtensions.kt
Created July 8, 2020 06:37 — forked from oakkub/DialogExtensions.kt
Kotlin extension functions for creating AlertDialog in a DSL way
import android.annotation.SuppressLint
import android.app.Activity
import android.app.AlertDialog
import android.content.Context
import android.support.annotation.StringRes
import android.support.v4.app.Fragment
import android.view.LayoutInflater
import android.view.View
import android.widget.Button
import android.widget.TextView
@iosandroiddev
iosandroiddev / CoroutineLifecycleObserver.kt
Created July 8, 2020 06:36 — forked from oakkub/CoroutineLifecycleObserver.kt
LifecycleObserver which allows easy cancelling of coroutines
/*
* Copyright 2018 Google LLC
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@iosandroiddev
iosandroiddev / README.md
Created April 13, 2018 10:43 — forked from claudijo/README.md
An Android view for typewriting-like animations

TypewriterView

An Android view that can be used to sequentially animate typing and deleting one character at a time. Pausing and enqueuing arbitrary Runnables is also possible. Inspired by Devunwired @ Stackoverflow (see http://stackoverflow.com/questions/6700374/android-character-by-character-display-text-animation).

An EditText view has been used as base to get a blinking cursor. This has the drawback that the user could edit the text while it is animating. Minimum changes to the code are required to instead use a TextView as base if that is an issue.

Example

TypewriterView typewriterView = (TypewriterView) view.findViewById(R.id.typewriter);
@iosandroiddev
iosandroiddev / PatternEditableBuilder.java
Created February 23, 2018 08:49 — forked from nesquena/PatternEditableBuilder.java
PatternEditableBuilder - Easy way to create colored clickable spans within a TextView!
import android.text.SpannableStringBuilder;
import android.text.Spanned;
import android.text.TextPaint;
import android.text.method.LinkMovementMethod;
import android.text.style.ClickableSpan;
import android.view.View;
import android.widget.TextView;
import java.util.ArrayList;
import java.util.regex.Matcher;
import android.content.Intent;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.provider.MediaStore;
import android.support.v7.widget.Toolbar;
import android.view.Menu;
import android.view.MenuItem;
import com.goparties.gpuser.util.CropImageView;
import java.io.IOException;
import butterknife.Bind;
@iosandroiddev
iosandroiddev / MemoryMappedDataConsumer.h
Created November 29, 2012 08:58 — forked from nielsbot/MemoryMappedDataConsumer.h
memory mapped core graphics data consumer for writing PDFs
#import <Foundation/Foundation.h>
#import <CoreGraphics/CoreGraphics.h>
@interface MemoryMappedDataConsumer : NSObject
@property ( nonatomic, readonly ) size_t size ;
@property ( nonatomic, readonly ) size_t capacity ;
@property ( nonatomic, readonly ) CGDataConsumerRef CGDataConsumer ;
@property ( nonatomic, readonly, copy ) NSURL * url ;