예제 #1
0
  private void updatePinColor() {
    view.setTextColor(view.getContext().getResources().getColor(android.R.color.white));

    switch (configuredAction) {
      case TOGGLE_ACTIVATION:
        view.setBackgroundResource(R.drawable.tinker_pin);
      case ANALOG_READ:
        view.setBackgroundResource(R.drawable.tinker_pin_emerald);
        break;
      case ANALOG_WRITE:
        view.setBackgroundResource(R.drawable.tinker_pin_sunflower);
        break;
      case DIGITAL_READ:
        if (digitalValue == DigitalValue.HIGH) {
          view.setBackgroundResource(R.drawable.tinker_pin_read_high);
          view.setTextColor(
              view.getContext().getResources().getColor(R.color.tinker_pin_text_dark));
        } else {
          view.setBackgroundResource(R.drawable.tinker_pin_cyan);
        }
        break;
      case DIGITAL_WRITE:
        if (digitalValue == DigitalValue.HIGH) {
          view.setBackgroundResource(R.drawable.tinker_pin_write_high);
          view.setTextColor(
              view.getContext().getResources().getColor(R.color.tinker_pin_text_dark));
        } else {
          view.setBackgroundResource(R.drawable.tinker_pin_alizarin);
        }
        break;
      case NONE:
        view.setBackgroundResource(R.drawable.tinker_pin);
        break;
    }
  }
 private void setMessageDetails(Cursor cursor, int columnIndex, TextView view) {
   StringBuilder messageDetails =
       new StringBuilder(
           RelativeTime.getDifference(view.getContext(), cursor.getLong(columnIndex)));
   setInReplyTo(cursor, view.getContext(), messageDetails);
   setRecipientName(cursor, view.getContext(), messageDetails);
   setMessageStatus(cursor, view.getContext(), messageDetails);
   view.setText(messageDetails.toString());
 }
