Skip to content

Instantly share code, notes, and snippets.

View esmasui's full-sized avatar

Sosuke Masui esmasui

View GitHub Profile
@esmasui
esmasui / gist:7348920
Created November 7, 2013 04:21
Fragment unit test
package com.uphyca.fragmenttest;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.app.FragmentManager;
import android.test.ActivityUnitTestCase;
import android.view.LayoutInflater;
From b2dd2a804ad2030b4a92d8ee8b9bf8129b1eee70 Mon Sep 17 00:00:00 2001
From: ianhanniballake <ian.hannibal.lake@gmail.com>
Date: Tue, 21 May 2013 12:04:16 -0700
Subject: [PATCH] Adds ActionBarDrawerToggle compatible with ActionBarSherlock
Signed-off-by: ianhanniballake <ian.hannibal.lake@gmail.com>
---
actionbarsherlock/libs/android-support-v4.jar | Bin 271754 -> 484258 bytes
.../src/com/actionbarsherlock/app/ActionBar.java | 14 +
.../app/ActionBarDrawerToggle.java | 441 +++++++++++++++++++++
@esmasui
esmasui / ExampleUnitTest.java
Created September 14, 2016 09:55
UnitTestで@smallTestとかでフィルターする例
package com.example;
import android.test.suitebuilder.annotation.SmallTest;
import org.junit.Test;
import org.junit.runner.RunWith;
import static org.junit.Assert.*;
/**
@esmasui
esmasui / gist:f00e255e60a69e20a1c0
Created February 29, 2016 10:47
Androidのテストでクリップボードから貼り付ける
// ペーストのショートカットCtrl+Vを打鍵すればおk
// Espresso
Instrumentation instrumentation = InstrumentationRegistry.getInstrumentation();
instrumentation.sendKeySync(new KeyEvent(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_V, 0, KeyEvent.META_CTRL_ON));
instrumentation.sendKeySync(new KeyEvent(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(), KeyEvent.ACTION_UP, KeyEvent.KEYCODE_V, 0, KeyEvent.META_CTRL_ON));

//uiautomator
UiDevice device = UiDevice.getInstance(InstrumentationRegistry.getInstrumentation());
device.pressKeyCode(KeyEvent.KEYCODE_V, KeyEvent.META_CTRL_ON);
@esmasui
esmasui / gist:8555828
Created January 22, 2014 09:22
Resources.getIdentifier()
String packageName = "com.example.app"; // アプリケーションのパッケージ名(AndroidManifestに書くやつ)
int identifier = context.getResources()
.getIdentifier("foo", "id", packageName);
@esmasui
esmasui / gist:8555713
Created January 22, 2014 09:12
Context.getResourceName()
Context context = ...
String name = context.getResources().getResourceName(R.id.action_bar);
var backing = MOON.getCurrentPage().backing;
var paper = MOON.getPaperJSON(backing);
var white = -1;
var penColor = (0x00aaff | (0xff000000));
var pressure = 0.5;
paper.color = white;
paper.strokes = [];
@esmasui
esmasui / gist:6386316
Created August 30, 2013 04:28
MOONBlockのdiff MOONPhase2.4.1 > 2.5.0
diff --git a/App/MOONBlock/js/block.enchant.js b/App/MOONBlock/js/block.enchant.js
index 499ed94..ddcb39e 100755
--- a/App/MOONBlock/js/block.enchant.js
+++ b/App/MOONBlock/js/block.enchant.js
@@ -1620,6 +1620,11 @@ enchant.block.BlockLabel = enchant.Class.create(enchant.Label, {
initialize: function(text) {
enchant.Label.call(this, text);
},
+ _update: function() {
+ var metrics = this.getMetrics(this.text);
test( "pressure", function() {
var backing = MOON.getCurrentPage().backing;
var paper = MOON.getPaperJSON(backing);
//console.log(paper);
paper.strokes = [];
var pressure = 1.0;
var w = paper.width;
@esmasui
esmasui / gist:6326571
Last active December 21, 2015 15:28
enchantMOONのローカルストレージに数値以外を保持する
/*
* Copyright (C) 2013 uPhyca Inc.
*
* 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