当前位置: 首页>>代码示例>>Java>>正文


Java QuickContactBadge.setImageDrawable方法代码示例

本文整理汇总了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));
        }
    }
}
 
开发者ID:daxslab,项目名称:daxSmail,代码行数:40,代码来源:ContactPictureLoader.java

示例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));
        }
    }
}
 
开发者ID:thialfihar,项目名称:k-9,代码行数:40,代码来源:ContactPictureLoader.java

示例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);
    	}
    }
}
 
开发者ID:minhkhoi209,项目名称:EngLishReminder,代码行数:18,代码来源:SmsPopupFragment.java

示例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);

	}
 
开发者ID:CommonQ,项目名称:sms_DualCard,代码行数:31,代码来源:ComposeMessageActivity.java

示例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);
    }
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:11,代码来源:AvatarListItem.java


注:本文中的android.widget.QuickContactBadge.setImageDrawable方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。