예제 #3
0
  private void doShowAnalogValue(int newValue) {
    if (analogWriteView != null) {
      analogWriteView.setVisibility(View.GONE);
      analogWriteView = null;
    }

    ViewGroup parent = (ViewGroup) view.getParent();

    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.cancel();
    }

    if (analogReadView == null) {
      analogReadView = Ui.findView(parent, R.id.tinker_analog_read_main);
    }

    // If the view does not exist, inflate it
    if (analogReadView == null) {
      LayoutInflater inflater =
          (LayoutInflater) view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      if (pinType == PinType.A) {
        analogReadView = inflater.inflate(R.layout.tinker_analog_read_left, parent, false);
        parent.addView(analogReadView);
      } else if (pinType == PinType.D) {
        analogReadView = inflater.inflate(R.layout.tinker_analog_read_right, parent, false);
        parent.addView(analogReadView, 0);
      } else if (pinType == PinType.T) {
        analogReadView = inflater.inflate(R.layout.tinker_analog_read_right, parent, false);
        parent.addView(analogReadView, 0);
      }
    }

    analogReadView.setVisibility(View.VISIBLE);
    // Find the existing views and set the values
    ProgressBar barGraph = Ui.findView(analogReadView, R.id.tinker_analog_read_progress);
    TextView readValue = Ui.findView(analogReadView, R.id.tinker_analog_read_value);

    if (PinAction.ANALOG_READ.equals(configuredAction)) {
      barGraph.setProgressDrawable(
          view.getContext().getResources().getDrawable(R.drawable.progress_emerald));
    } else {
      barGraph.setProgressDrawable(
          view.getContext().getResources().getDrawable(R.drawable.progress_sunflower));
    }

    int max = 1;
    if (configuredAction == PinAction.ANALOG_READ) {
      max = ANALOG_READ_MAX;
    } else if (configuredAction == PinAction.ANALOG_WRITE) {
      max = ANALOG_WRITE_MAX;
    }

    barGraph.setMax(max);
    barGraph.setProgress(newValue);
    readValue.setText(String.valueOf(newValue));
  }
 private static void addDetectedValueHeader(
     @NonNull ListView listView,
     @StringRes int labelRes,
     @NonNull String labelKey,
     @NonNull String labelValue,
     @NonNull String value,
     @NonNull Icon icon) {
   final TextView textView =
       (TextView)
           LayoutInflater.from(listView.getContext())
               .inflate(R.layout.edx_selectable_list_item, listView, false);
   {
     final SpannableString labelValueSpan = new SpannableString(labelValue);
     labelValueSpan.setSpan(
         new ForegroundColorSpan(
             listView.getResources().getColor(R.color.edx_grayscale_neutral_dark)),
         0,
         labelValueSpan.length(),
         Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
     textView.setText(
         ResourceUtil.getFormattedString(
             listView.getContext().getResources(), labelRes, labelKey, labelValueSpan));
   }
   Context context = textView.getContext();
   TextViewCompat.setCompoundDrawablesRelativeWithIntrinsicBounds(
       textView,
       new IconDrawable(context, icon)
           .sizeRes(context, R.dimen.edx_base)
           .colorRes(context, R.color.edx_grayscale_neutral_light),
       null,
       null,
       null);
   listView.addHeaderView(textView, new FormOption(labelValue, value), true);
 }
  public void updateMetaUi() {
    Book book = mSpritzer.getBook();
    Metadata meta = book.getMetadata();
    Author author = meta.getAuthors().get(0);
    int curChapter = mSpritzer.getCurrentChapter();

    mAuthorView.setText(author.getFirstname() + " " + author.getLastname());
    mTitleView.setText(meta.getFirstTitle());
    String chapterText;
    if (book.getSpine().getResource(curChapter).getTitle() == null
        || book.getSpine().getResource(curChapter).getTitle().trim().compareTo("") == 0) {
      chapterText = String.format("Chapter %d", curChapter);
    } else {
      chapterText = book.getSpine().getResource(curChapter).getTitle();
    }

    int startSpan = chapterText.length();
    chapterText =
        String.format(
            "%s  %s m left",
            chapterText,
            (mSpritzer.getMinutesRemainingInQueue() == 0)
                ? "<1"
                : String.valueOf(mSpritzer.getMinutesRemainingInQueue()));
    int endSpan = chapterText.length();
    Spannable spanRange = new SpannableString(chapterText);
    TextAppearanceSpan tas = new TextAppearanceSpan(mChapterView.getContext(), R.style.MinutesToGo);
    spanRange.setSpan(tas, startSpan, endSpan, Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    mChapterView.setText(spanRange);

    mProgress.setMax(mSpritzer.getMaxChapter());
    mProgress.setProgress(curChapter);
  }
예제 #6
0
  public void showDigitalRead(DigitalValue newValue) {
    this.digitalValue = newValue;
    ViewGroup parent = (ViewGroup) view.getParent();
    if (digitalReadView == null) {
      digitalReadView = Ui.findView(parent, R.id.tinker_digital_write_main);
    }

    // If the view does not exist, inflate it
    if (digitalReadView == null) {
      LayoutInflater inflater =
          (LayoutInflater) view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
      digitalReadView = inflater.inflate(R.layout.tinker_digital_read, parent, false);
      if (pinType == PinType.A) {
        parent.addView(digitalReadView);
      } else if (pinType == PinType.D) {
        parent.addView(digitalReadView, 0);
      }
    }

    digitalReadView.setVisibility(View.VISIBLE);
    final TextView value = Ui.findView(digitalReadView, R.id.tinker_digital_read_value);
    value.setText(newValue.name());
    // fade(value, newValue);
    updatePinColor();
    if (!stopAnimating()) {
      getCancelAnimator().start();
    }
  }
예제 #7
0
 public static void place(TextView view, int index, String place) {
   if (TextUtils.isEmpty(place)) {
     view.setText(view.getContext().getString(R.string.payment_title_hint, index + 1));
   } else {
     view.setText(place);
   }
 }
예제 #8
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);

    Toolbar toolbar = (Toolbar) findViewById(R.id.myToolBar);
    TextView tv = (TextView) findViewById(R.id.tvMainTitle);
    Typeface font = Typeface.createFromAsset(tv.getContext().getAssets(), "font/Roboto-Medium.ttf");
    tv.setTypeface(font);
    tv.setText("Help");
    setSupportActionBar(toolbar);

    if (savedInstanceState != null) {
      // Restore the fragment's instance
      fragmentListView =
          (FragmentListView) getFragmentManager().getFragment(savedInstanceState, "mContent");

    } else {
      fragmentListView = new FragmentListView();
    }
    FragmentManager fm = getFragmentManager();
    FragmentTransaction ft = fm.beginTransaction();
    ft.replace(R.id.container, fragmentListView);
    ft.commit();
  }
