當前位置: 首頁>>代碼示例>>Java>>正文


Java Builder.setStyle方法代碼示例

本文整理匯總了Java中android.support.v4.app.NotificationCompat.Builder.setStyle方法的典型用法代碼示例。如果您正苦於以下問題:Java Builder.setStyle方法的具體用法?Java Builder.setStyle怎麽用?Java Builder.setStyle使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.support.v4.app.NotificationCompat.Builder的用法示例。


在下文中一共展示了Builder.setStyle方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: modifyForConference

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
	final Message first = messages.get(0);
	final Message last = messages.get(messages.size() - 1);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(conversation.getName());

	for(Message message : messages) {
		if (message.hasMeCommand()) {
			style.addLine(UIHelper.getMessagePreview(mXmppConnectionService,message).first);
		} else {
			style.addLine(Html.fromHtml("<b>" + UIHelper.getMessageDisplayName(message) + "</b>: " + UIHelper.getMessagePreview(mXmppConnectionService, message).first));
		}
	}
	builder.setContentText((first.hasMeCommand() ? "" :UIHelper.getMessageDisplayName(first)+ ": ") +UIHelper.getMessagePreview(mXmppConnectionService, first).first);
	builder.setStyle(style);
	if (notify) {
		builder.setTicker((last.hasMeCommand() ? "" : UIHelper.getMessageDisplayName(last) + ": ") + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
	}
}
 
開發者ID:Frozenbox,項目名稱:frozenchat,代碼行數:20,代碼來源:NotificationService.java

示例2: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final Message message,
		final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
			.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getDownloadable() == null) {
				tmp.add(msg);
					}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(getReadableBody(tmp.get(0)));
		} else {
			builder.setContentText(mXmppConnectionService.getString(R.string.image_file));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:26,代碼來源:NotificationService.java

示例3: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
							final Message message, final ArrayList<Message> messages) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			CharSequence text = getMergedBodies(tmp);
			bigPictureStyle.setSummaryText(text);
			builder.setContentText(text);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, uBuilder, messages);
	}
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:29,代碼來源:NotificationService.java

示例4: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	final StringBuilder names = new StringBuilder();
	Conversation conversation = null;
	for (final ArrayList<Message> messages : notifications.values()) {
		if (messages.size() > 0) {
			conversation = messages.get(0).getConversation();
			final String name = conversation.getName();
			if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
				int count = messages.size();
				style.addLine(Html.fromHtml("<b>"+name+"</b> "+mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count)));
			} else {
				style.addLine(Html.fromHtml("<b>" + name + "</b> "
						+ UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first));
			}
			names.append(name);
			names.append(", ");
		}
	}
	if (names.length() >= 2) {
		names.delete(names.length() - 2, names.length());
	}
	mBuilder.setContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	mBuilder.setContentText(names.toString());
	mBuilder.setStyle(style);
	if (conversation != null) {
		mBuilder.setContentIntent(createContentIntent(conversation));
	}
	return mBuilder;
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:40,代碼來源:NotificationService.java

