use of android.graphics.drawable.Drawable in project nmid-headline by miao1007.
the class EditPage method genBackground.
private void genBackground() {
background = new ColorDrawable(DIM_COLOR);
if (backgroundView != null) {
try {
Bitmap bgBm = captureView(backgroundView, backgroundView.getWidth(), backgroundView.getHeight());
bgBm = blur(bgBm, 20, 8);
BitmapDrawable blurBm = new BitmapDrawable(activity.getResources(), bgBm);
background = new LayerDrawable(new Drawable[] { blurBm, background });
} catch (Throwable e) {
e.printStackTrace();
}
}
}
use of android.graphics.drawable.Drawable in project k-9 by k9mail.
the class MessageListAdapter method bindView.
@Override
public void bindView(View view, Context context, Cursor cursor) {
Account account = fragment.getAccountFromCursor(cursor);
String fromList = cursor.getString(SENDER_LIST_COLUMN);
String toList = cursor.getString(TO_LIST_COLUMN);
String ccList = cursor.getString(CC_LIST_COLUMN);
Address[] fromAddrs = Address.unpack(fromList);
Address[] toAddrs = Address.unpack(toList);
Address[] ccAddrs = Address.unpack(ccList);
boolean fromMe = fragment.messageHelper.toMe(account, fromAddrs);
boolean toMe = fragment.messageHelper.toMe(account, toAddrs);
boolean ccMe = fragment.messageHelper.toMe(account, ccAddrs);
CharSequence displayName = fragment.messageHelper.getDisplayName(account, fromAddrs, toAddrs);
CharSequence displayDate = DateUtils.getRelativeTimeSpanString(context, cursor.getLong(DATE_COLUMN));
Address counterpartyAddress = fetchCounterPartyAddress(fromMe, toAddrs, ccAddrs, fromAddrs);
int threadCount = (fragment.showingThreadedList) ? cursor.getInt(THREAD_COUNT_COLUMN) : 0;
String subject = MlfUtils.buildSubject(cursor.getString(SUBJECT_COLUMN), fragment.getString(R.string.general_no_subject), threadCount);
boolean read = (cursor.getInt(READ_COLUMN) == 1);
boolean flagged = (cursor.getInt(FLAGGED_COLUMN) == 1);
boolean answered = (cursor.getInt(ANSWERED_COLUMN) == 1);
boolean forwarded = (cursor.getInt(FORWARDED_COLUMN) == 1);
boolean hasAttachments = (cursor.getInt(ATTACHMENT_COUNT_COLUMN) > 0);
MessageViewHolder holder = (MessageViewHolder) view.getTag();
int maybeBoldTypeface = (read) ? Typeface.NORMAL : Typeface.BOLD;
long uniqueId = cursor.getLong(fragment.uniqueIdColumn);
boolean selected = fragment.selected.contains(uniqueId);
holder.chip.setBackgroundColor(account.getChipColor());
if (fragment.checkboxes) {
holder.selected.setChecked(selected);
}
if (fragment.stars) {
holder.flagged.setChecked(flagged);
}
holder.position = cursor.getPosition();
if (holder.contactBadge != null) {
updateContactBadge(holder, counterpartyAddress);
}
setBackgroundColor(view, selected, read);
if (fragment.activeMessage != null) {
changeBackgroundColorIfActiveMessage(cursor, account, view);
}
updateWithThreadCount(holder, threadCount);
CharSequence beforePreviewText = (fragment.senderAboveSubject) ? subject : displayName;
String sigil = recipientSigil(toMe, ccMe);
SpannableStringBuilder messageStringBuilder = new SpannableStringBuilder(sigil).append(beforePreviewText);
if (fragment.previewLines > 0) {
String preview = getPreview(cursor);
messageStringBuilder.append(" ").append(preview);
}
holder.preview.setText(messageStringBuilder, TextView.BufferType.SPANNABLE);
formatPreviewText(holder.preview, beforePreviewText, sigil);
Drawable statusHolder = buildStatusHolder(forwarded, answered);
if (holder.from != null) {
holder.from.setTypeface(Typeface.create(holder.from.getTypeface(), maybeBoldTypeface));
if (fragment.senderAboveSubject) {
holder.from.setCompoundDrawablesWithIntrinsicBounds(// left
statusHolder, // top
null, // right
hasAttachments ? mAttachmentIcon : null, // bottom
null);
holder.from.setText(displayName);
} else {
holder.from.setText(new SpannableStringBuilder(sigil).append(displayName));
}
}
if (holder.subject != null) {
if (!fragment.senderAboveSubject) {
holder.subject.setCompoundDrawablesWithIntrinsicBounds(// left
statusHolder, // top
null, // right
hasAttachments ? mAttachmentIcon : null, // bottom
null);
}
holder.subject.setTypeface(Typeface.create(holder.subject.getTypeface(), maybeBoldTypeface));
holder.subject.setText(subject);
}
holder.date.setText(displayDate);
}
use of android.graphics.drawable.Drawable in project qksms by moezbhatti.
the class QKActivity method colorMenuIcons.
public void colorMenuIcons(Menu menu, int color) {
// Toolbar navigation icon
Drawable navigationIcon = mToolbar.getNavigationIcon();
if (navigationIcon != null) {
navigationIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
mToolbar.setNavigationIcon(navigationIcon);
}
// Overflow icon
colorOverflowButtonWhenReady(color);
// Other icons
for (int i = 0; i < menu.size(); i++) {
MenuItem menuItem = menu.getItem(i);
Drawable newIcon = menuItem.getIcon();
if (newIcon != null) {
newIcon.setColorFilter(color, PorterDuff.Mode.SRC_ATOP);
menuItem.setIcon(newIcon);
}
}
}
use of android.graphics.drawable.Drawable in project qksms by moezbhatti.
the class SearchAdapter method onBindViewHolder.
@Override
public void onBindViewHolder(SearchViewHolder holder, int position) {
SearchData data = getItem(position);
holder.mData = data;
holder.mClickListener = mItemClickListener;
holder.root.setOnClickListener(holder);
holder.root.setOnLongClickListener(holder);
if (data.contact != null) {
Drawable avatarDrawable = data.contact.getAvatar(mContext, null);
holder.avatar.setImageDrawable(avatarDrawable);
holder.avatar.setContactName(data.contact.getName());
holder.name.setText(data.contact.getName());
} else {
holder.avatar.setImageDrawable(null);
holder.avatar.setContactName(null);
holder.name.setText(null);
}
holder.date.setText(DateFormatter.getConversationTimestamp(mContext, data.date));
if (mQuery != null) {
// We need to make the search string bold within the full message
// Get all of the start positions of the query within the messages
ArrayList<Integer> indices = new ArrayList<>();
int index = data.body.toLowerCase().indexOf(mQuery.toLowerCase());
while (index >= 0) {
indices.add(index);
index = data.body.toLowerCase().indexOf(mQuery.toLowerCase(), index + 1);
}
// Make all instances of the search query bold
SpannableStringBuilder sb = new SpannableStringBuilder(data.body);
for (int i : indices) {
StyleSpan span = new StyleSpan(Typeface.BOLD);
sb.setSpan(span, i, i + mQuery.length(), Spannable.SPAN_EXCLUSIVE_INCLUSIVE);
}
holder.snippet.setText(sb);
}
}
use of android.graphics.drawable.Drawable in project Signal-Android by WhisperSystems.
the class MultiWaveView method internalSetTargetResources.
private void internalSetTargetResources(int resourceId) {
Resources res = getContext().getResources();
TypedArray array = res.obtainTypedArray(resourceId);
int count = array.length();
ArrayList<TargetDrawable> targetDrawables = new ArrayList<TargetDrawable>(count);
for (int i = 0; i < count; i++) {
Drawable drawable = array.getDrawable(i);
targetDrawables.add(new TargetDrawable(res, drawable));
}
array.recycle();
mTargetResourceId = resourceId;
mTargetDrawables = targetDrawables;
updateTargetPositions();
}
Aggregations