예제 #9
0
  public static void setNameAndUsername(TextView textView, String name, String username) {
    Context c = textView.getContext();

    ForegroundColorSpan grayTextForegroundSpan =
        new ForegroundColorSpan(c.getResources().getColor(R.color.name_gray));

    AbsoluteSizeSpan fontsizeSpan = new AbsoluteSizeSpan(20);

    SpannableStringBuilder ssb = new SpannableStringBuilder(name + " @" + username);

    // Apply the color span
    ssb.setSpan(
        grayTextForegroundSpan, // the span to add
        name.length() + 1, // the start of the span (inclusive)
        ssb.length(), // the end of the span (exclusive)
        Spanned
            .SPAN_EXCLUSIVE_EXCLUSIVE); // behavior when text is later inserted into the
                                        // SpannableStringBuilder

    ssb.setSpan(
        fontsizeSpan, // the span to add
        name.length() + 1, // the start of the span (inclusive)
        ssb.length(), // the end of the span (exclusive)
        Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);

    textView.setText(ssb);
  }
예제 #10
0
 @OnClick(R.id.cardview)
 public void cardViewOnClick() {
   Context context = tvMessage.getContext();
   Intent intent = new Intent(context, WorkOrderDetailActivity.class);
   WorkOrderWarn workOrderWarn = workOrderWarnList.get(getAdapterPosition());
   intent.putExtra("workOrderId", workOrderWarn.getWorkOrderId());
   context.startActivity(intent);
 }
 void setState(int state) {
   text.setPressed(state == STATE_PRESSED);
   tab.setPressed(state == STATE_PRESSED);
   if (state == STATE_ACTIVE) {
     final int[] activeState = new int[] {com.android.internal.R.attr.state_active};
     if (text.getBackground().isStateful()) {
       text.getBackground().setState(activeState);
     }
     if (tab.getBackground().isStateful()) {
       tab.getBackground().setState(activeState);
     }
     text.setTextAppearance(text.getContext(), R.style.TextAppearance_SlidingTabActive);
   } else {
     text.setTextAppearance(text.getContext(), R.style.TextAppearance_SlidingTabNormal);
   }
   currentState = state;
 }
  /** 处理NewsDetailsTitleBar点击事件 */
  @Override
  public void onClick(View v) {
    InputMethodManager m =
        (InputMethodManager)
            mNewsReplyContent.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
    switch (v.getId()) {
        // 上一条新闻
      case R.id.newsdetails_titlebar_previous:
        if (mPosition > 0) {
          detailViewPager.setCurrentItem(mPosition - 1);
        } else {
          Toast.makeText(this, "没有上条新闻", Toast.LENGTH_SHORT).show();
        }
        break;
        // 下一条新闻
      case R.id.newsdetails_titlebar_next:
        if (mPosition < mNewsData.size() - 1) {
          detailViewPager.setCurrentItem(mPosition + 1);
        } else {
          Toast.makeText(this, "没有下条新闻", Toast.LENGTH_SHORT).show();
        }
        break;
        // 显示评论
      case R.id.newsdetails_titlebar_comments:
        Intent intent = new Intent(NewsDetailsActivity.this, CommentsActivity.class);
        // 传递新闻ID
        intent.putExtra("nid", mNid);
        startActivity(intent);
        break;
        // 新闻回复图片
      case R.id.news_reply_img_btn:
        mNewsReplyImgLayout.setVisibility(View.GONE);
        mNewsReplyEditLayout.setVisibility(View.VISIBLE);
        mNewsReplyContent.requestFocus(); // 使输入框聚焦
        m.toggleSoftInput(0, InputMethodManager.SHOW_IMPLICIT);
        break;
        // 发表新闻回复
      case R.id.news_reply_post:
        new PostCommentThread().start();
        mNewsReplyImgLayout.setVisibility(View.VISIBLE);
        mNewsReplyEditLayout.setVisibility(View.GONE);
        m.toggleSoftInput(0, InputMethodManager.HIDE_NOT_ALWAYS);
        break;

      case R.id.news_share_btn:
        // 设置分享新闻
        Intent intent2 = new Intent(Intent.ACTION_SEND);
        intent2.setType("image/*");
        intent2.putExtra(Intent.EXTRA_TEXT, "来自展鸿新闻客户端:" + newslist_item_title);
        intent2.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        startActivity(Intent.createChooser(intent2, getTitle()));
        break;
      case R.id.tap_back:
        mNewsReplyImgLayout.setVisibility(View.VISIBLE);
        mNewsReplyEditLayout.setVisibility(View.GONE);
        break;
    }
  }
