List of usage examples for android.text.format DateUtils FORMAT_ABBREV_RELATIVE
int FORMAT_ABBREV_RELATIVE
To view the source code for android.text.format DateUtils FORMAT_ABBREV_RELATIVE.
Click Source Link
From source file:com.abcvoipsip.ui.messages.ConverstationsAdapter.java
@Override public void bindView(View view, Context context, Cursor cursor) { super.bindView(view, context, cursor); final ConversationListItemViews tagView = (ConversationListItemViews) view.getTag(); String nbr = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM)); String fromFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL)); String to_number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_TO)); //int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ)); long date = cursor.getLong(cursor.getColumnIndex(SipMessage.FIELD_DATE)); tagView.fromFull = fromFull;/*from www .j a v a 2 s . c o m*/ tagView.to = to_number; tagView.from = nbr; tagView.position = cursor.getPosition(); /* Drawable background = (read == 0)? context.getResources().getDrawable(R.drawable.conversation_item_background_unread) : context.getResources().getDrawable(R.drawable.conversation_item_background_read); view.setBackgroundDrawable(background); */ String number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL)); CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, number); /* final Uri lookupUri = info.contactContentUri; final String name = info.name; final int ntype = info.numberType; final String label = info.phoneLabel; CharSequence formattedNumber = SipUri.getCanonicalSipContact(number, false); */ // Photo tagView.quickContactView.assignContactUri(info.contactContentUri); ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, SipHome.USE_LIGHT_THEME ? R.drawable.ic_contact_picture_holo_light : R.drawable.ic_contact_picture_holo_dark); // From tagView.fromView.setText(formatMessage(cursor)); //Date // Set the date/time field by mixing relative and absolute times. int flags = DateUtils.FORMAT_ABBREV_RELATIVE; tagView.dateView.setText(DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags)); }
From source file:com.gdgdevfest.android.apps.devfestbcn.ui.PlusStreamRowViewBinder.java
public static void bindActivityView(final View rootView, Activity activity, ImageLoader imageLoader, boolean singleSourceMode) { // Prepare view holder. ViewHolder tempViews = (ViewHolder) rootView.getTag(); final ViewHolder views; if (tempViews != null) { views = tempViews;/*from w ww. j av a 2 s. c o m*/ } else { views = new ViewHolder(); rootView.setTag(views); // Author and metadata box views.authorContainer = rootView.findViewById(R.id.stream_author_container); views.userImage = (ImageView) rootView.findViewById(R.id.stream_user_image); views.userName = (TextView) rootView.findViewById(R.id.stream_user_name); views.time = (TextView) rootView.findViewById(R.id.stream_time); // Author's content views.content = (TextView) rootView.findViewById(R.id.stream_content); // Original share box views.originalContainer = rootView.findViewById(R.id.stream_original_container); views.originalAuthor = (TextView) rootView.findViewById(R.id.stream_original_author); views.originalContent = (TextView) rootView.findViewById(R.id.stream_original_content); // Media box views.mediaContainer = rootView.findViewById(R.id.stream_media_container); views.mediaBackground = (ImageView) rootView.findViewById(R.id.stream_media_background); views.mediaOverlay = (ImageView) rootView.findViewById(R.id.stream_media_overlay); views.mediaTitle = (TextView) rootView.findViewById(R.id.stream_media_title); views.mediaSubtitle = (TextView) rootView.findViewById(R.id.stream_media_subtitle); // Interactions box views.interactionsContainer = rootView.findViewById(R.id.stream_interactions_container); views.plusOnes = (TextView) rootView.findViewById(R.id.stream_plus_ones); views.shares = (TextView) rootView.findViewById(R.id.stream_shares); views.comments = (TextView) rootView.findViewById(R.id.stream_comments); } final Context context = rootView.getContext(); final Resources res = context.getResources(); // Determine if this is a reshare (affects how activity fields are to be interpreted). Activity.PlusObject.Actor originalAuthor = activity.getObject().getActor(); boolean isReshare = "share".equals(activity.getVerb()) && originalAuthor != null; // Author and metadata box views.authorContainer.setVisibility(singleSourceMode ? View.GONE : View.VISIBLE); views.userName.setText(activity.getActor().getDisplayName()); // Find user profile image url String userImageUrl = null; if (activity.getActor().getImage() != null) { userImageUrl = activity.getActor().getImage().getUrl(); } // Load image from network in background thread using Volley library imageLoader.get(userImageUrl, views.userImage, PLACEHOLDER_USER_IMAGE); long thenUTC = activity.getUpdated().getValue() + activity.getUpdated().getTimeZoneShift() * 60000; views.time.setText(DateUtils.getRelativeTimeSpanString(thenUTC, System.currentTimeMillis(), DateUtils.SECOND_IN_MILLIS, DateUtils.FORMAT_ABBREV_MONTH | DateUtils.FORMAT_ABBREV_RELATIVE)); // Author's additional content String selfContent = isReshare ? activity.getAnnotation() : activity.getObject().getContent(); views.content.setMaxLines(singleSourceMode ? 1000 : 5); if (!TextUtils.isEmpty(selfContent)) { views.content.setVisibility(View.VISIBLE); views.content.setText(Html.fromHtml(selfContent)); } else { views.content.setVisibility(View.GONE); } // Original share box if (isReshare) { views.originalContainer.setVisibility(View.VISIBLE); // Set original author text, highlight author name final String author = res.getString(R.string.stream_originally_shared, originalAuthor.getDisplayName()); final SpannableStringBuilder spannableAuthor = new SpannableStringBuilder(author); spannableAuthor.setSpan(new StyleSpan(Typeface.BOLD), author.length() - originalAuthor.getDisplayName().length(), author.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE); views.originalAuthor.setText(spannableAuthor, TextView.BufferType.SPANNABLE); String originalContent = activity.getObject().getContent(); views.originalContent.setMaxLines(singleSourceMode ? 1000 : 3); if (!TextUtils.isEmpty(originalContent)) { views.originalContent.setVisibility(View.VISIBLE); views.originalContent.setText(Html.fromHtml(originalContent)); } else { views.originalContent.setVisibility(View.GONE); } } else { views.originalContainer.setVisibility(View.GONE); } // Media box // Set media content. List<Activity.PlusObject.Attachments> attachments = activity.getObject().getAttachments(); if (attachments != null && attachments.size() > 0) { Activity.PlusObject.Attachments attachment = attachments.get(0); String objectType = attachment.getObjectType(); String imageUrl = attachment.getImage() != null ? attachment.getImage().getUrl() : null; if (imageUrl == null && attachment.getThumbnails() != null && attachment.getThumbnails().size() > 0) { Thumbnails thumb = attachment.getThumbnails().get(0); imageUrl = thumb.getImage() != null ? thumb.getImage().getUrl() : null; } // Load image from network in background thread using Volley library imageLoader.get(imageUrl, views.mediaBackground, PLACEHOLDER_MEDIA_IMAGE); boolean overlayStyle = false; views.mediaOverlay.setImageDrawable(null); if (("photo".equals(objectType) || "video".equals(objectType) || "album".equals(objectType)) && !TextUtils.isEmpty(imageUrl)) { overlayStyle = true; views.mediaOverlay .setImageResource("video".equals(objectType) ? R.drawable.ic_stream_media_overlay_video : R.drawable.ic_stream_media_overlay_photo); } else if ("article".equals(objectType) || "event".equals(objectType)) { overlayStyle = false; views.mediaTitle.setText(attachment.getDisplayName()); if (!TextUtils.isEmpty(attachment.getUrl())) { Uri uri = Uri.parse(attachment.getUrl()); views.mediaSubtitle.setText(uri.getHost()); } else { views.mediaSubtitle.setText(""); } } views.mediaContainer.setVisibility(View.VISIBLE); views.mediaContainer.setBackgroundResource( overlayStyle ? R.color.plus_stream_media_background : android.R.color.black); if (overlayStyle) { views.mediaBackground.clearColorFilter(); } else { views.mediaBackground.setColorFilter(res.getColor(R.color.plus_media_item_tint)); } views.mediaOverlay.setVisibility(overlayStyle ? View.VISIBLE : View.GONE); views.mediaTitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE); views.mediaSubtitle.setVisibility(overlayStyle ? View.GONE : View.VISIBLE); } else { views.mediaContainer.setVisibility(View.GONE); views.mediaBackground.setImageDrawable(null); views.mediaOverlay.setImageDrawable(null); } // Interactions box final int plusOneCount = (activity.getObject().getPlusoners() != null) ? activity.getObject().getPlusoners().getTotalItems().intValue() : 0; if (plusOneCount > 0) { views.plusOnes.setVisibility(View.VISIBLE); views.plusOnes.setText(getPlusOneString(plusOneCount)); } else { views.plusOnes.setVisibility(View.GONE); } final int commentCount = (activity.getObject().getReplies() != null) ? activity.getObject().getReplies().getTotalItems().intValue() : 0; if (commentCount > 0) { views.comments.setVisibility(View.VISIBLE); views.comments.setText(Integer.toString(commentCount)); } else { views.comments.setVisibility(View.GONE); } final int resharerCount = (activity.getObject().getResharers() != null) ? activity.getObject().getResharers().getTotalItems().intValue() : 0; if (resharerCount > 0) { views.shares.setVisibility(View.VISIBLE); views.shares.setText(Integer.toString(resharerCount)); } else { views.shares.setVisibility(View.GONE); } views.interactionsContainer.setVisibility( (plusOneCount > 0 || commentCount > 0 || resharerCount > 0) ? View.VISIBLE : View.GONE); }
From source file:com.roamprocess1.roaming4world.ui.messages.ConversationsAdapter.java
@SuppressLint("SdCardPath") @Override// w w w . j a va 2s . c o m public void bindView(View view, Context context, Cursor cursor) { super.bindView(view, context, cursor); System.out.println("Conversationlist:bindView"); final ConversationListItemViews tagView = (ConversationListItemViews) view.getTag(); String nbr = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM)); String fromFull = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL)); String to_number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_TO)); int read = cursor.getInt(cursor.getColumnIndex(SipMessage.FIELD_READ)); long date = cursor.getLong(cursor.getColumnIndex(SipMessage.FIELD_DATE)); DBProvider db = new DBProvider(); Cursor cr = db.allMessage(to_number, fromFull, context); cr.moveToLast(); SipMessage msg1 = new SipMessage(cr); String lastMessage = msg1.getBodyContent(); if (lastMessage.contains("[Offline message -") && !nbr.equals("sip:registrar@kamailio.org")) { System.out.println("offline message"); String[] finalMessage = lastMessage.split("]"); lastMessage = finalMessage[finalMessage.length - 1]; } TextView txtview = (TextView) view.findViewById(R.id.subject); if (lastMessage.startsWith("R4WIMGTOCONTACTCHATSEND@@")) { txtview.setText("Image"); } else { txtview.setText(lastMessage); } tagView.fromFull = fromFull; tagView.to = to_number; tagView.from = nbr; tagView.position = cursor.getPosition(); /* Drawable background = (read == 0)? context.getResources().getDrawable(R.drawable.conversation_item_background_unread) : context.getResources().getDrawable(R.drawable.conversation_item_background_read); view.setBackgroundDrawable(background); */ String number = cursor.getString(cursor.getColumnIndex(SipMessage.FIELD_FROM_FULL)); CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, number); // Photo tagView.quickContactView.assignContactUri(info.contactContentUri); Log.setLogLevel(6); Log.d("Conversation adapter number", number); String nu = StaticValues.getStripNumber(number); String path = "/sdcard/R4W/ProfilePic/" + nu + ".png"; System.out.println("msg adp out - path=" + path); File imageFile = new File(path); if (imageFile.exists()) { try { Bitmap bm = BitmapFactory.decodeFile(path); bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth()); tagView.quickContactView.getImageView().setImageBitmap(bm); } catch (Exception e) { // TODO: handle exception try { tagView.quickContactView.getImageView().setImageURI(Uri.parse(path)); } catch (Exception e2) { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); // TODO: handle exception } } } else { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); } // From System.out.println("formatMessage(cursor):" + formatMessage(cursor)); tagView.fromView.setText(formatMessage(cursor)); //Date // Set the date/time field by mixing relative and absolute times. int flags = DateUtils.FORMAT_ABBREV_RELATIVE; tagView.dateView.setText(DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags)); }
From source file:com.roamprocess1.roaming4world.ui.messages.MessageAdapter.java
@SuppressLint("SdCardPath") @Override//from www . j a va 2 s. c o m public void bindView(View view, Context context, Cursor cursor) { System.out.println("MessageAdapter.java in bindView() "); final MessageListItemViews tagView = (MessageListItemViews) view.getTag(); v = view; this.context = context; SipMessage msg = new SipMessage(cursor); // System.out.println("msg:"+msg); System.out.println("Cursor row count:" + cursor.getCount()); String number = msg.getRemoteNumber(); long date = msg.getDate(); String message = msg.getBodyContent(); subject = message; System.out.println("subject--" + subject); if (message.contains("[Offline message -") && !number.equals("sip:registrar@kamailio.org")) { System.out.println("offline message"); String[] finalMessage = message.split("]"); subject = finalMessage[finalMessage.length - 1]; } else { subject = message; } String errorTxt = msg.getErrorContent(); String mimeType = msg.getMimeType(); int type = msg.getType(); Log.setLogLevel(6); Log.d("Col count", cursor.getColumnCount() + " @"); String[] columnname = cursor.getColumnNames(); for (int i = 0; i < columnname.length; i++) { Log.d("columnname " + i, columnname[i] + " @"); Log.d(columnname[i], cursor.getString(cursor.getColumnIndex(columnname[i])) + " @"); } tv_msg_info = (TextView) view.findViewById(R.id.tv_msg_info); pb_uploading = (ProgressBar) view.findViewById(R.id.pb_uploading); String timestamp = ""; if (System.currentTimeMillis() - date > 1000 * 60 * 60 * 24) { // If it was recieved one day ago or more display relative // timestamp - SMS like behavior int flags = DateUtils.FORMAT_ABBREV_RELATIVE; timestamp = (String) DateUtils.getRelativeTimeSpanString(date, System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, flags); } else { // If it has been recieved recently show time of reception - IM // like behavior timestamp = dateFormatter.format(new Date(date)); } tagView.dateView.setText(timestamp); // Delivery state if (type == SipMessage.MESSAGE_TYPE_QUEUED) { tagView.deliveredIndicator.setVisibility(View.VISIBLE); tagView.deliveredIndicator.setImageResource(R.drawable.error_watch_not_send); tagView.deliveredIndicator.setContentDescription(""); } else if (type == SipMessage.MESSAGE_TYPE_FAILED) { tagView.deliveredIndicator.setVisibility(View.VISIBLE); tagView.deliveredIndicator.setImageResource(R.drawable.error_watch_not_send); tagView.deliveredIndicator.setContentDescription(""); } else { tagView.deliveredIndicator.setVisibility(View.VISIBLE); tagView.deliveredIndicator.setImageResource(R.drawable.todo_send); tagView.deliveredIndicator.setContentDescription(""); } if (TextUtils.isEmpty(errorTxt)) { tagView.errorView.setVisibility(View.GONE); } else { tagView.errorView.setVisibility(View.GONE); tagView.errorView.setText(errorTxt); } // Subject tagView.contentView.setText(formatMessage(number, subject, mimeType)); if (msg.isOutgoing()) { setPhotoSide(tagView, ArrowPosition.LEFT); LinearLayout linerLayout = (LinearLayout) view.findViewById(R.id.message_block); linerLayout.setBackgroundResource(R.drawable.chatedittextdesign); text_view = (TextView) view.findViewById(R.id.text_view); text_view.setTextColor(Color.BLACK); // Photo tagView.quickContactView.assignContactUri(personalInfo.contactContentUri); /* ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), personalInfo, R.drawable.ic_contact_picture_holo_dark); */ System.out.println("msg adp out - 0"); String path = "/sdcard/R4W/ProfilePic/ProfilePic.png"; File user_imageFile = new File(path); if (user_imageFile.exists()) { try { if (bm != null) { // bm = null; } bm = BitmapFactory.decodeFile(path); bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth()); tagView.quickContactView.getImageView().setImageBitmap(bm); } catch (Exception e) { // TODO: handle exception try { tagView.quickContactView.getImageView().setImageURI(Uri.parse(path)); } catch (Exception e2) { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), personalInfo, R.drawable.ic_contact_picture_holo_dark); // TODO: handle exception } } } else { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), personalInfo, R.drawable.ic_contact_picture_holo_dark); } outgoingImage(number); } else { setPhotoSide(tagView, ArrowPosition.RIGHT); LinearLayout linerLayout = (LinearLayout) view.findViewById(R.id.message_block); linerLayout.setBackgroundResource(R.drawable.messagebodyleft); // Contact CallerInfo info = CallerInfo.getCallerInfoFromSipUri(mContext, msg.getFullFrom()); text_view = (TextView) view.findViewById(R.id.text_view); text_view.setTextColor(Color.BLACK); pb_uploading.setVisibility(ProgressBar.GONE); // Photo tagView.quickContactView.assignContactUri(info.contactContentUri); /* ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); */ System.out.println("msg adp in - 1"); String nu = stripNumber(number); String path = "/sdcard/R4W/ProfilePic/" + nu + ".png"; System.out.println("msg adp out - path=" + path); File user_imageFile = new File(path); if (user_imageFile.exists()) { try { if (bm != null) { // bm = null; } bm = BitmapFactory.decodeFile(path); bm = ImageHelperCircular.getRoundedCornerBitmap(bm, bm.getWidth()); tagView.quickContactView.getImageView().setImageBitmap(bm); } catch (Exception e) { // TODO: handle exception try { tagView.quickContactView.getImageView().setImageURI(Uri.parse(path)); } catch (Exception e2) { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); // TODO: handle exception } } } else { ContactsAsyncHelper.updateImageViewWithContactPhotoAsync(mContext, tagView.quickContactView.getImageView(), info, R.drawable.ic_contact_picture_holo_dark); } incomingImage(); } }
From source file:com.android.dialer.calllog.PhoneCallDetailsHelper.java
/** * Get the call date/time of the call. For the call log this is relative to the current time. * e.g. 3 minutes ago. For voicemail, see {@link #getGranularDateTime(PhoneCallDetails)} * * @param details Call details to use./*w ww . j a va 2s . c o m*/ * @return String representing when the call occurred. */ public CharSequence getCallDate(PhoneCallDetails details) { if (details.callTypes[0] == Calls.VOICEMAIL_TYPE) { return getGranularDateTime(details); } return DateUtils.getRelativeTimeSpanString(details.date, getCurrentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); }
From source file:com.ohso.omgubuntu.ArticleActivity.java
private void setContents(Article article) { CharSequence date = DateUtils.getRelativeTimeSpanString(article.getDate(), new Date().getTime(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); StringBuilder content = new StringBuilder(); content.append(//from w w w. j a v a 2 s . co m "<!DOCTYPE html><head><link rel='stylesheet' type='text/css' href='style.css'></head><body>"); content.append("<h1 id='article-title'>" + article.getTitle() + "</h1>"); content.append("<div class='metadata'>"); content.append("<span class='author'>" + article.getAuthor() + "</span>"); content.append("<span class='date'>" + date + "</span></div>"); content.append("<div class='post'>"); content.append(article.getContent()); content.append("<h2 class='internal-comments-link'><a href='internal://app-comments'>" + getResources().getString(R.string.activity_article_comment_text) + "</a></h2></div></body></html>"); webview.loadDataWithBaseURL("file:///android_asset/", content.toString(), "text/html", "UTF-8", getResources().getString(R.string.base_url) + article.getPath()); }
From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java
private void bindRcsGroupChatEvent(View view, Cursor cursor) { BasicViewHolder holder = (BasicViewHolder) view.getTag(); holder.getTimestampText()/*w w w .j a va 2s . com*/ .setText(DateUtils.getRelativeTimeSpanString(cursor.getLong(holder.getColumnTimestampIdx()), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); String event = RiApplication.sGroupChatEvents[cursor.getInt(holder.getColumnStatusIdx())]; holder.getStatusText().setText(mActivity.getString(R.string.label_groupchat_event, event)); }
From source file:com.gsma.rcs.ri.messaging.adapter.TalkCursorAdapter.java
private void bindRcsFileTransferOutView(View view, Cursor cursor) { RcsFileTransferOutViewHolder holder = (RcsFileTransferOutViewHolder) view.getTag(); holder.getTimestampText()/*from w w w. j a v a 2 s . c o m*/ .setText(DateUtils.getRelativeTimeSpanString(cursor.getLong(holder.getColumnTimestampIdx()), System.currentTimeMillis(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE)); String mimeType = cursor.getString(holder.getColumnMimetypeIdx()); StringBuilder sb = new StringBuilder(cursor.getString(holder.getColumnFilenameIdx())); long filesize = cursor.getLong(holder.getColumnFilesizeIdx()); long transferred = cursor.getLong(holder.getColumnTransferredIdx()); final ImageView imageView = holder.getFileImageView(); imageView.setOnClickListener(null); imageView.setLayoutParams(mImageParamsDefault); imageView.setImageResource(R.drawable.ri_filetransfer_on); if (filesize != transferred) { holder.getProgressText() .setText(sb.append(" : ").append(Utils.getProgressLabel(transferred, filesize)).toString()); } else { holder.getProgressText().setText(sb.append(" (") .append(FileUtils.humanReadableByteCount(filesize, true)).append(")").toString()); } final Uri file = Uri.parse(cursor.getString(holder.getColumnContentIdx())); if (Utils.isImageType(mimeType)) { String filePath = FileUtils.getPath(mContext, file); Bitmap imageBitmap = null; if (filePath != null) { LruCache<String, BitmapCacheInfo> memoryCache = bitmapCache.getMemoryCache(); BitmapCacheInfo bitmapCacheInfo = memoryCache.get(filePath); if (bitmapCacheInfo == null) { ImageBitmapLoader loader = new ImageBitmapLoader(mContext, memoryCache, MAX_IMAGE_WIDTH, MAX_IMAGE_HEIGHT, new BitmapLoader.SetViewCallback() { @Override public void loadView(BitmapCacheInfo cacheInfo) { imageView.setImageBitmap(cacheInfo.getBitmap()); imageView.setLayoutParams(mImageParams); } }); loader.execute(filePath); } else { imageBitmap = bitmapCacheInfo.getBitmap(); } if (imageBitmap != null) { imageView.setImageBitmap(imageBitmap); imageView.setLayoutParams(mImageParams); } imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.showPicture(mActivity, file); } }); } } else if (Utils.isAudioType(mimeType)) { imageView.setImageResource(R.drawable.headphone); imageView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { Utils.playAudio(mActivity, file); } }); } holder.getStatusText().setText(getRcsFileTransferStatus(cursor, holder)); boolean undeliveredExpiration = cursor.getInt(holder.getColumnExpiredDeliveryIdx()) == 1; holder.getStatusText().setCompoundDrawablesWithIntrinsicBounds( undeliveredExpiration ? R.drawable.chat_view_undelivered : 0, 0, 0, 0); }
From source file:com.todoroo.astrid.notes.EditNoteActivity.java
/** Helper method to set the contents and visibility of each field */ public synchronized void bindView(View view, NoteOrUpdate item) { // name//from w w w . j av a2 s. co m final TextView nameView = (TextView) view.findViewById(R.id.title); { nameView.setText(item.title); Linkify.addLinks(nameView, Linkify.ALL); } // date final TextView date = (TextView) view.findViewById(R.id.date); { CharSequence dateString = DateUtils.getRelativeTimeSpanString(item.createdAt, DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); date.setText(dateString); } // picture final ImageView commentPictureView = (ImageView) view.findViewById(R.id.comment_picture); setupImagePopupForCommentView(view, commentPictureView, item.commentBitmap, fragment); }
From source file:com.todoroo.astrid.adapter.UpdateAdapter.java
private void setupUserActivityRow(View view, UserActivity activity, User user) { final AsyncImageView pictureView = (AsyncImageView) view.findViewById(R.id.picture); {/*from w w w . j a va 2 s . c o m*/ if (user.containsNonNullValue(USER_PICTURE)) { String pictureUrl = user.getPictureUrl(USER_PICTURE, RemoteModel.PICTURE_THUMB); pictureView.setUrl(pictureUrl); } else { pictureView.setUrl(null); } pictureView.setVisibility(View.VISIBLE); } final AsyncImageView commentPictureView = (AsyncImageView) view.findViewById(R.id.comment_picture); { String pictureThumb = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_MEDIUM); String pictureFull = activity.getPictureUrl(UserActivity.PICTURE, RemoteModel.PICTURE_LARGE); Bitmap updateBitmap = null; if (TextUtils.isEmpty(pictureThumb)) updateBitmap = activity.getPictureBitmap(UserActivity.PICTURE); setupImagePopupForCommentView(view, commentPictureView, pictureThumb, pictureFull, updateBitmap, activity.getValue(UserActivity.MESSAGE), fragment, imageCache); } // name final TextView nameView = (TextView) view.findViewById(R.id.title); { nameView.setText( getUpdateComment((AstridActivity) fragment.getActivity(), activity, user, linkColor, fromView)); nameView.setMovementMethod(new LinkMovementMethod()); nameView.setTextColor(color); } // date final TextView date = (TextView) view.findViewById(R.id.date); { CharSequence dateString = DateUtils.getRelativeTimeSpanString( activity.getValue(UserActivity.CREATED_AT), DateUtilities.now(), DateUtils.MINUTE_IN_MILLIS, DateUtils.FORMAT_ABBREV_RELATIVE); date.setText(dateString); } }