Skip to content

Instantly share code, notes, and snippets.

<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2015 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
package com.google.sample.castcompanionlibrary.cast.imageloader;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.util.DisplayMetrics;
import com.squareup.picasso.Picasso;
import com.squareup.picasso.Target;
package be.digitalia.common.adapters;
import android.database.DataSetObserver;
import android.util.SparseIntArray;
import android.widget.Adapter;
import android.widget.SectionIndexer;
/**
* An optimized version of the framework's AlphabetIndexer which is compatible with any Adapter
* returning non-null items with a meaningful toString() representation. Section indexes will be
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
@leasual
leasual / HttpClientSslHelper.java
Created September 25, 2015 09:08 — forked from Frank-Zhu/HttpClientSslHelper.java
Android HTTPS SSL双向验证
package com.ecloud.ssldemo;
import android.content.Context;
import android.util.Log;
import com.squareup.okhttp.OkHttpClient;
import org.apache.http.client.ClientProtocolException;
import org.apache.http.client.HttpClient;
import org.apache.http.conn.scheme.Scheme;
import android.content.Context;
import android.content.SharedPreferences;
/**
* Created by james.li on 2015/9/29.
*/
public class SPreferenceUtil {
private static SPreferenceUtil instance;
private SharedPreferences mSharedPreferences;
import android.util.Log;
/**
* Created by james.li on 2015/9/29.
*/
public class LogUtil {
/**
* @return 当前的类名(simpleName)
*/
package com.geedroid.util;
import android.app.Activity;
import android.view.View;
/**
* Created by james.li on 2015/9/29.
* 继承此类,可以使用getView(R.id.test);找到对应的控件,无需在使用findviewbyid()
*/
public class BaseActivity extends Activity {
@leasual
leasual / ExampleStaticHandler.java
Created October 21, 2015 09:53 — forked from yeoupooh/ExampleStaticHandler.java
Avoiding "This Handler class should be static or leaks might occur".
// This is OLD way of usnig Handler which shows an warning.
private Handler oldHandler = new Handler() {
@Override
public void handleMessage(Message msg) {
// Handle a message as you want.
}
}
@leasual
leasual / build.gradle
Created November 9, 2015 09:05 — forked from twocity/build.gradle
android gradle change output apk file name.
android.applicationVariants.all { variant ->
println "*********" + variant.description + "**********";
def variants = variant.baseName.split("-");
def apkName = "ricebook-";
apkName += variants[0];
apkName += "-v" + android.defaultConfig.versionName;
if (!variant.zipAlign) {
apkName += "-unaligned";
}
if (variant.buildType.name == "release") {