예제 #13
0
 @TargetApi(Build.VERSION_CODES.M)
 public static void setTextAppearance(TextView view, @StyleRes int appearanceRes) {
   if (Build.VERSION.SDK_INT < 23) {
     //noinspection deprecation
     view.setTextAppearance(view.getContext(), appearanceRes);
   } else {
     view.setTextAppearance(appearanceRes);
   }
 }
예제 #14
0
 public void onFinish() {
   a.setText(
       a.getContext()
           .getString(
               b, new Object[] {Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)}));
   if (d != null) {
     d.a();
     d = null;
   }
 }
예제 #15
0
 @Override
 public boolean onTouchEvent(
     @NonNull TextView widget, @NonNull Spannable buffer, @NonNull MotionEvent event) {
   try {
     return super.onTouchEvent(widget, buffer, event);
   } catch (ActivityNotFoundException e) {
     ToastUtils.showMessage(widget.getContext(), R.string.link_not_openable);
     return true;
   }
 }
예제 #16
0
 public static void setTextStyle(TextView textView) {
   Context context = textView.getContext();
   String size = Preferences.getFontSize(context);
   int sizeId;
   if (size.equals("small")) sizeId = android.R.style.TextAppearance_Small;
   else if (size.equals("large")) sizeId = android.R.style.TextAppearance_Large;
   else sizeId = android.R.style.TextAppearance;
   TextViewCompat.setTextAppearance(textView, sizeId);
   // setEmojiconSize((int) getTextSize());
 }
예제 #17
0
  public void showAnalogWrite(final OnAnalogWriteListener listener) {
    if (analogReadView != null) {
      analogReadView.setVisibility(View.GONE);
      analogReadView = null;
    }

    final ViewGroup parent = (ViewGroup) view.getParent();
    if (analogWriteView == null) {
      analogWriteView = Ui.findView(parent, R.id.tinker_analog_write_main);
    }

    // If the view does not exist, inflate it
    if (analogWriteView == null) {
      LayoutInflater inflater =
          (LayoutInflater) view.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);

      if (pinType == PinType.A) {
        analogWriteView = inflater.inflate(R.layout.tinker_analog_write_left, parent, false);
        parent.addView(analogWriteView);
      } else if (pinType == PinType.D) {
        analogWriteView = inflater.inflate(R.layout.tinker_analog_write_right, parent, false);
        parent.addView(analogWriteView, 0);
      }
    }

    analogWriteView.setVisibility(View.VISIBLE);
    final SeekBar seekBar = Ui.findView(analogWriteView, R.id.tinker_analog_write_seekbar);
    final TextView valueText = Ui.findView(analogWriteView, R.id.tinker_analog_write_value);
    if (pinBackgroundAnim != null) {
      pinBackgroundAnim.cancel();
      pinBackgroundAnim = null;
    }
    parent.setBackgroundColor(0x4C000000);

    seekBar.setOnSeekBarChangeListener(
        new OnSeekBarChangeListener() {

          @Override
          public void onStopTrackingTouch(SeekBar seekBar) {
            int value = seekBar.getProgress();
            parent.setBackgroundColor(0);
            showAnalogWriteValue();
            listener.onAnalogWrite(value);
          }

          @Override
          public void onStartTrackingTouch(SeekBar seekBar) {}

          @Override
          public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
            valueText.setText(String.valueOf(progress));
          }
        });
  }