示例5: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final Message message,
							final ArrayList<Message> messages, final boolean notify) {
	try {
		final Bitmap bitmap = mXmppConnectionService.getFileBackend()
				.getThumbnail(message, getPixel(288), false);
		final ArrayList<Message> tmp = new ArrayList<>();
		for (final Message msg : messages) {
			if (msg.getType() == Message.TYPE_TEXT
					&& msg.getTransferable() == null) {
				tmp.add(msg);
			}
		}
		final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
		bigPictureStyle.bigPicture(bitmap);
		if (tmp.size() > 0) {
			bigPictureStyle.setSummaryText(getMergedBodies(tmp));
			builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, tmp.get(0)).first);
		} else {
			builder.setContentText(mXmppConnectionService.getString(
					R.string.received_x_file,
					UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
		}
		builder.setStyle(bigPictureStyle);
	} catch (final FileNotFoundException e) {
		modifyForTextOnly(builder, messages, notify);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:28,代碼來源:NotificationService.java

示例6: modifyForTextOnly

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForTextOnly(final Builder builder,
							   final ArrayList<Message> messages, final boolean notify) {
	builder.setStyle(new NotificationCompat.BigTextStyle().bigText(getMergedBodies(messages)));
	builder.setContentText(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
	if (notify) {
		builder.setTicker(UIHelper.getMessagePreview(mXmppConnectionService, messages.get(messages.size() - 1)).first);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:9,代碼來源:NotificationService.java

示例7: modifyForConference

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForConference(Builder builder, Conversation conversation, List<Message> messages, boolean notify) {
	final Message first = messages.get(0);
	final Message last = messages.get(messages.size() - 1);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(conversation.getName());
	for(Message message : messages) {
		style.addLine(Html.fromHtml("<b>"+UIHelper.getMessageDisplayName(message)+"</b> "+UIHelper.getMessagePreview(mXmppConnectionService,message).first));
	}
	builder.setContentText(UIHelper.getMessageDisplayName(first)+ ": " +UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
	builder.setStyle(style);
	if (notify) {
		builder.setTicker(UIHelper.getMessageDisplayName(last) + ": " + UIHelper.getMessagePreview(mXmppConnectionService,last).first);
	}
}
 
開發者ID:xavierle,項目名稱:messengerxmpp,代碼行數:15,代碼來源:NotificationService.java

示例8: modifyForImage

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForImage(final Builder builder, final UnreadConversation.Builder uBuilder,
                            final Message message, final ArrayList<Message> messages) {
    try {
        final Bitmap bitmap = mXmppConnectionService.getFileBackend()
                .getThumbnail(message, getPixel(288), false);
        final ArrayList<Message> tmp = new ArrayList<>();
        for (final Message msg : messages) {
            if (msg.getType() == Message.TYPE_TEXT
                    && msg.getTransferable() == null) {
                tmp.add(msg);
            }
        }
        final BigPictureStyle bigPictureStyle = new NotificationCompat.BigPictureStyle();
        bigPictureStyle.bigPicture(bitmap);
        if (tmp.size() > 0) {
            CharSequence text = getMergedBodies(tmp);
            bigPictureStyle.setSummaryText(text);
            builder.setContentText(text);
        } else {
            builder.setContentText(mXmppConnectionService.getString(
                    R.string.received_x_file,
                    UIHelper.getFileDescriptionString(mXmppConnectionService, message)));
        }
        builder.setStyle(bigPictureStyle);
    } catch (final FileNotFoundException e) {
        modifyForTextOnly(builder, uBuilder, messages);
    }
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:29,代碼來源:NotificationService.java

示例9: Notification

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void Notification(PushNotification noti, Context context) {
        NotificationDBProvider dbProvider = NotificationDBProvider.getInstance(context);
        PendingIntent pendingIntent = getPendingIntent(context, DummyActivity.class);

        ArrayList<String> messages = dbProvider.getUnReadMessageTitle6();
        int count = dbProvider.getUnReadMessageCount();
        Builder builder = new NotificationCompat.Builder(context);
        if (count > 1) {
            if (count > 9999) {
                builder.setContentTitle("9999+" + context.getString(R.string.new_notification));
            } else {
                builder.setContentTitle(String.valueOf(count) + context.getString(R.string.new_notification));
            }
            InboxStyle style = new InboxStyle(builder);
            if (count > messages.size()) {
                count = messages.size();
            }
            for (int i = 0; i < count; i++) {
                style.addLine(messages.get(i));
            }
//			style.setSummaryText("+ more");
            builder.setStyle(style);
        } else {
            builder.setContentTitle(noti.title);
            builder.setContentText(noti.message);
        }
        commonBuilder(builder, pendingIntent, noti.message);
        NotificationManager notifyManager = (NotificationManager) context.getSystemService(Context.NOTIFICATION_SERVICE);
        notifyManager.notify(0, builder.build());

        Intent intentBoradCast = new Intent(Setting.BROADCAST_ALARM_UPDATE);
        LocalBroadcastManager.getInstance(context).sendBroadcast(intentBoradCast);
    }
 
開發者ID:BioStar2,項目名稱:BioStar2Android,代碼行數:34,代碼來源:GcmBroadcastReceiver.java

示例10: setInboxStyle

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
public static void setInboxStyle(Builder builder, String title, List<String> lines)
{
	builder.setNumber(lines.size());
	InboxStyle inboxStyle = new InboxStyle();

	inboxStyle.setBigContentTitle(title);

	for (String line : lines)
	{
		inboxStyle.addLine(line);
	}

	builder.setStyle(inboxStyle);
}
 
開發者ID:jonathangerbaud,項目名稱:Klyph,代碼行數:15,代碼來源:KlyphNotification.java

示例11: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	final StringBuilder names = new StringBuilder();
	Conversation conversation = null;
	for (final ArrayList<Message> messages : notifications.values()) {
		if (messages.size() > 0) {
			conversation = messages.get(0).getConversation();
			final String name = conversation.getName();
			if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
				int count = messages.size();
				style.addLine(Html.fromHtml("<b>"+name+"</b>: "+mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count)));
			} else {
				style.addLine(Html.fromHtml("<b>" + name + "</b>: "
						+ UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first));
			}
			names.append(name);
			names.append(", ");
		}
	}
	if (names.length() >= 2) {
		names.delete(names.length() - 2, names.length());
	}
	mBuilder.setContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	mBuilder.setContentText(names.toString());
	mBuilder.setStyle(style);
	if (conversation != null) {
		mBuilder.setContentIntent(createContentIntent(conversation));
	}
	return mBuilder;
}
 
開發者ID:Frozenbox,項目名稱:frozenchat,代碼行數:40,代碼來源:NotificationService.java

示例12: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	final StringBuilder names = new StringBuilder();
	Conversation conversation = null;
	for (ArrayList<Message> messages : notifications.values()) {
		if (messages.size() > 0) {
			conversation = messages.get(0).getConversation();
			String name = conversation.getName();
			style.addLine(Html.fromHtml("<b>" + name + "</b> "
						+ getReadableBody(messages.get(0))));
			names.append(name);
			names.append(", ");
		}
	}
	if (names.length() >= 2) {
		names.delete(names.length() - 2, names.length());
	}
	mBuilder.setContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	mBuilder.setContentText(names.toString());
	mBuilder.setStyle(style);
	if (conversation != null) {
		mBuilder.setContentIntent(createContentIntent(conversation
					.getUuid()));
	}
	return mBuilder;
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:36,代碼來源:NotificationService.java

示例13: modifyForTextOnly

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private void modifyForTextOnly(final Builder builder,
		final ArrayList<Message> messages, final boolean notify) {
	builder.setStyle(new NotificationCompat.BigTextStyle()
			.bigText(getMergedBodies(messages)));
	builder.setContentText(getReadableBody(messages.get(0)));
	if (notify) {
		builder.setTicker(getReadableBody(messages.get(messages.size() - 1)));
	}
}
 
開發者ID:juanignaciomolina,項目名稱:txtr,代碼行數:10,代碼來源:NotificationService.java

示例14: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
	final Builder mBuilder = new NotificationCompat.Builder(
			mXmppConnectionService);
	final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
	style.setBigContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	final StringBuilder names = new StringBuilder();
	Conversation conversation = null;
	for (final ArrayList<Message> messages : notifications.values()) {
		if (messages.size() > 0) {
			conversation = messages.get(0).getConversation();
			final String name = conversation.getName();
			SpannableString styledString;
			if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
				int count = messages.size();
				styledString = new SpannableString(name + ": " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages,count,count));
				styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
				style.addLine(styledString);
			} else {
				styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
				styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
				style.addLine(styledString);
			}
			names.append(name);
			names.append(", ");
		}
	}
	if (names.length() >= 2) {
		names.delete(names.length() - 2, names.length());
	}
	mBuilder.setContentTitle(notifications.size()
			+ " "
			+ mXmppConnectionService
			.getString(R.string.unread_conversations));
	mBuilder.setContentText(names.toString());
	mBuilder.setStyle(style);
	if (conversation != null) {
		mBuilder.setContentIntent(createContentIntent(conversation));
	}
	mBuilder.setGroupSummary(true);
	mBuilder.setGroup(CONVERSATIONS_GROUP);
	mBuilder.setDeleteIntent(createDeleteIntent(null));
	mBuilder.setSmallIcon(R.drawable.ic_notification);
	return mBuilder;
}
 
開發者ID:syntafin,項目名稱:TenguChat,代碼行數:48,代碼來源:NotificationService.java

示例15: buildMultipleConversation

import android.support.v4.app.NotificationCompat.Builder; //導入方法依賴的package包/類
private Builder buildMultipleConversation() {
    final Builder mBuilder = new NotificationCompat.Builder(
            mXmppConnectionService);
    final NotificationCompat.InboxStyle style = new NotificationCompat.InboxStyle();
    style.setBigContentTitle(notifications.size()
            + " "
            + mXmppConnectionService
            .getString(R.string.unread_conversations));
    final StringBuilder names = new StringBuilder();
    Conversation conversation = null;
    for (final ArrayList<Message> messages : notifications.values()) {
        if (messages.size() > 0) {
            conversation = messages.get(0).getConversation();
            final String name = conversation.getName();
            SpannableString styledString;
            if (Config.HIDE_MESSAGE_TEXT_IN_NOTIFICATION) {
                int count = messages.size();
                styledString = new SpannableString(name + ": " + mXmppConnectionService.getResources().getQuantityString(R.plurals.x_messages, count, count));
                styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
                style.addLine(styledString);
            } else {
                styledString = new SpannableString(name + ": " + UIHelper.getMessagePreview(mXmppConnectionService, messages.get(0)).first);
                styledString.setSpan(new StyleSpan(Typeface.BOLD), 0, name.length(), 0);
                style.addLine(styledString);
            }
            names.append(name);
            names.append(", ");
        }
    }
    if (names.length() >= 2) {
        names.delete(names.length() - 2, names.length());
    }
    mBuilder.setContentTitle(notifications.size()
            + " "
            + mXmppConnectionService
            .getString(R.string.unread_conversations));
    mBuilder.setContentText(names.toString());
    mBuilder.setStyle(style);
    if (conversation != null) {
        mBuilder.setContentIntent(createContentIntent(conversation));
    }
    mBuilder.setGroupSummary(true);
    mBuilder.setGroup(CONVERSATIONS_GROUP);
    mBuilder.setDeleteIntent(createDeleteIntent(null));
    mBuilder.setSmallIcon(R.drawable.ic_notification);
    return mBuilder;
}
 
開發者ID:kriztan,項目名稱:Pix-Art-Messenger,代碼行數:48,代碼來源:NotificationService.java


注:本文中的android.support.v4.app.NotificationCompat.Builder.setStyle方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。