Skip to content

Instantly share code, notes, and snippets.

View niusounds's full-sized avatar
🤘

Yuya Matsuo niusounds

🤘
View GitHub Profile
@niusounds
niusounds / LayeredImageView.java
Last active August 29, 2015 13:57
https://gist.github.com/niusounds/7905659 の後にまた作った。複数レイヤーを重ねて表示するView。Layerごとに色相・明るさ・コントラスト・透明度の指定が可能。
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.graphics.Matrix;
@niusounds
niusounds / TwitterLoginDialogFragment.java
Created March 24, 2014 10:35
AndroidAnnotationsとTwitter4jでラクラクTwitter連携
import org.androidannotations.annotations.Background;
import org.androidannotations.annotations.EFragment;
import org.androidannotations.annotations.FragmentArg;
import org.androidannotations.annotations.UiThread;
import twitter4j.Twitter;
import twitter4j.TwitterException;
import twitter4j.TwitterFactory;
import twitter4j.auth.AccessToken;
import twitter4j.auth.RequestToken;
@niusounds
niusounds / GLToolbox.java
Last active August 29, 2015 13:59
Hello OpenGL ES Texture
/*
* Copyright (C) 2012 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
@niusounds
niusounds / MediaExtractorAsync.java
Last active July 25, 2016 21:44
MediaExtractorAsync
import java.io.FileDescriptor;
import java.io.IOException;
import java.nio.ByteBuffer;
import java.util.Map;
import android.content.Context;
import android.media.MediaExtractor;
import android.media.MediaFormat;
import android.net.Uri;
@niusounds
niusounds / HomographyActivity.java
Last active August 29, 2015 14:00
Homography sample
package com.eje_c.matrixtest;
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.os.Bundle;
@niusounds
niusounds / MatrixEvaluator.java
Created May 12, 2014 03:48
Matrix to Matrix implementation
import android.animation.TypeEvaluator;
import android.graphics.Matrix;
public class MatrixEvaluator implements TypeEvaluator<Matrix> {
private Matrix evaluated = new Matrix();
private float[] values = new float[9];
private float[] startValues = new float[9];
private float[] endValues = new float[9];
@Override
@niusounds
niusounds / isMobile.js
Created May 28, 2014 12:49
simple mobile detection
function isMobile() {
return !!navigator.userAgent.match(/(android|iphone|ipad)/i);
};
@niusounds
niusounds / MyAdapter.java
Last active February 16, 2016 20:42
How to simplify RecyclerView.Adapter and RecyclerView.ViewHolder
import android.content.Context;
import org.androidannotations.annotations.EBean;
public class MyAdapter extends SimpleListAdapter<String, TextView> {
public MyAdapter(Context ctx) {
super(ctx);
}
@niusounds
niusounds / MidiChannel.js
Last active August 29, 2015 14:05
JavaのMidiChannelを参考にしたWebMIDIのラッパー
function MidiChannel(midiOutput, channel) {
this.output = midiOutput;
this.channel = channel;
}
MidiChannel.prototype = {
/*
* Channel voice messages
*/
noteOff: function(noteNumber, velocity, timestamp) {
@niusounds
niusounds / bs-modal-center.js
Created August 27, 2014 02:59
Bootstrapのmodalを画面中央に表示するためのAngularJS Directive。要jQuery
angular.module('ModalCenter', []).directive('modalDialog', function($window) {
return {
restrict: 'C',
link: function(scope, element, attrs) {
var win = $($window);
win.on('resize', modalCenter);
function modalCenter() {
element.css('margin-top', (win.height() - element.height()) * 0.5 + 'px');
}
modalCenter();