예제 #18
0
 private void setTextWithCustomFont(TextView text, String fontName) {
   if (this.text != null) {
     SpannableString s = new SpannableString(this.text);
     s.setSpan(
         new TypefaceSpan(text.getContext(), fontName),
         0,
         s.length(),
         Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
     text.setText(s);
   }
 }
예제 #19
0
  /**
   * Set the maximum text size to a given unit and value. See TypedValue for the possible dimension
   * units.
   *
   * @param unit The desired dimension unit.
   * @param size The desired size in the given units.
   * @attr ref android.R.styleable#TextView_textSize
   */
  public AutofitHelper setMaxTextSize(int unit, float size) {
    Context context = mTextView.getContext();
    Resources r = Resources.getSystem();

    if (context != null) {
      r = context.getResources();
    }

    setRawMaxTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
    return this;
  }
 @Override
 public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
   if (actionId == EditorInfo.IME_ACTION_SEND) {
     InputMethodManager imm =
         (InputMethodManager) v.getContext().getSystemService(Context.INPUT_METHOD_SERVICE);
     imm.hideSoftInputFromWindow(v.getWindowToken(), 0);
     sendMessage();
     return true;
   } else {
     return false;
   }
 }
예제 #21
0
  private AutofitHelper(TextView view) {
    final Context context = view.getContext();
    float scaledDensity = context.getResources().getDisplayMetrics().scaledDensity;

    mTextView = view;
    mPaint = new TextPaint();
    setRawTextSize(view.getTextSize());

    mMaxLines = getMaxLines(view);
    mMinTextSize = scaledDensity * DEFAULT_MIN_TEXT_SIZE;
    mMaxTextSize = mTextSize;
    mPrecision = DEFAULT_PRECISION;
  }
예제 #22
0
  private static void autofit(
      TextView view,
      TextPaint paint,
      float minTextSize,
      float maxTextSize,
      int maxLines,
      float precision) {
    if (maxLines <= 0 || maxLines == Integer.MAX_VALUE) {
      return;
    }

    int targetWidth = view.getWidth() - view.getPaddingLeft() - view.getPaddingRight();
    if (targetWidth <= 0) {
      return;
    }

    CharSequence text = view.getText();
    TransformationMethod method = view.getTransformationMethod();
    if (method != null) {
      text = method.getTransformation(text, view);
    }

    Context context = view.getContext();
    Resources r = Resources.getSystem();
    DisplayMetrics displayMetrics;

    float size = maxTextSize;
    float high = size;
    float low = 0;

    if (context != null) {
      r = context.getResources();
    }
    displayMetrics = r.getDisplayMetrics();

    paint.set(view.getPaint());
    paint.setTextSize(size);

    if ((maxLines == 1 && paint.measureText(text, 0, text.length()) > targetWidth)
        || getLineCount(text, paint, size, targetWidth, displayMetrics) > maxLines) {
      size =
          getAutofitTextSize(
              text, paint, targetWidth, maxLines, low, high, precision, displayMetrics);
    }

    if (size < minTextSize) {
      size = minTextSize;
    }

    view.setTextSize(TypedValue.COMPLEX_UNIT_PX, size);
  }
예제 #23
0
  Animator getCancelAnimator() {
    ObjectAnimator backToTransparent1 =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_end);
    ObjectAnimator goDark =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_go_dark);
    ObjectAnimator backToTransparent2 =
        (ObjectAnimator)
            AnimatorInflater.loadAnimator(view.getContext(), R.animator.pin_background_end);

    ViewGroup parent = (ViewGroup) view.getParent();
    ArgbEvaluator evaluator = new ArgbEvaluator();
    for (ObjectAnimator animator : list(backToTransparent1, goDark, backToTransparent2)) {
      animator.setTarget(parent);
      animator.setEvaluator(evaluator);
    }

    AnimatorSet animatorSet = new AnimatorSet();
    animatorSet.setTarget(parent);
    animatorSet.playSequentially(backToTransparent1, goDark, backToTransparent2);
    return animatorSet;
  }
