Skip to content

Instantly share code, notes, and snippets.

View songzhiyong's full-sized avatar
🌍

Jerome Song songzhiyong

🌍
View GitHub Profile
var _ = require('lodash'),
colors = require('colors/safe'),
Table = require('cli-table2'),
format = require('util').format,
util = require('../../util'),
cliUtils = require('./cli-utils'),
print = require('../../print'),
pad = cliUtils.padLeft,
@songzhiyong
songzhiyong / DividerItemDecoration.java
Created October 14, 2015 07:29 — forked from lapastillaroja/DividerItemDecoration.java
DividerItemDecoration. RecyclerView.ItemDecoration simple implementation
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.util.AttributeSet;
import android.view.View;
public class DeepScrollView extends ScrollView {
public ShrinkWatchScrollView(Context context, AttributeSet attrs,
int defStyle) {
super(context, attrs, defStyle);
}
public ShrinkWatchScrollView(Context context, AttributeSet attrs) {
this(context, attrs, 0);
/* Copyright 2013 Google Inc.
Licensed under Apache 2.0: http://www.apache.org/licenses/LICENSE-2.0.html */
package com.example.latlnginterpolation;
import android.animation.ObjectAnimator;
import android.animation.TypeEvaluator;
import android.animation.ValueAnimator;
import android.annotation.TargetApi;
import android.os.Build;

System directories

Method Result
Environment.getDataDirectory() /data
Environment.getDownloadCacheDirectory() /cache
Environment.getRootDirectory() /system

External storage directories

import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.drawable.Drawable;
import android.util.AttributeSet;
import android.widget.ImageView;
public class ForegroundImageView extends ImageView {
private Drawable foreground;
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.setData(Uri.parse("content://mms-sms/"));
startActivity(intent);
public class RC4 {
private final byte[] S = new byte[256];
private final byte[] T = new byte[256];
private final int keylen;
public RC4(final byte[] key) {
if (key.length < 1 || key.length > 256) {
throw new IllegalArgumentException(
"key must be between 1 and 256 bytes");
} else {
@songzhiyong
songzhiyong / Android-GPS-switcher
Created January 9, 2014 05:53
Turn on or turn off the gps
public void turnGPSOn()
{
Intent intent = new Intent("android.location.GPS_ENABLED_CHANGE");
intent.putExtra("enabled", true);
this.ctx.sendBroadcast(intent);
String provider = Settings.Secure.getString(ctx.getContentResolver(), Settings.Secure.LOCATION_PROVIDERS_ALLOWED);
if(!provider.contains("gps")){ //if gps is disabled
final Intent poke = new Intent();
poke.setClassName("com.android.settings", "com.android.settings.widget.SettingsAppWidgetProvider");