当前位置: 首页>>代码示例>>Java>>正文


Java EmojiCompat类代码示例

本文整理汇总了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));
}
 
开发者ID:googlesamples,项目名称:android-EmojiCompat,代码行数:26,代码来源:MainActivity.java

示例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();
}
 
开发者ID:jpelgrom,项目名称:Movie-Notifier-Android,代码行数:18,代码来源:MovieNotifierApp.java

示例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);
  }
}
 
开发者ID:vanniktech,项目名称:Emoji,代码行数:19,代码来源:GoogleCompatEmojiDrawable.java

示例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)));
    }
}
 
开发者ID:googlesamples,项目名称:android-EmojiCompat,代码行数:11,代码来源:MainActivity.java

示例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;
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:12,代码来源:EmojiService.java

示例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);
  }
}
 
开发者ID:vanniktech,项目名称:Emoji,代码行数:8,代码来源:GoogleCompatEmojiProvider.java

示例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];
    }
  }
}
 
开发者ID:vanniktech,项目名称:Emoji,代码行数:10,代码来源:GoogleCompatEmojiDrawable.java

示例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);
  }
}
 
开发者ID:vanniktech,项目名称:Emoji,代码行数:35,代码来源:MainActivity.java

示例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;
    }
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:12,代码来源:EmojiWrapper.java

示例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);
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:8,代码来源:AbstractEmojiService.java

示例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;
	}
}
 
开发者ID:siacs,项目名称:Conversations,代码行数:12,代码来源:EmojiWrapper.java

示例12: init

import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public void init() {
	final EmojiCompat.Config config = buildConfig();
	config.setReplaceAll(true);
	EmojiCompat.init(config);
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:6,代码来源:AbstractEmojiService.java

示例13: buildConfig

import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
protected EmojiCompat.Config buildConfig() {
	return new BundledEmojiCompatConfig(context);
}
 
开发者ID:syntafin,项目名称:TenguChat,代码行数:5,代码来源:EmojiService.java

示例14: GoogleCompatEmojiProvider

import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
public GoogleCompatEmojiProvider(@NonNull final EmojiCompat emojiCompat) {
  if (emojiCompat == null) {
    throw new NullPointerException();
  }
}
 
开发者ID:vanniktech,项目名称:Emoji,代码行数:6,代码来源:GoogleCompatEmojiProvider.java

示例15: buildConfig

import android.support.text.emoji.EmojiCompat; //导入依赖的package包/类
@Override
protected EmojiCompat.Config buildConfig() {
    return new BundledEmojiCompatConfig(context);
}
 
开发者ID:kriztan,项目名称:Pix-Art-Messenger,代码行数:5,代码来源:EmojiService.java


注:本文中的android.support.text.emoji.EmojiCompat类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。