Skip to content

Instantly share code, notes, and snippets.

View jp1017's full-sized avatar
:octocat:
Focusing

妙法莲华经 jp1017

:octocat:
Focusing
View GitHub Profile
@jp1017
jp1017 / CountDownTimer.java
Created December 18, 2015 04:51
replace 官方的 from github, this can normal cancle
package com.inst.navigation.utils;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
/* The calls to {@link #onTick(long)} are synchronized to this object so that
* one call to {@link #onTick(long)} won't ever occur before the previous
* callback is complete. This is only relevant when the implementation of
* {@link #onTick(long)} takes an amount of time to execute that is significant
@jp1017
jp1017 / adb+
Created January 6, 2016 03:10 — forked from race604/adb+
#!/bin/bash
# Script adb+
# Run any command adb provides on all your currently connected devices,
# Or prompt to select one device
showHelp() {
echo "Usage: adb+ [-a] <command>"
echo " -h: show help"
echo " -a: run command on all device"
echo " command: normal adb commands"
@jp1017
jp1017 / Sort Algorithm
Created January 7, 2016 07:27 — forked from Leaking/Sort Algorithm
Sort Algorithm
/**
* 冒泡排序
*
* @param a
*/
public static void bubbleSort(int[] a) {
int temp;
for (int i = 0; i < a.length; i++)
for (int j = 0; j < a.length - i - 1; j++) {
@jp1017
jp1017 / dispatchTouchEvent源码解析
Created January 7, 2016 07:28 — forked from Leaking/dispatchTouchEvent源码解析
android事件分发dispatchTouchEvent方法的源码解析
package cc.aa;
import android.os.Environment;
import android.view.MotionEvent;
import android.view.View;
public class UnderstandDispatchTouchEvent {
/**
* dispatchTouchEvent()源码学习及其注释
* 常说事件传递中的流程是:dispatchTouchEvent->onInterceptTouchEvent->onTouchEvent
@jp1017
jp1017 / DBHelper.java
Created January 8, 2016 10:19
在Application实现得到DaoMaster和DaoSession的方法及数据库增删改查工具类
public class DBHelper
{
private static Context mContext;
private static DBHelper instance;
private CityInfoDBDao cityInfoDao;
private DBHelper()
{
}
@jp1017
jp1017 / Data.java
Created January 11, 2016 00:20 — forked from douo/Data.java
一个实现安卓 Recycle 机制的例子
/**
* Created by Tiou on 2014/7/15.
* 一个实现 Recycle 机制的对象
*/
public class Data {
/**
* 对象池,就是上文所提到的对象仓库,用于暂时存放不用的对象。
* 用链表来实现对象池结构,直观,高效,易用。
* sPool 便是指向链表头部的引用
*/
@jp1017
jp1017 / person.xml
Created January 12, 2016 13:03
个人资料布局
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#ffffff"
android:orientation="vertical" >
<FrameLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
>
@jp1017
jp1017 / getLauncherActivity.sh
Last active October 9, 2017 08:19
获取安卓app的包名和入口 Activity
#!/bin/bash
# 来源:
#1. https://stackoverflow.com/questions/2789462/find-package-name-for-android-apps-to-use-intent-to-launch-market-app-from-web/7502519#7502519
#2. http://jp1017.github.io/2016/01/29/获取安卓应用的包名和入口-Activity/
# how to use: ./getLauncherActivity.sh **.apk
#package_name=$1
#launch app by package name
#adb shell monkey -p ${package_name} -c android.intent.category.LAUNCHER 1;
public static int calculateInSampleSize(
BitmapFactory.Options options, int reqWidth, int reqHeight) {
// Raw height and width of image
final int height = options.outHeight;
final int width = options.outWidth;
int inSampleSize = 1;
if (height > reqHeight || width > reqWidth) {
final int halfHeight = height / 2;
@jp1017
jp1017 / rotateBitmapByCamera.java
Created February 23, 2016 11:38
ImageView旋转的三种方法
/**
* Camera与Matrix的比较:
* Camera的rotate()相关方法是指定某一维度上旋转指定的角度。
* Matrix的rotate()相关方法实现的效果是顺时针旋转指定的角度;与Camera指定Z轴旋转效果相同,但方向相反。
*
* Camera的translate()方法根据某一维度上视点的位移实现图像的缩放,与Matrix的scale()相关方法作用效果相似,
* 只是Matrix的scale()相关方法是直接指定缩放比例。
*
* Camera不支持倾斜操作,Matrix可以直接实现倾斜操作。
*/