本文整理汇总了Java中com.onegravity.contactpicker.picture.cache.ContactPictureCache类的典型用法代码示例。如果您正苦于以下问题:Java ContactPictureCache类的具体用法?Java ContactPictureCache怎么用?Java ContactPictureCache使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ContactPictureCache类属于com.onegravity.contactpicker.picture.cache包,在下文中一共展示了ContactPictureCache类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: retrievePicture
import com.onegravity.contactpicker.picture.cache.ContactPictureCache; //导入依赖的package包/类
public static Bitmap retrievePicture(Context context, Uri photoUri, boolean roundContactPictures) {
if (context == null || photoUri == null || Helper.isNullOrEmpty(photoUri.toString())) {
return null;
}
InputStream stream = null;
Bitmap bitmap = null;
// read contact picture
try {
stream = context.getContentResolver().openInputStream(photoUri);
bitmap = BitmapFactory.decodeStream(stream);
if (bitmap != null) {
// some contact pictures aren't square...
if (bitmap.getWidth() != bitmap.getHeight()) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int indent = Math.abs(w - h) / 2;
int x = w > h ? indent : 0;
int y = w < h ? indent : 0;
int size = Math.min(w, h);
bitmap = createBitmap(bitmap, x, y, size, size);
}
if (roundContactPictures) {
bitmap = getRoundedBitmap(bitmap);
}
}
} catch (OutOfMemoryError | FileNotFoundException ignore) {
} finally {
Helper.closeQuietly(stream);
}
// cache contact picture
if (bitmap != null) {
ContactPictureCache.getInstance(context).put(photoUri, bitmap);
}
return bitmap;
}
示例2: ContactPictureManager
import com.onegravity.contactpicker.picture.cache.ContactPictureCache; //导入依赖的package包/类
public ContactPictureManager(Context context, boolean roundContactPictures) {
sPhotoCache = ContactPictureCache.getInstance(context);
mRoundContactPictures = roundContactPictures;
EventBus.getDefault().register(this);
}
示例3: retrievePicture
import com.onegravity.contactpicker.picture.cache.ContactPictureCache; //导入依赖的package包/类
public static Bitmap retrievePicture(Context context, Uri photoUri, boolean roundContactPictures) {
if (context == null || photoUri == null || Helper.isNullOrEmpty(photoUri.toString())) {
return null;
}
InputStream stream = null;
Bitmap bitmap = null;
// read contact picture
try {
stream = context.getContentResolver().openInputStream(photoUri);
bitmap = BitmapFactory.decodeStream(stream);
if (bitmap != null) {
// some contact pictures aren't square...
if (bitmap.getWidth() != bitmap.getHeight()) {
int w = bitmap.getWidth();
int h = bitmap.getHeight();
int indent = Math.abs(w - h) / 2;
int x = w > h ? indent : 0;
int y = w < h ? indent : 0;
int size = Math.min(w, h);
bitmap = createBitmap(bitmap, x, y, size, size);
}
if (roundContactPictures) {
bitmap = getRoundedBitmap(bitmap);
}
}
}
catch (OutOfMemoryError | FileNotFoundException ignore) {}
finally {
Helper.closeQuietly(stream);
}
// cache contact picture
if (bitmap != null) {
ContactPictureCache.getInstance(context).put(photoUri, bitmap);
}
return bitmap;
}
示例4: ContactPictureManager
import com.onegravity.contactpicker.picture.cache.ContactPictureCache; //导入依赖的package包/类
public ContactPictureManager(Context context, boolean roundContactPictures) {
sPhotoCache = ContactPictureCache.getInstance( context );
mRoundContactPictures = roundContactPictures;
EventBus.getDefault().register(this);
}