本文整理汇总了Java中android.support.text.emoji.EmojiCompat类的典型用法代码示例。如果您正苦于以下问题:Java EmojiCompat类的具体用法?Java EmojiCompat怎么用?Java EmojiCompat使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
EmojiCompat类属于android.support.text.emoji包,在下文中一共展示了EmojiCompat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// TextView variant provided by EmojiCompat library
final TextView emojiTextView = findViewById(R.id.emoji_text_view);
emojiTextView.setText(getString(R.string.emoji_text_view, EMOJI));
// EditText variant provided by EmojiCompat library
final TextView emojiEditText = findViewById(R.id.emoji_edit_text);
emojiEditText.setText(getString(R.string.emoji_edit_text, EMOJI));
// Button variant provided by EmojiCompat library
final TextView emojiButton = findViewById(R.id.emoji_button);
emojiButton.setText(getString(R.string.emoji_button, EMOJI));
// Regular TextView without EmojiCompat support; you have to manually process the text
final TextView regularTextView = findViewById(R.id.regular_text_view);
EmojiCompat.get().registerInitCallback(new InitCallback(regularTextView));
// Custom TextView
final TextView customTextView = findViewById(R.id.emoji_custom_text_view);
customTextView.setText(getString(R.string.custom_text_view, EMOJI));
}
示例2: onCreate
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
public void onCreate() {
super.onCreate();
StethoUtil.install(this);
AppCompatDelegate.setDefaultNightMode(getSharedPreferences("settings", MODE_PRIVATE).getInt("prefDayNight", AppCompatDelegate.MODE_NIGHT_AUTO));
FontRequest fontRequest = new FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.com_google_android_gms_fonts_certs);
EmojiCompat.Config config = new FontRequestEmojiCompatConfig(this, fontRequest);
EmojiCompat.init(config);
setupCinemaListUpdates();
}
示例3: draw
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override public void draw(final Canvas canvas) {
final Rect bounds = getBounds();
textPaint.setTextSize(bounds.height() * TEXT_SIZE_FACTOR);
final int y = Math.round(bounds.bottom - bounds.height() * BASELINE_OFFSET_FACTOR);
if (!processed && EmojiCompat.get().getLoadState() != EmojiCompat.LOAD_STATE_LOADING) {
processed = true;
if (EmojiCompat.get().getLoadState() != EmojiCompat.LOAD_STATE_FAILED) {
process();
}
}
if (emojiSpan == null) {
canvas.drawText(emojiCharSequence, 0, emojiCharSequence.length(), bounds.left, y, textPaint);
} else {
emojiSpan.draw(canvas, emojiCharSequence, 0, emojiCharSequence.length(), bounds.left, bounds.top, y, bounds.bottom, textPaint);
}
}
示例4: onInitialized
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
public void onInitialized() {
final TextView regularTextView = mRegularTextViewRef.get();
if (regularTextView != null) {
final EmojiCompat compat = EmojiCompat.get();
final Context context = regularTextView.getContext();
regularTextView.setText(
compat.process(context.getString(R.string.regular_text_view, EMOJI)));
}
}
示例5: buildConfig
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
protected EmojiCompat.Config buildConfig() {
final FontRequest fontRequest = new FontRequest(
"com.google.android.gms.fonts",
"com.google.android.gms",
"Noto Color Emoji Compat",
R.array.font_certs);
FontRequestEmojiCompatConfig fontRequestEmojiCompatConfig = new FontRequestEmojiCompatConfig(context, fontRequest);
fontRequestEmojiCompatConfig.registerInitCallback(initCallback);
return fontRequestEmojiCompatConfig;
}
示例6: replaceWithImages
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override public void replaceWithImages(final Context context, final Spannable text, final float emojiSize, final float defaultEmojiSize, final EmojiReplacer fallback) {
if (EmojiCompat.get().getLoadState() != EmojiCompat.LOAD_STATE_SUCCEEDED
|| emojiSize != defaultEmojiSize
|| EmojiCompat.get().process(text, 0, text.length()) != text) {
fallback.replaceWithImages(context, text, emojiSize, defaultEmojiSize, null);
}
}
示例7: process
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
private void process() {
emojiCharSequence = EmojiCompat.get().process(emojiCharSequence);
if (emojiCharSequence instanceof Spanned) {
final Object[] spans = ((Spanned) emojiCharSequence).getSpans(0, emojiCharSequence.length(), EmojiSpan.class);
if (spans.length > 0) {
emojiSpan = (EmojiSpan) spans[0];
}
}
}
示例8: onOptionsItemSelected
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override public boolean onOptionsItemSelected(final MenuItem item) {
switch (item.getItemId()) {
case R.id.show_dialog:
MainDialog.show(this);
return true;
case R.id.variantIos:
EmojiManager.install(new IosEmojiProvider());
recreate();
return true;
case R.id.variantGoogle:
EmojiManager.install(new GoogleEmojiProvider());
recreate();
return true;
case R.id.variantTwitter:
EmojiManager.install(new TwitterEmojiProvider());
recreate();
return true;
case R.id.variantGoogleCompat:
if (emojiCompat == null) {
final EmojiCompat.Config config = new BundledEmojiCompatConfig(this);
config.setReplaceAll(true);
emojiCompat = EmojiCompat.init(config);
}
EmojiManager.install(new GoogleCompatEmojiProvider(emojiCompat));
recreate();
return true;
case R.id.variantEmojiOne:
EmojiManager.install(new EmojiOneProvider());
recreate();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
示例9: transform
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public static CharSequence transform(CharSequence input) {
try {
if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) {
return EmojiCompat.get().process(input);
} else {
return input;
}
} catch (IllegalStateException e) {
return input;
}
}
示例10: init
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public void init(boolean useBundledEmoji) {
Log.d(Config.LOGTAG, "Emojis: use integrated lib " + useBundledEmoji);
EmojiCompat.Config config = buildConfig();
config.setReplaceAll(useBundledEmoji);
EmojiCompat.reset(config);
EmojiCompat.init(config);
}
示例11: transform
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public static CharSequence transform(CharSequence input) {
try {
if (EmojiCompat.get().getLoadState() == EmojiCompat.LOAD_STATE_SUCCEEDED) {
return EmojiCompat.get().process(input);
} else {
return input;
}
} catch (IllegalStateException e) {
return input;
}
}
示例12: init
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public void init() {
final EmojiCompat.Config config = buildConfig();
config.setReplaceAll(true);
EmojiCompat.init(config);
}
示例13: buildConfig
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
protected EmojiCompat.Config buildConfig() {
return new BundledEmojiCompatConfig(context);
}
示例14: GoogleCompatEmojiProvider
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public GoogleCompatEmojiProvider(@NonNull final EmojiCompat emojiCompat) {
if (emojiCompat == null) {
throw new NullPointerException();
}
}
示例15: buildConfig
import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
protected EmojiCompat.Config buildConfig() {
return new BundledEmojiCompatConfig(context);
}