List of usage examples for android.widget ImageView setImageResource
@android.view.RemotableViewMethod(asyncImpl = "setImageResourceAsync") public void setImageResource(@DrawableRes int resId)
From source file:com.bt.download.android.gui.adapters.TransferListAdapter.java
private void populateBittorrentDownloadItem(View view, TransferItem item) { ImageView icon = findView(view, R.id.view_transfer_item_list_item_icon); TextView title = findView(view, R.id.view_transfer_item_list_item_title); ProgressBar progress = findView(view, R.id.view_transfer_item_list_item_progress); TextView size = findView(view, R.id.view_transfer_item_list_item_size); ImageButton buttonPlay = findView(view, R.id.view_transfer_item_list_item_button_play); icon.setImageResource(getFileTypeIconId(FilenameUtils.getExtension(item.getFile().getAbsolutePath()))); title.setText(item.getDisplayName()); progress.setProgress(item.getProgress()); size.setText(UIUtils.getBytesInHuman(item.getSize())); buttonPlay.setTag(item);//w ww. j a v a 2 s .co m buttonPlay.setVisibility(item.isComplete() ? View.VISIBLE : View.GONE); buttonPlay.setOnClickListener(playOnClickListener); }
From source file:edu.stanford.mobisocial.dungbeetle.model.DbObject.java
/** * @param v the view to bind/*www .java 2s. c o m*/ * @param context standard activity context * @param c the cursor source for the object in the db object table. * Must include _id in the projection. * * @param allowInteractions controls whether the bound view is * allowed to intercept touch events and do its own processing. */ public static void bindView(View v, final Context context, Cursor cursor, boolean allowInteractions) { TextView nameText = (TextView) v.findViewById(R.id.name_text); ViewGroup frame = (ViewGroup) v.findViewById(R.id.object_content); frame.removeAllViews(); // make sure we have all the columns we need Long objId = cursor.getLong(cursor.getColumnIndexOrThrow(DbObj.COL_ID)); String[] projection = null; String selection = DbObj.COL_ID + " = ?"; String[] selectionArgs = new String[] { Long.toString(objId) }; String sortOrder = null; Cursor c = context.getContentResolver().query(DbObj.OBJ_URI, projection, selection, selectionArgs, sortOrder); if (!c.moveToFirst()) { Log.w(TAG, "could not find obj " + objId); c.close(); return; } DbObj obj = App.instance().getMusubi().objForCursor(c); if (obj == null) { nameText.setText("Failed to access database."); Log.e("DbObject", "cursor was null for bindView of DbObject"); return; } DbUser sender = obj.getSender(); Long timestamp = c.getLong(c.getColumnIndexOrThrow(DbObj.COL_TIMESTAMP)); Long hash = obj.getHash(); short deleted = c.getShort(c.getColumnIndexOrThrow(DELETED)); String feedName = obj.getFeedName(); String type = obj.getType(); Date date = new Date(timestamp); c.close(); c = null; if (sender == null) { nameText.setText("Message from unknown contact."); return; } nameText.setText(sender.getName()); final ImageView icon = (ImageView) v.findViewById(R.id.icon); if (sViewProfileAction == null) { sViewProfileAction = new OnClickViewProfile((Activity) context); } icon.setTag(sender.getLocalId()); if (allowInteractions) { icon.setOnClickListener(sViewProfileAction); v.setTag(objId); } icon.setImageBitmap(sender.getPicture()); if (deleted == 1) { v.setBackgroundColor(sDeletedColor); } else { v.setBackgroundColor(Color.TRANSPARENT); } TextView timeText = (TextView) v.findViewById(R.id.time_text); timeText.setText(RelativeDate.getRelativeDate(date)); frame.setTag(objId); // TODO: error prone! This is database id frame.setTag(R.id.object_entry, cursor.getPosition()); // this is cursor id FeedRenderer renderer = DbObjects.getFeedRenderer(type); if (renderer != null) { renderer.render(context, frame, obj, allowInteractions); } if (!allowInteractions) { v.findViewById(R.id.obj_attachments_icon).setVisibility(View.GONE); v.findViewById(R.id.obj_attachments).setVisibility(View.GONE); } else { if (!MusubiBaseActivity.isDeveloperModeEnabled(context)) { v.findViewById(R.id.obj_attachments_icon).setVisibility(View.GONE); v.findViewById(R.id.obj_attachments).setVisibility(View.GONE); } else { ImageView attachmentCountButton = (ImageView) v.findViewById(R.id.obj_attachments_icon); TextView attachmentCountText = (TextView) v.findViewById(R.id.obj_attachments); attachmentCountButton.setVisibility(View.VISIBLE); if (hash == 0) { attachmentCountButton.setVisibility(View.GONE); } else { //int color = DbObject.colorFor(hash); boolean selfPost = false; DBHelper helper = new DBHelper(context); try { Cursor attachments = obj.getSubfeed().query("type=?", new String[] { LikeObj.TYPE }); try { attachmentCountText.setText("+" + attachments.getCount()); if (attachments.moveToFirst()) { while (!attachments.isAfterLast()) { if (attachments.getInt(attachments.getColumnIndex(CONTACT_ID)) == -666) { selfPost = true; break; } attachments.moveToNext(); } } } finally { attachments.close(); } } finally { helper.close(); } if (selfPost) { attachmentCountButton.setImageResource(R.drawable.ic_menu_love_red); } else { attachmentCountButton.setImageResource(R.drawable.ic_menu_love); } attachmentCountText.setTag(R.id.object_entry, hash); attachmentCountText.setTag(R.id.feed_label, Feed.uriForName(feedName)); attachmentCountText.setOnClickListener(LikeListener.getInstance(context)); } } } }
From source file:com.android.mms.rcs.FavoriteDetailAdapter.java
@Override public Object instantiateItem(ViewGroup view, int position) { mCursor.moveToPosition(position);/* w w w. j a v a 2s . co m*/ View content = mInflater.inflate(R.layout.message_detail_content, view, false); TextView bodyText = (TextView) content.findViewById(R.id.textViewBody); LinearLayout mLinearLayout = (LinearLayout) content.findViewById(R.id.other_type_layout); mMsgType = mCursor.getInt(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.MSG_TYPE)); if (mMsgType == RcsUtils.RCS_MSG_TYPE_TEXT) { initTextMsgView(bodyText); } else { bodyText.setVisibility(View.GONE); mLinearLayout.setVisibility(View.VISIBLE); ImageView imageView = (ImageView) mLinearLayout.findViewById(R.id.image_view); TextView textView = (TextView) mLinearLayout.findViewById(R.id.type_text_view); if (mMsgType != RcsUtils.RCS_MSG_TYPE_CAIYUNFILE) { imageView.setOnClickListener(mOnClickListener); } if (mMsgType == RcsUtils.RCS_MSG_TYPE_IMAGE) { initImageMsgView(mLinearLayout); showContentFileSize(textView); mContentType = "image/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_AUDIO) { imageView.setImageResource(R.drawable.rcs_voice); showContentFileSize(textView); mContentType = "audio/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VIDEO) { String thumbPath = mCursor.getString( mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.THUMBNAIL)); Bitmap bitmap = BitmapFactory.decodeFile(thumbPath); imageView.setImageBitmap(bitmap); showContentFileSize(textView); mContentType = "video/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_MAP) { imageView.setImageResource(R.drawable.rcs_map); String body = mCursor .getString(mCursor.getColumnIndexOrThrow(FavoriteMessageProvider.FavoriteMessage.CONTENT)); textView.setText(body); mContentType = "map/*"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_VCARD) { textView.setVisibility(View.GONE); initVcardMagView(mLinearLayout); mContentType = "text/x-vCard"; } else if (mMsgType == RcsUtils.RCS_MSG_TYPE_PAID_EMO) { String messageBody = mCursor .getString(mCursor.getColumnIndex(FavoriteMessageProvider.FavoriteMessage.FILE_NAME)); String[] body = messageBody.split(","); RcsEmojiStoreUtil.getInstance().loadImageAsynById(imageView, body[0], RcsEmojiStoreUtil.EMO_STATIC_FILE); } else { bodyText.setVisibility(View.VISIBLE); mLinearLayout.setVisibility(View.GONE); initTextMsgView(bodyText); } } TextView detailsText = (TextView) content.findViewById(R.id.textViewDetails); detailsText.setText(getTextMessageDetails(mContext, mCursor, true)); view.addView(content); return content; }
From source file:com.dnielfe.manager.adapters.BrowserListAdapter.java
private void loadFromRes(final File file, final ImageView icon) { Drawable mimeIcon = null;/*from www.java2s . c om*/ if (file != null && file.isDirectory()) { if (file.canRead() && file.list().length > 0) mimeIcon = mResources.getDrawable(R.drawable.type_folder); else mimeIcon = mResources.getDrawable(R.drawable.type_folder_empty); } else { final String fileExt = FilenameUtils.getExtension(file.getName()); mimeIcon = mMimeTypeIconCache.get(fileExt); if (mimeIcon == null) { final int mimeIconId = MimeTypes.getIconForExt(fileExt); if (mimeIconId != 0) { mimeIcon = mResources.getDrawable(mimeIconId); mMimeTypeIconCache.put(fileExt, mimeIcon); } } } if (mimeIcon != null) { icon.setImageDrawable(mimeIcon); } else { // default icon icon.setImageResource(R.drawable.type_unknown); } }
From source file:com.amaze.filemanager.fragments.ProcessViewer.java
void processCompressResults(DataPackage dataPackage) { final int id = dataPackage.getId(); if (!CancelledZipIds.contains(id)) { if (ZipIds.contains(id)) { boolean completed = dataPackage.isCompleted(); View process = rootView.findViewWithTag("zip" + id); if (completed) { rootView.removeViewInLayout(process); ZipIds.remove(ZipIds.indexOf(id)); } else { String name = dataPackage.getName(); int p1 = dataPackage.getP1(); ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1); if (p1 <= 100) { ((TextView) process.findViewById(R.id.progressText)).setText( utils.getString(getActivity(), R.string.zipping) + "\n" + name + "\n" + p1 + "%"); p.setProgress(p1);/*from w w w. jav a 2 s .c o m*/ } } } else { CardView root = (CardView) getActivity().getLayoutInflater().inflate(R.layout.processrow, null); root.setTag("zip" + id); ImageView progressImage = ((ImageView) root.findViewById(R.id.progressImage)); ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button); TextView progressText = (TextView) root.findViewById(R.id.progressText); if (mainActivity.theme1 == 1) { root.setCardBackgroundColor(R.color.cardView_foreground); root.setCardElevation(0f); cancel.setImageResource(R.drawable.ic_action_cancel); progressText.setTextColor(Color.WHITE); progressImage.setImageResource(R.drawable.ic_doc_compressed); } else { // cancel has default src set for light theme progressText.setTextColor(Color.BLACK); progressImage.setImageResource(R.drawable.ic_doc_compressed_black); } cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping), Toast.LENGTH_LONG).show(); Intent i = new Intent("zipcancel"); i.putExtra("id", id); getActivity().sendBroadcast(i); rootView.removeView(rootView.findViewWithTag("zip" + id)); ZipIds.remove(ZipIds.indexOf(id)); CancelledZipIds.add(id); // TODO: Implement this method } }); String name = dataPackage.getName(); int p1 = dataPackage.getP1(); ((TextView) root.findViewById(R.id.progressText)) .setText(utils.getString(getActivity(), R.string.zipping) + "\n" + name); ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1); p.setProgress(p1); ZipIds.add(id); rootView.addView(root); } } }
From source file:com.nd.pad.GreenBrowser.util.ImageDownloader.java
/** * Same as download but the image is always downloaded and the cache is not * used. Kept private at the moment as its interest is not clear. *///from ww w . ja va 2s. c om private void forceDownload(String url, ImageView imageView, int loadingDrawable_ID, int failDrawable_ID, boolean isSaveLocal, ImageDownLoaderAction action) { if (url == null) { imageView.setImageResource(failDrawable_ID); return; } if (cancelPotentialDownload(url, imageView)) { /*modeCORRECT*/ switch (mode) { case NO_ASYNC_TASK: Bitmap bitmap = downloadBitmap(url); addBitmapToCache(url, bitmap); imageView.setImageBitmap(bitmap); break; case NO_DOWNLOADED_DRAWABLE: imageView.setMinimumHeight(156); BitmapDownloaderTask task = new BitmapDownloaderTask(imageView, failDrawable_ID, isSaveLocal, action); task.execute(url); break; case CORRECT: task = new BitmapDownloaderTask(imageView, failDrawable_ID, isSaveLocal, action); DownloadedDrawable downloadedDrawable = new DownloadedDrawable(task, loadingDrawable_ID); imageView.setImageDrawable(downloadedDrawable); imageView.setMinimumHeight(156); try { task.execute(url); } catch (RejectedExecutionException localRejectedExecutionException) { } break; } } }
From source file:com.amaze.filemanager.fragments.ProcessViewer.java
public void processExtractResults(DataPackage dataPackage) { if (!running) return;//w ww . j av a2 s . c o m if (getResources() == null) return; final int id = dataPackage.getId(); if (!CancelledExtractIds.contains(id)) { if (ExtractIds.contains(id)) { boolean completed = dataPackage.isCompleted(); View process = rootView.findViewWithTag("extract" + id); if (completed) { rootView.removeViewInLayout(process); ExtractIds.remove(ExtractIds.indexOf(id)); } else { String name = dataPackage.getName(); int p1 = dataPackage.getP1(); long p3 = dataPackage.getTotal(); long p2 = dataPackage.getDone(); ProgressBar p = (ProgressBar) process.findViewById(R.id.progressBar1); if (p1 <= 100) { ((TextView) process.findViewById(R.id.progressText)).setText( utils.getString(getActivity(), R.string.extracting) + "\n" + name + "\n" + p1 + "%" + "\n" + utils.readableFileSize(p2) + "/" + utils.readableFileSize(p3)); p.setProgress(p1); } } } else { CardView root = (CardView) getActivity().getLayoutInflater().inflate(R.layout.processrow, null); root.setTag("extract" + id); ImageView progressImage = ((ImageView) root.findViewById(R.id.progressImage)); ImageButton cancel = (ImageButton) root.findViewById(R.id.delete_button); TextView progressText = (TextView) root.findViewById(R.id.progressText); if (mainActivity.theme1 == 1) { root.setCardBackgroundColor(R.color.cardView_foreground); root.setCardElevation(0f); cancel.setImageResource(R.drawable.ic_action_cancel); progressText.setTextColor(Color.WHITE); progressImage.setImageResource(R.drawable.ic_doc_compressed); } else { // cancel has default src set for light theme progressText.setTextColor(Color.BLACK); progressImage.setImageResource(R.drawable.ic_doc_compressed_black); } cancel.setOnClickListener(new View.OnClickListener() { public void onClick(View p1) { Toast.makeText(getActivity(), utils.getString(getActivity(), R.string.stopping), Toast.LENGTH_LONG).show(); Intent i = new Intent("excancel"); i.putExtra("id", id); getActivity().sendBroadcast(i); rootView.removeView(rootView.findViewWithTag("extract" + id)); ExtractIds.remove(ExtractIds.indexOf(id)); CancelledExtractIds.add(id); // TODO: Implement this method } }); String name = dataPackage.getName(); int p1 = dataPackage.getP1(); ((TextView) root.findViewById(R.id.progressText)) .setText(utils.getString(getActivity(), R.string.extracting) + "\n" + name); ProgressBar p = (ProgressBar) root.findViewById(R.id.progressBar1); p.setProgress(p1); ExtractIds.add(id); rootView.addView(root); } } }
From source file:com.parse.ui.ParseLoginFragment.java
@Override public View onCreateView(LayoutInflater inflater, ViewGroup parent, Bundle savedInstanceState) { config = ParseLoginConfig.fromBundle(getArguments(), getActivity()); View v = inflater.inflate(R.layout.com_parse_ui_parse_login_fragment, parent, false); ImageView appLogo = (ImageView) v.findViewById(R.id.app_logo); parseLogin = v.findViewById(R.id.parse_login); usernameField = (EditText) v.findViewById(R.id.login_username_input); passwordField = (EditText) v.findViewById(R.id.login_password_input); parseLoginHelpButton = (Button) v.findViewById(R.id.parse_login_help); parseLoginButton = (Button) v.findViewById(R.id.parse_login_button); parseSignupButton = (Button) v.findViewById(R.id.parse_signup_button); facebookLoginButton = (Button) v.findViewById(R.id.facebook_login); twitterLoginButton = (Button) v.findViewById(R.id.twitter_login); if (appLogo != null && config.getAppLogo() != null) { appLogo.setImageResource(config.getAppLogo()); }/*from w w w . j a v a 2 s. c om*/ if (allowParseLoginAndSignup()) { setUpParseLoginAndSignup(); } if (allowFacebookLogin()) { setUpFacebookLogin(); } if (allowTwitterLogin()) { setUpTwitterLogin(); } return v; }
From source file:it.chefacile.app.MainActivity.java
private void setBackground(ImageView iv) { iv.setImageResource(R.drawable.egg); }
From source file:com.hunch.ImageManager.java
public void getTopicImage(final Context context, final ImageView image, final String imgURL) { URL url = stringToURL(imgURL); Drawable cachedDrawable = getCachedTopicImage(context, url); if (cachedDrawable != null) { // the image is in the cache image.setImageDrawable(cachedDrawable); } else {/*from ww w . ja v a 2 s . co m*/ // the image is not in the cache, must download downloadTopicDrawable(url, context, new Callback() { @Override public void callComplete(Drawable d) { image.setImageDrawable(d); } }); // set it to the placeholder image for now image.setImageResource(Const.TOPIC_DEFAULT_IMG); } }