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
/** | |
* 该Drawable能够为与之绑定的ImageView保持一个BitmapWorkerTask(AsyncTask)的引用,使得 | |
* BitmapWorkerTask能够在需要的时候被取消,并且保证只有最后与ImageView绑定的BitmapWorkerTask | |
* 才能够更新ImageView | |
*/ | |
private static class AsyncDrawable extends BitmapDrawable { | |
private final WeakReference<BitmapWorkerTask> bitmapWorkerTaskReference; | |
/** | |
* bitmap参数是占位图片(placeholder),代表图片正在加载中 |
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 int calculateInSampleSize(BitmapFactory.Options options, | |
int reqWidth, int reqHeight) { | |
// 从BitmapFactory.Options中获取图片的原始高度和宽度 | |
final int height = options.outHeight; | |
final int width = options.outWidth; | |
int inSampleSize = 1; | |
if (height > reqHeight || width > reqWidth) { | |
// 计算原始尺寸与显示尺寸的比例 |
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 Bitmap decodeSampledBitmapFromDescriptor( | |
FileDescriptor fileDescriptor, int reqWidth, | |
int reqHeight, ImageCache cache) { | |
// 设置inJustDecodeBounds=true来获取图片的尺寸 | |
final BitmapFactory.Options options = new BitmapFactory.Options(); | |
options.inJustDecodeBounds = true; | |
BitmapFactory.decodeFileDescriptor(fileDescriptor, null, options); | |
// 计算采样率 |
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 void setPresence(int code){ | |
if(connection == null) return; | |
Presence presence; | |
switch(code){ | |
case 0: | |
presence = new Presence(Presence.Type.available); | |
connection.sendPacket(presence); | |
Log.v(TAG, "设置在线"); | |
break; |
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
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE | |
Version 2, December 2004 | |
Copyright (C) 2011 YOUR_NAME_HERE <YOUR_URL_HERE> | |
Everyone is permitted to copy and distribute verbatim or modified | |
copies of this license document, and changing it is allowed as long | |
as the name is changed. | |
DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE |
NewerOlder