List of usage examples for android.widget ImageView setImageLevel
@android.view.RemotableViewMethod public void setImageLevel(int level)
From source file:Main.java
public static void setImageLevel(ImageView imageView, Integer level) { if (imageView != null) { if (level == null) level = 0;//from w w w . j a v a 2 s . c om imageView.setImageLevel(level); } else { throw new IllegalArgumentException("A view is null in your parameters."); } }
From source file:com.xabber.android.ui.adapter.OccupantListAdapter.java
@Override public View getView(int position, View convertView, ViewGroup parent) { final View view; if (convertView == null) { view = activity.getLayoutInflater().inflate(R.layout.item_occupant, parent, false); } else {/* w w w . j a v a2s.c om*/ view = convertView; } final Occupant occupant = (Occupant) getItem(position); final ImageView avatarView = (ImageView) view.findViewById(R.id.ivAvatar); avatarView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Intent intent; try { intent = ContactActivity.createIntent(activity, account, UserJid.from(JidCreate.domainFullFrom(room.asDomainBareJid(), occupant.getNickname()))); activity.startActivity(intent); } catch (UserJid.UserJidCreateException e) { LogManager.exception(this, e); } } }); final ImageView affilationView = (ImageView) view.findViewById(R.id.affilation); final TextView nameView = (TextView) view.findViewById(R.id.name); final TextView statusTextView = (TextView) view.findViewById(R.id.status); final ImageView statusModeView = (ImageView) view.findViewById(R.id.ivStatus); if (MUCManager.getInstance().getNickname(account, room).equals(occupant.getNickname())) { avatarView.setImageDrawable(AvatarManager.getInstance().getAccountAvatar(account)); } else { try { avatarView.setImageDrawable( AvatarManager.getInstance().getUserAvatar(UserJid.from(occupant.getJid()))); } catch (UserJid.UserJidCreateException e) { LogManager.exception(this, e); // set default avatar avatarView.setImageDrawable(ContextCompat.getDrawable(parent.getContext(), R.drawable.ic_avatar_1)); } } affilationView.setImageLevel(occupant.getAffiliation().ordinal()); nameView.setText(occupant.getNickname()); String status; if (occupant.getRole() == MUCRole.moderator) status = activity.getString(R.string.muc_role_moderator); else if (occupant.getRole() == MUCRole.participant) status = activity.getString(R.string.muc_role_participant); else status = activity.getString(R.string.muc_role_visitor); String statusText = occupant.getStatusText(); if (statusText != null && !statusText.isEmpty()) status = status + " " + statusText; statusTextView.setText(status); statusModeView.setImageLevel(occupant.getStatusMode().getStatusLevel()); return view; }
From source file:android.support.v17.leanback.widget.GuidedActionsStylist.java
private boolean setIcon(final ImageView iconView, GuidedAction action) { Drawable icon = null;/*from ww w . ja v a 2 s .co m*/ if (iconView != null) { Context context = iconView.getContext(); icon = action.getIcon(); if (icon != null) { // setImageDrawable resets the drawable's level unless we set the view level first. iconView.setImageLevel(icon.getLevel()); iconView.setImageDrawable(icon); iconView.setVisibility(View.VISIBLE); } else { iconView.setVisibility(View.GONE); } } return icon != null; }