Skip to content

Instantly share code, notes, and snippets.

View yaoxinghuo's full-sized avatar
🎯
Focusing

Terry Yao yaoxinghuo

🎯
Focusing
View GitHub Profile
@yaoxinghuo
yaoxinghuo / new_gist_file
Created August 7, 2013 08:45
Android 里的 MediaPlayer 因为缓冲停止了播放,显示提示
mp.setOnInfoListener(new OnInfoListener() {
@Override
public boolean onInfo(MediaPlayer mp, int what, int extra) {
if (what == MediaPlayer.MEDIA_INFO_BUFFERING_START) {
loadingDialog.setVisibility(View.VISIBLE);
} else if (what == MediaPlayer.MEDIA_INFO_BUFFERING_END) {
loadingDialog.setVisibility(View.GONE);
}
return false;
}
@yaoxinghuo
yaoxinghuo / SHA1
Created August 19, 2013 04:47
SHA1
package com.terrynow.common;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Locale;
/**
* @author Terry E-mail: yaoxinghuo at 126 dot com
* @date Aug 19, 2013 9:54:05 AM
*/
@yaoxinghuo
yaoxinghuo / ChangeFont
Last active December 21, 2015 08:19
Android 整个应用换字体,字体ttf 文件放到 assets 下,调用可以放到 Application 的 onCreate 里面
private void setDefaultFont() {
try {
final Typeface bold = Typeface.createFromAsset(getAssets(),
"stheitilight.ttf");
final Typeface italic = Typeface.createFromAsset(getAssets(),
"stheitilight.ttf");
final Typeface boldItalic = Typeface.createFromAsset(getAssets(),
"stheitilight.ttf");
final Typeface regular = Typeface.createFromAsset(getAssets(),
"stheitilight.ttf");
@yaoxinghuo
yaoxinghuo / new_gist_file
Created September 12, 2013 03:24
Androd 判断某应用是否含有自启动和桌面小插件功能
/**
* 检查某个包 是否有自启动或者桌面小插件
*
* @param context
* @return 0 木有 1有自启动 2有小插件 3都有
*/
public static int checkStartupAndWidget(Context context, String packageName) {
PackageManager pm = context.getPackageManager();
boolean haveStartup = false;
boolean haveWidget = false;
@yaoxinghuo
yaoxinghuo / new_gist_file
Created September 19, 2013 03:18
Controller 之间的切换
DetailController *detailController=[[DetailController alloc] initWithNibName:@"DetailController" bundle:nil];
self.view.window.rootViewController=detailController;
//another:
TwoViewController *tempTwoViewController = [[TwoViewController alloc] initWithNibName:@"TwoViewController" bundle:nil];
[self.view.superview addSubview:tempTwoViewController.view];
[self.view removeFromSuperview];
[tempTwoViewController release];
//方法一右侧进入
@yaoxinghuo
yaoxinghuo / gist:6618757
Last active December 23, 2015 09:59 — forked from gdavis/gist:2829437
XCode 改成和 Eclipse 类似的快捷键 Command+D Delete Current Line Duplicate Current Line Alt+Command+Down Show Completions Alt+/
<!--Location: /Applications/Xcode.app/Contents/Frameworks/IDEKit.framework/Versions/A/Resources/IDETextKeyBindingSet.plist
-->
<key>GDI Commands</key>
<dict>
<key>GDI Duplicate Current Line</key>
<string>selectLine:, copy:, moveToEndOfLine:, insertNewline:, paste:, deleteBackward:</string>
<key>GDI Delete Current Line</key>
<string>moveToEndOfLine:, deleteToBeginningOfLine:, deleteBackward:, moveDown:, moveToBeginningOfLine:</string>
<key>GDI Move Current Line Up</key>
<string>selectLine:, cut:, moveUp:, moveToBeginningOfLine:, insertNewLine:, paste:, moveBackward:</string>
@yaoxinghuo
yaoxinghuo / new_gist_file
Created September 25, 2013 05:09
Android 生成二维码 需要zxing-core.jar
/**
* 用字符串生成二维码
* @param str
* @author zhouzhe@lenovo-cw.com
* @return
* @throws WriterException
*/
public static Bitmap create2DCode(String str) throws WriterException {
//生成二维矩阵,编码时指定大小,不要生成了图片以后再进行缩放,这样会模糊导致识别失败
BitMatrix matrix = new MultiFormatWriter().encode(str,BarcodeFormat.QR_CODE, 300, 300);
@yaoxinghuo
yaoxinghuo / TRYBlockAlertView.h
Created October 7, 2013 08:14
Block应用 UIAlertView来实现点击回调
//
// TRYBlockAlertView.h
// HelloWorld
//
// Created by Terry on 2013-10-07.
// Copyright (c) 2013 Terry. All rights reserved.
//
#import <UIKit/UIKit.h>
typedef void(^ClickedBlock)(NSInteger);
@yaoxinghuo
yaoxinghuo / new_gist_file
Created October 7, 2013 09:08
ObjectiveC 中NSDictionary中 NSNumber 和 NSInteger
//NSDictionary中 储存 NSInteger 不是对象,所以存过去的时候,都转换成了 NSNUmber 了
//需要转换成 NSInteger:
[change setValue:[NSNumber numberWithInteger:3] forKey:@"new"];
NSInteger val = [[change objectForKey:@"new"] intValue];
NSLog(@"%d",(int) val);
@yaoxinghuo
yaoxinghuo / new_gist_file
Created October 7, 2013 14:10
OC 创建单例
//
// UserConext.m
// HelloWorld
//
// Created by Terry on 2013-10-07.
// Copyright (c) 2013 Terry. All rights reserved.
//
#import "UserConext.h"