Skip to content

Instantly share code, notes, and snippets.

@mochico
mochico / constraint_guideline_percent_sample.xml
Created July 8, 2018 10:46
Sample for guideline and percent in ConstraintLayout
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#fff">
<android.support.constraint.Guideline
android:id="@+id/vertical_center_guideline"
android:layout_width="wrap_content"
@mochico
mochico / page1.json
Created July 7, 2018 12:36
PagingTest
[
"あけび",
"アサイー",
"アセロラ",
"アボカド",
"あんず",
"いちご",
"いちじく",
"いよかん",
"梅",
@mochico
mochico / AAC-ViewModel-Codelabs.md
Created February 22, 2018 11:49 — forked from wasabeef/AAC-ViewModel-Codelabs.md
ViewModel - Android Architecture Components
import com.squareup.okhttp.Response;
import com.squareup.okhttp.internal.http.HttpDate;
import java.net.CookieManager;
import java.net.HttpCookie;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Date;
import java.util.List;
import java.util.StringTokenizer;
@mochico
mochico / android_get_hex_color_from_xml.md
Last active November 17, 2015 01:10
Androidのcolor.xmlから16進数カラーコードを取得する
Integer.toHexString(getResources().getColor(R.color.highlight_color) & 0x00ffffff);

htmlでカラー置き換えなどの時はalphaが効かないのでbit演算の論理積で必要な桁だけ取得する

@mochico
mochico / Utils.java
Created March 4, 2014 12:40
debug log for android
import android.util.Log;
public class Utils {
/** デバッグログ切替 */
public static final boolean isLogging = true;
/**
* Logメソッドを切り換えられるdebugLog
* @param logVal
public class MyJsonObjectRequest extends JsonObjectRequest {
private MyJsonObjectRequest(int method, String url,
JSONObject jsonRequest, Listener<JSONObject> listener,
ErrorListener errorListener) {
super(method, url, jsonRequest, listener, errorListener);
}
public MyJsonObjectRequest(String url, JSONObject jsonRequest,
Listener<JSONObject> listener, ErrorListener errorListener) {
super(url, jsonRequest, listener, errorListener);
@mochico
mochico / styles.xml
Created June 4, 2013 10:17
ダイアログをカスタムするときに背景とタイトルを消すstyle ref: http://qiita.com/items/6c69d6568c4a7581f172
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="Theme.MyDialog" parent="android:style/Theme.Dialog">
<item name="android:windowNoTitle">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
</style>
</resources>
@mochico
mochico / get KeyStore's Hash
Last active December 14, 2015 01:18
get KeyStore's Hash (important is -v. this need in Java1.7)
keytool -list -v -keystore ~/.android/debug.keystore -storepass android -keypass android
@mochico
mochico / adb shell am start
Created December 25, 2012 14:40
いっつも忘れるアプリ立ち上げるあのコマンド
$ adb shell am start -n com.mochico.app/.TestActivity