本文整理汇总了Java中android.widget.QuickContactBadge.setImageDrawable方法的典型用法代码示例。如果您正苦于以下问题:Java QuickContactBadge.setImageDrawable方法的具体用法?Java QuickContactBadge.setImageDrawable怎么用?Java QuickContactBadge.setImageDrawable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.widget.QuickContactBadge
的用法示例。
在下文中一共展示了QuickContactBadge.setImageDrawable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: loadContactPicture
import android.widget.QuickContactBadge; //导入方法依赖的package包/类
/**
* Load a contact picture and display it using the supplied {@link QuickContactBadge} instance.
*
* <p>
* If a picture is found in the cache, it is displayed in the {@code QuickContactBadge}
* immediately. Otherwise a {@link ContactPictureRetrievalTask} is started to try to load the
* contact picture in a background thread. Depending on the result the contact picture or a
* fallback picture is then stored in the bitmap cache.
* </p>
*
* @param address
* The {@link Address} instance holding the email address that is used to search the
* contacts database.
* @param badge
* The {@code QuickContactBadge} instance to receive the picture.
*
* @see #mBitmapCache
* @see #calculateFallbackBitmap(Address)
*/
public void loadContactPicture(Address address, QuickContactBadge badge) {
Bitmap bitmap = getBitmapFromCache(address);
if (bitmap != null) {
// The picture was found in the bitmap cache
badge.setImageBitmap(bitmap);
} else if (cancelPotentialWork(address, badge)) {
// Query the contacts database in a background thread and try to load the contact
// picture, if there is one.
ContactPictureRetrievalTask task = new ContactPictureRetrievalTask(badge, address);
AsyncDrawable asyncDrawable = new AsyncDrawable(mResources,
calculateFallbackBitmap(address), task);
badge.setImageDrawable(asyncDrawable);
try {
task.executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
} catch (RejectedExecutionException e) {
// We flooded the thread pool queue... use a fallback picture
badge.setImageBitmap(calculateFallbackBitmap(address));
}
}
}
示例2: loadContactPicture
import android.widget.QuickContactBadge; //导入方法依赖的package包/类
/**
* Load a contact picture and display it using the supplied {@link QuickContactBadge} instance.
*
* <p>
* If a picture is found in the cache, it is displayed in the {@code QuickContactBadge}
* immediately. Otherwise a {@link ContactPictureRetrievalTask} is started to try to load the
* contact picture in a background thread. Depending on the result the contact picture or a
* fallback picture is then stored in the bitmap cache.
* </p>
*
* @param address
* The {@link Address} instance holding the email address that is used to search the
* contacts database.
* @param badge
* The {@code QuickContactBadge} instance to receive the picture.
*
* @see #mBitmapCache
* @see #calculateFallbackBitmap(Address)
*/
public void loadContactPicture(Address address, QuickContactBadge badge) {
Bitmap bitmap = getBitmapFromCache(address);
if (bitmap != null) {
// The picture was found in the bitmap cache
badge.setImageBitmap(bitmap);
} else if (cancelPotentialWork(address, badge)) {
// Query the contacts database in a background thread and try to load the contact
// picture, if there is one.
ContactPictureRetrievalTask task = new ContactPictureRetrievalTask(badge, address);
AsyncDrawable asyncDrawable = new AsyncDrawable(mResources,
calculateFallbackBitmap(address), task);
badge.setImageDrawable(asyncDrawable);
try {
task.exec();
} catch (RejectedExecutionException e) {
// We flooded the thread pool queue... use a fallback picture
badge.setImageBitmap(calculateFallbackBitmap(address));
}
}
}
示例3: onPostExecute
import android.widget.QuickContactBadge; //导入方法依赖的package包/类
@Override
protected void onPostExecute(Bitmap photo) {
if (BuildConfig.DEBUG)
Log.v("Done loading contact photo");
if (photo != null && viewReference != null) {
final QuickContactBadge badge = viewReference.get();
if (badge != null && isAdded()) {
TransitionDrawable mTd =
new TransitionDrawable(new Drawable[] {
getResources().getDrawable(R.drawable.ic_contact_picture),
new BitmapDrawable(getResources(), photo) });
badge.setImageDrawable(mTd);
mTd.setCrossFadeEnabled(false);
mTd.startTransition(CONTACT_IMAGE_FADE_DURATION);
}
}
}
示例4: addQuickContactActionBar
import android.widget.QuickContactBadge; //导入方法依赖的package包/类
private void addQuickContactActionBar(ActionBar actionBar) {
Drawable avatarDrawable;
sDefaultContactImage = ComposeMessageActivity.this.getResources()
.getDrawable(R.drawable.ic_contact_picture);
ViewGroup v = (ViewGroup) LayoutInflater.from(this).inflate(
R.layout.test_actionbar, null);
actionBar.setDisplayShowCustomEnabled(true);
actionBar.setCustomView(v);
mAvatar = (QuickContactBadge) v.findViewById(R.id.test_avatar);
Contact contact = mConversation.getRecipients().get(0);
avatarDrawable = contact.getAvatar(ComposeMessageActivity.this,
sDefaultContactImage);
if (contact.existsInDatabase()) {// 010
mAvatar.assignContactUri(contact.getUri());
} else {
mAvatar.assignContactFromPhone(contact.getNumber(), true);
}
mAvatar.setImageDrawable(avatarDrawable);
mAvatar.setVisibility(View.VISIBLE);
// mAvatar.assignContactUri(contactUri)
actionBar.setDisplayOptions(ActionBar.DISPLAY_SHOW_CUSTOM
| ActionBar.DISPLAY_SHOW_TITLE);
}
示例5: onFinishInflate
import android.widget.QuickContactBadge; //导入方法依赖的package包/类
@Override
protected void onFinishInflate() {
super.onFinishInflate();
mAvatarView = (QuickContactBadge) findViewById(R.id.avatar);
if (isInEditMode()) {
mAvatarView.setImageDrawable(sDefaultContactImage);
mAvatarView.setVisibility(VISIBLE);
}
}