Skip to content

Instantly share code, notes, and snippets.

View zaki50's full-sized avatar

Makoto Yamazaki zaki50

View GitHub Profile
$ diff -Nur 22.1.0 22.1.1
diff -Nur 22.1.0/android/support/v4/view/LayoutInflaterCompatHC.java 22.1.1/android/support/v4/view/LayoutInflaterCompatHC.java
--- 22.1.0/android/support/v4/view/LayoutInflaterCompatHC.java 2015-04-20 18:55:38.000000000 +0900
+++ 22.1.1/android/support/v4/view/LayoutInflaterCompatHC.java 2015-04-23 18:58:12.000000000 +0900
@@ -49,7 +49,16 @@
final LayoutInflater.Factory2 factory2 = factory != null
? new FactoryWrapperHC(factory) : null;
inflater.setFactory2(factory2);
- forceSetFactory2(inflater, factory2);
+
@zaki50
zaki50 / RealmUtils.java
Last active August 29, 2015 14:19
Realm インスタンスを取得するためのユーティリティクラスはこんな感じか? Application#onCreate() で setupDatabase() を呼んで、 Activity/Fragment#onCreate() で getRealm() して onDestroy() で Realm#close()
import android.content.Context;
import java.io.File;
import io.realm.Realm;
import io.realm.RealmMigration;
import io.realm.exceptions.RealmMigrationNeededException;
public class RealmUtils {
Applicati
@zaki50
zaki50 / studio.vmoptions
Created December 9, 2014 13:05
今使ってる ~/Library/Preferences/AndroidStudio/studio.vmoptions
-Xms2048m
-Xmx2048m
-XX:MaxPermSize=768m
-XX:ReservedCodeCacheSize=256m
-XX:+UseCodeCacheFlushing
-XX:+UseCompressedOops
// Google Plus
compile "com.google.android.gms:play-services-plus:6.5.+"
// Google Account Login
compile "com.google.android.gms:play-services-identity:6.5.+"
// Google Activity Recognition
compile "com.google.android.gms:play-services-location:6.5.+"
// Google App Indexing
compile "com.google.android.gms:play-services-appindexing:6.5.+"
// Google Cast
compile "com.google.android.gms:play-services-cast:6.5.+"
@zaki50
zaki50 / gist:f798b8507db03d9ecea3
Last active August 29, 2015 14:03
android wear のバックライトの明るさ調整方法と、端末ごとの設定値
// AndroidManifest.xml に <uses-permission android:name="android.permission.WRITE_SETTINGS"/> を書くこと
final int brightness = 128; // 0-255 の範囲で明るさを指定する
// バックライトの明るさの設定方法は、普通のAndroid端末と同じ
Settings.System.putInt(getContentResolver(), Settings.System.SCREEN_BRIGHTNESS, brightness);
// Samsung Gear Live の設定画面では5段階(括弧の中は設定画面で選択した場合の値)
// 5(255): 255-230
@zaki50
zaki50 / FloatingActionButton.java
Last active August 29, 2015 14:03
Material Design の FloatingActionButton のためのクラスを作ってみた
/*
* Copyright (C) 2014 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
@zaki50
zaki50 / gist:9663178
Created March 20, 2014 12:55
私がよくつかうライブラリのライセンスページ用 HTML
<html>
<head>
<style> body { font-family: sans-serif; }
div { background-color: #eeeeee; padding: 1em; white-space: pre-wrap; font-family: monospace }
</style>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
</head>
<body>
<h3><a href="http://jakewharton.github.io/butterknife/">Butter Knife</a></h3>
@zaki50
zaki50 / panel_bg.xml
Created February 22, 2014 09:06
パネルの背景画像用の drawable リソースとして、上端にハイライト、下端にシャドウをいれたものを作る例。色を変えやすいように基本部分は shape を使う。ハイライトとシャドウはshapeでは作れないので、半透明な9patch画像を用意する。xxhdpi用だとこんな感じ https://dl.dropboxusercontent.com/u/713512/highlight_and_shadow.9.png
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape
android:shape="rectangle">
<solid android:color="#ffcccccc"/>
</shape>
</item>
<item android:drawable="@drawable/highlight_and_shadow"/>
</layer-list>
Kitkat での実行結果がこんなでつらい
D/hoge ( 8203): "あ".getBytes(Shift_JIS).length = 1
D/hoge ( 8203): "あい".getBytes(Shift_JIS).length = 3
D/hoge ( 8203): "あいう".getBytes(Shift_JIS).length = 6
D/hoge ( 8203): "あいうえ".getBytes(Shift_JIS).length = 8
D/hoge ( 8203): "あいうえお".getBytes(Shift_JIS).length = 10
@zaki50
zaki50 / AndroidManifest.xml
Last active January 21, 2018 21:32
ためしに PrintService を作ってみた
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.zakky.myprintservice"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="19"
android:targetSdkVersion="19" />