This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#=============================================================================== | |
# Filename: boost.sh | |
# Author: Pete Goodliffe | |
# Copyright: (c) Copyright 2009 Pete Goodliffe | |
# Licence: Please feel free to use this, with attribution | |
# Modified version | |
#=============================================================================== | |
# | |
# Builds a Boost framework for the iPhone. | |
# Creates a set of universal libraries that can be used on an iPhone and in the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <sys/socket.h> | |
#include <sys/ioctl.h> | |
#include <linux/netdevice.h> | |
#include <arpa/inet.h> | |
#include <unistd.h> | |
#include <sys/system_properties.h> | |
#include <stdio.h> | |
char cmd_res_line[256]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <Foundation/Foundation.h> | |
@interface BDSBlockingQueue : NSObject | |
- (void)enqueue:(id)item; | |
- (id)dequeue; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static VersionedOperation () { | |
final int sdkVersion = Integer.parseInt(Build.VERSION.SDK); | |
if (sdkVersion > Build.VERSION_CODES.ECLAIR) { | |
// do something with new API features | |
} else { | |
// do normal | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private DiskLruCache mDiskLruCache; | |
private final Object mDiskCacheLock = new Object(); | |
private boolean mDiskCacheStarting = true; | |
private static final int DISK_CACHE_SIZE = 1024 * 1024 * 10; // 10MB | |
private static final String DISK_CACHE_SUBDIR = "disk_cache"; | |
File cacheDir = getDiskCacheDir(this, DISK_CACHE_SUBDIR); | |
new InitDiskCacheTask().execute(cacheDir); | |
class InitDiskCacheTask extends AsyncTask<File, Void, Void> { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void addBitmapToMemoryCache(String key, Bitmap bitmap) { | |
if (getBitmapFromMemCache(key) == null) { | |
mMemoryCache.put(key, bitmap); | |
} | |
} | |
public Bitmap getBitmapFromMemCache(String key) { | |
return mMemoryCache.get(key); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private LruCache<String, BitmapDrawable> mMemoryCache; | |
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024); | |
// 使用最大可使用内存的1/8作为缓存 | |
final int cacheSize = maxMemory / 8; | |
mMemoryCache = new LruCache<String, BitmapDrawable>(cacheSize) { | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 如果当前存在一致的任务,返回false,代表不需要新建任务,否则返回true | |
*/ | |
public static boolean cancelPotentialWork(Object data, ImageView imageView) { | |
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); | |
if (bitmapWorkerTask != null) { | |
final Object bitmapData = bitmapWorkerTask.data; | |
if (bitmapData == null || !bitmapData.equals(data)) { | |
bitmapWorkerTask.cancel(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 比较之前传入的ImageView在当前时刻关联的`AsyncTask`是否等于自身 | |
* 来确定是否需要将结果返回给ImageView | |
*/ | |
private ImageView getAttachedImageView() { | |
final ImageView imageView = imageViewReference.get(); | |
final BitmapWorkerTask bitmapWorkerTask = getBitmapWorkerTask(imageView); | |
if (this == bitmapWorkerTask) { | |
return imageView; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static BitmapWorkerTask getBitmapWorkerTask(ImageView imageView) { | |
if (imageView != null) { | |
final Drawable drawable = imageView.getDrawable(); | |
if (drawable instanceof AsyncDrawable) { | |
final AsyncDrawable asyncDrawable = (AsyncDrawable) drawable; | |
return asyncDrawable.getBitmapWorkerTask(); | |
} | |
} | |
return null; | |
} |
NewerOlder