Skip to content

Instantly share code, notes, and snippets.

@ltbaogt
ltbaogt / OpenSSL AES
Last active August 10, 2017 07:45 — forked from rrsdev/.groovy
Groovy/Java based OpenSSL AES implementation.
package my.crypto
import groovy.transform.CompileStatic
import javax.crypto.Cipher
import javax.crypto.spec.IvParameterSpec
import javax.crypto.spec.SecretKeySpec
import java.security.MessageDigest
import java.security.SecureRandom
import static java.nio.charset.StandardCharsets.*
public class FileUtil {
public static File getPickedPictureFile(Context context, Uri selectedImage) {
final boolean isKitKat = Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT;
// DocumentProvider
if (isKitKat && DocumentsContract.isDocumentUri(context, selectedImage)) {
// ExternalStorageProvider
if (isExternalStorageDocument(selectedImage)) {
@ltbaogt
ltbaogt / FirebaseDataReceiver.java
Created July 26, 2017 02:51 — forked from Antarix/FirebaseDataReceiver.java
Firebase Android Sample for managing notification
import android.content.Context;
import android.content.Intent;
import android.support.v4.content.WakefulBroadcastReceiver;
import android.util.Log;
/**
* This is called whenever app receives notification
* in background/foreground state so you can
* apply logic for background task, but still Firebase notification
* will be shown in notification tray
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="15dp"
android:orientation="vertical">
@ltbaogt
ltbaogt / CollapsingToolbarLayout.xml
Last active May 19, 2017 07:06 — forked from iPaulPro/include_list_viewpager.xml
CollapsingToolbarLayout with TabLayout
<?xml version="1.0" encoding="utf-8"?><!--
~ Copyright (C) 2015 The Android Open Source Project
~
~ 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