Skip to content

Instantly share code, notes, and snippets.

@mediavrog
mediavrog / IconizedMenu.java
Last active Jan 14, 2022
Android Compatibility popup menu with icons (requires support library v7)
View IconizedMenu.java
/**
* Seems like the only way to use it currently (as of 10/2018) is through reflection
* see https://resocoder.com/2018/02/02/popup-menu-with-icons-android-kotlin-tutorial-code/
**/
package com.vuzz.snapdish.ui;
import android.content.Context;
import android.support.v7.internal.view.SupportMenuInflater;
import android.support.v7.internal.view.menu.MenuBuilder;
@mediavrog
mediavrog / gist:49c4f809dffea4e00738a7f5e3bbfa59
Last active Mar 22, 2021
CORS in Google Cloud Functions for Firebase
View gist:49c4f809dffea4e00738a7f5e3bbfa59
const cors = require('cors')({origin: true});
exports.sample = functions.https.onRequest((req, res) => {
cors(req, res, () => {
res.send('Passed.');
});
});
@mediavrog
mediavrog / gist:5625602
Last active Dec 1, 2020
Filter out Intents you don"t want to show from a IntentChooser dialog. For example your own app, competing apps or just apps you have a share integration by SDK already :) Based on http://stackoverflow.com/questions/5734678/custom-filtering-of-intent-chooser-based-on-installed-android-package-name/8550043#8550043
View gist:5625602
// Usage:
// blacklist
String[] blacklist = new String[]{"com.any.package", "net.other.package"};
// your share intent
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "some text");
intent.putExtra(android.content.Intent.EXTRA_SUBJECT, "a subject");
// ... anything else you want to add
// invoke custom chooser
@mediavrog
mediavrog / JapaneseCharacter.java
Last active Aug 26, 2020
Simple string conversion from Hiragana to Katakana and vice versa. Uses the JapaneseCharacter class from Duane J. May and combines it with a simple Utility class method to perform the actual conversion.
View JapaneseCharacter.java
/**
* JapaneseCharacter contains static functions to do various tests
* on characters to determine if it is one of the various types of
* characters used in the japanese writing system.
* <p/>
* There are also a functions to translate between Katakana, Hiragana,
* and Romaji.
*
* @author Duane J. May <djmay@mayhoo.com>
* @version $Id: JapaneseCharacter.java,v 1.2 2002/04/20 18:10:24 djmay Exp $
@mediavrog
mediavrog / EditText.xml
Created Jun 4, 2014
Cursor not visible in EditText in Jelly Bean - this happens if you set a background for the field; to fix it, set the cursorDrawable to @null. Always use this combination when using custom backgrounds.
View EditText.xml
<EditText
android:id="@+id/my_edit_text"
...
android:background="@drawable/some_bg"
android:textCursorDrawable="@null" />
@mediavrog
mediavrog / main.js
Created Oct 24, 2016
Simple bootstrapping for a VueJS app with I18n, Routing and http client
View main.js
// VueJS with Router, I18n and simple http client
import Vue from "vue"
import VueI18n from "vue-i18n"
import VueRouter from "vue-router"
import VueResource from 'vue-resource'
// 2 pages for the app states
import Splash from "./pages/Splash.vue"
import Main from "./pages/Main.vue"
import App from "./App.vue"
// i18n strings
@mediavrog
mediavrog / compile-volley
Created Aug 22, 2013
Compile Google Volley to JAR
View compile-volley
$ git clone https://android.googlesource.com/platform/frameworks/volley
$ cd volley
$ android update project -p .
$ ant jar
// Then, copy bin/volley.jar into your libs/ folder and off you go!
@mediavrog
mediavrog / issue_template.md
Created May 1, 2017
Default issue template at AIR
View issue_template.md

Expected behaviour

Actual behaviour

Steps to reproduce the behaviour

@mediavrog
mediavrog / PULL_REQUEST_TEMPLATE.md
Last active May 1, 2017
Default Pull Request template for AIR.
View PULL_REQUEST_TEMPLATE.md

Fixes #

Changes proposed in this PR

Review requested by @