예제 #24
0
    @Override
    public Object instantiateItem(ViewGroup container, int position) {
      final TextView tv = new TextView(container.getContext());
      tv.setText(getPageTitle(position));
      tv.setGravity(Gravity.CENTER);
      tv.setTextAppearance(tv.getContext(), R.style.TextAppearance_AppCompat_Title);
      container.addView(
          tv, ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT);

      Item item = new Item();
      item.cheese = mCheeses.get(position);
      item.view = tv;
      return item;
    }
예제 #25
0
  public void setCustomeFonts(TextView view) {

    if (view != null && !view.isInEditMode()) {
      if (fonts == null) {
        loadCustomeFonts(view.getContext());
      }
      int style = Typeface.NORMAL;
      if (view.getTypeface() != null) {
        style = view.getTypeface().getStyle();
      }
      if (style >= 0 && style < fonts.length) {
        view.setTypeface(fonts[style], style);
      }
    }
  }
예제 #26
0
 public void onTick(long paramLong) {
   int i = (int) paramLong / 1000;
   String str =
       a.getContext()
           .getString(
               b,
               new Object[] {
                 Integer.valueOf(i / 3600), Integer.valueOf(i % 3600 / 60), Integer.valueOf(i % 60)
               });
   Object localObject = str;
   if (!TextUtils.isEmpty(c)) {
     localObject = TextUtils.expandTemplate(c, new CharSequence[] {str});
   }
   a.setText((CharSequence) localObject);
 }
예제 #27
0
  /**
   * Set the original text size of the View.
   *
   * @see TextView#setTextSize(int, float)
   */
  public void setTextSize(int unit, float size) {
    if (mIsAutofitting) {
      // We don't want to update the TextView's actual textSize while we're autofitting
      // since it'd get set to the autofitTextSize
      return;
    }
    Context context = mTextView.getContext();
    Resources r = Resources.getSystem();

    if (context != null) {
      r = context.getResources();
    }

    setRawTextSize(TypedValue.applyDimension(unit, size, r.getDisplayMetrics()));
  }
예제 #28
0
 public static void a(TextView paramTextView, float paramFloat) {
   Drawable[] arrayOfDrawable = paramTextView.getCompoundDrawables();
   int j = arrayOfDrawable.length;
   int i = 0;
   while (i < j) {
     Drawable localDrawable = arrayOfDrawable[i];
     if (localDrawable != null) {
       localDrawable.setLevel((int) (10.0F * paramFloat) / 5);
     }
     i += 1;
   }
   paramTextView.setContentDescription(
       String.format(
           "%s,%s",
           new Object[] {a(paramTextView.getContext(), paramFloat), paramTextView.getText()}));
 }
예제 #29
0
  @Override
  public void afterTextChanged(Editable s) {
    if (start >= 0) {
      float textSize = textView.getTextSize();
      int pos = start;

      start = -2;
      EmojiconHandler.addEmojis(
          textView.getContext(),
          s,
          (int) textSize,
          DynamicDrawableSpan.ALIGN_BASELINE,
          (int) textSize,
          pos,
          count);
      start = -1;
    }
  }
예제 #30
0
 @Override
 public CharSequence filter(
     CharSequence source, int start, int end, Spanned dest, int dstart, int dend) {
   char[] v = new char[end - start];
   TextUtils.getChars(source, start, end, v, 0);
   Spannable emojified = EmojiProvider.getInstance(view.getContext()).emojify(new String(v), view);
   if (source instanceof Spanned) {
     TextUtils.copySpansFrom((Spanned) source, start, end, null, emojified, 0);
   }
   view.getViewTreeObserver().addOnGlobalLayoutListener(this);
   if (view.getWidth() == 0 || view.getEllipsize() != TruncateAt.END) {
     return emojified;
   } else {
     return TextUtils.ellipsize(
         emojified,
         view.getPaint(),
         view.getWidth() - view.getPaddingRight() - view.getPaddingLeft(),
         TruncateAt.END);
   }
 }