Skip to content

Instantly share code, notes, and snippets.

import android.content.Intent
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.util.Log
private const val tag = "2ndShare"
/**
* 1) Clear all the apps
* 2) Go to Google Photos, share image to this app
@vishna
vishna / doOnNextLayout.kt
Created November 23, 2018 13:05
View.doOnNextLayout
// https://android.googlesource.com/platform/frameworks/support/+/androidx-master-dev/core/ktx/src/main/java/androidx/core/view/View.kt
inline fun <T : View> T.doOnNextLayout(crossinline action: (view: T) -> Unit) {
addOnLayoutChangeListener(object : View.OnLayoutChangeListener {
override fun onLayoutChange(
view: View,
left: Int,
top: Int,
right: Int,
bottom: Int,
oldLeft: Int,
@vishna
vishna / better-safe-than-sorry.kt
Created October 4, 2018 15:24
Better safe than sorry
inline fun <T> safe(block: () -> T?) : T? {
return try {
block.invoke()
} catch (t: Throwable) {
null // ¯\_(ツ)_/¯
}
}
@vishna
vishna / debounce-broadcast.kt
Created November 5, 2017 19:38
Debounce input from an EditText and relay to a TextView with a timeout.
package me.vishna.kdebounce
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.android.UI
@vishna
vishna / debounce-broadcast.kt
Created November 5, 2017 19:38
Debounce input from an EditText and relay to a TextView with a timeout.
package me.vishna.kdebounce
import android.support.v7.app.AppCompatActivity
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
import android.widget.EditText
import android.widget.TextView
import kotlinx.coroutines.experimental.*
import kotlinx.coroutines.experimental.android.UI

Privacy Policy

Last revised on 2017-03-11

Fotofall

fotofall for Android

fotofall would like all users to carefully read the information provided. All inquiries are to be directed to: fotofallapp@gmail.com

@vishna
vishna / fotofall-desktop.md
Created November 20, 2015 20:17
Run Fotofall on Desktop (EXPERIMENTAL )
package android.support.design.widget;
import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
/**
* Created by vishna on 04/11/15.
*/
public class AppBarLayoutWorkaroundBehavior extends AppBarLayout.Behavior {
import android.annotation.TargetApi;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.res.Resources;
import android.graphics.Canvas;
import android.media.AudioManager;
import android.media.MediaFormat;
import android.media.MediaPlayer;
import android.net.Uri;
@vishna
vishna / RecyclerUtils.java
Created March 13, 2015 09:47
Missing RecyclerView ScrollListener API
package whatever;
import android.support.v7.widget.RecyclerView;
import java.lang.reflect.Field;
import java.util.HashSet;
/**
* Created by vishna on 28/10/14.
*/