Java Code Examples for android.text.TextUtils.TruncateAt

The following are top voted examples for showing how to use android.text.TextUtils.TruncateAt. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: chromium-for-android-56-debug-video   File: TemplatePreservingTextView.java   Source Code and License 7 votes vote down vote up
private CharSequence getTruncatedText(int availWidth) {
    final TextPaint paint = getPaint();

    // Calculate the width the template takes.
    final String emptyTemplate = String.format(mTemplate, "");
    final float emptyTemplateWidth = paint.measureText(emptyTemplate);

    // Calculate the available width for the content.
    final float contentWidth = Math.max(availWidth - emptyTemplateWidth, 0.f);

    // Ellipsize the content to the available width.
    CharSequence clipped = TextUtils.ellipsize(mContent, paint, contentWidth, TruncateAt.END);

    // Build the full string, which should fit within availWidth.
    return String.format(mTemplate, clipped);
}
 
Example 2
Project: PeSanKita-android   File: EmojiTextView.java   Source Code and License 6 votes vote down vote up
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  final int size = MeasureSpec.getSize(widthMeasureSpec);
  final int mode = MeasureSpec.getMode(widthMeasureSpec);
  if (!useSystemEmoji()                                            &&
      getEllipsize() == TruncateAt.END                             &&
      !TextUtils.isEmpty(source)                                   &&
      (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) &&
      getPaint().breakText(source, 0, source.length()-1, true, size, null) != source.length())
  {
    needsEllipsizing = true;
    FontMetricsInt font = getPaint().getFontMetricsInt();
    super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(Math.abs(font.top - font.bottom), MeasureSpec.EXACTLY));
  } else {
    needsEllipsizing = false;
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}
 
Example 3
Project: letv   File: TaskGuide.java   Source Code and License 6 votes vote down vote up
private void a() {
    this.b = new TextView(this.a.F);
    this.b.setTextColor(Color.rgb(255, 255, 255));
    this.b.setTextSize(15.0f);
    this.b.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199));
    this.b.setGravity(3);
    this.b.setEllipsize(TruncateAt.END);
    this.b.setIncludeFontPadding(false);
    this.b.setSingleLine(true);
    ViewGroup.LayoutParams layoutParams = new LinearLayout.LayoutParams(0, -2);
    layoutParams.weight = 1.0f;
    layoutParams.leftMargin = this.a.a(4);
    addView(this.b, layoutParams);
    this.c = new Button(this.a.F);
    this.c.setPadding(0, 0, 0, 0);
    this.c.setTextSize(16.0f);
    this.c.setTextColor(Color.rgb(255, 255, 255));
    this.c.setShadowLayer(1.0f, 1.0f, 1.0f, Color.rgb(242, 211, 199));
    this.c.setIncludeFontPadding(false);
    this.c.setOnClickListener(new f(this.a, this.d.a));
    layoutParams = new LinearLayout.LayoutParams(this.a.a(TaskGuide.p), this.a.a(TaskGuide.q));
    layoutParams.leftMargin = this.a.a(2);
    layoutParams.rightMargin = this.a.a(8);
    addView(this.c, layoutParams);
}
 
Example 4
Project: boohee_v5.6   File: BooheeNoticeActivity.java   Source Code and License 6 votes vote down vote up
private void findView() {
    this.txt_notice_good_morning_sub_title = (TextView) findViewById(R.id
            .txt_notice_good_morning_sub_title);
    this.txt_notice_diet_sub_title = (TextView) findViewById(R.id.txt_notice_diet_sub_title);
    this.txt_notice_sport_sub_title = (TextView) findViewById(R.id.txt_notice_sport_sub_title);
    this.txt_notice_water_sub_title = (TextView) findViewById(R.id.txt_notice_water_sub_title);
    this.txt_notice_box_count = (TextView) findViewById(R.id.txt_notice_box_count);
    this.txt_notice_good_morning_sub_title.setEllipsize(TruncateAt.END);
    this.txt_notice_diet_sub_title.setEllipsize(TruncateAt.END);
    this.txt_notice_sport_sub_title.setEllipsize(TruncateAt.END);
    this.txt_notice_water_sub_title.setEllipsize(TruncateAt.END);
    this.tb_notice_good_morning = (ToggleButton) findViewById(R.id.tb_notice_good_morning);
    this.tb_notice_diet = (ToggleButton) findViewById(R.id.tb_notice_diet);
    this.tb_notice_sport = (ToggleButton) findViewById(R.id.tb_notice_sport);
    this.tb_notice_water = (ToggleButton) findViewById(R.id.tb_notice_water);
}
 
Example 5
Project: boohee_v5.6   File: Toolbar.java   Source Code and License 6 votes vote down vote up
public void setTitle(CharSequence title) {
    if (!TextUtils.isEmpty(title)) {
        if (this.mTitleTextView == null) {
            Context context = getContext();
            this.mTitleTextView = new TextView(context);
            this.mTitleTextView.setSingleLine();
            this.mTitleTextView.setEllipsize(TruncateAt.END);
            if (this.mTitleTextAppearance != 0) {
                this.mTitleTextView.setTextAppearance(context, this.mTitleTextAppearance);
            }
            if (this.mTitleTextColor != 0) {
                this.mTitleTextView.setTextColor(this.mTitleTextColor);
            }
        }
        if (!isChildOrHidden(this.mTitleTextView)) {
            addSystemView(this.mTitleTextView, true);
        }
    } else if (this.mTitleTextView != null && isChildOrHidden(this.mTitleTextView)) {
        removeView(this.mTitleTextView);
        this.mHiddenViews.remove(this.mTitleTextView);
    }
    if (this.mTitleTextView != null) {
        this.mTitleTextView.setText(title);
    }
    this.mTitleText = title;
}
 
Example 6
Project: boohee_v5.6   File: Toolbar.java   Source Code and License 6 votes vote down vote up
public void setSubtitle(CharSequence subtitle) {
    if (!TextUtils.isEmpty(subtitle)) {
        if (this.mSubtitleTextView == null) {
            Context context = getContext();
            this.mSubtitleTextView = new TextView(context);
            this.mSubtitleTextView.setSingleLine();
            this.mSubtitleTextView.setEllipsize(TruncateAt.END);
            if (this.mSubtitleTextAppearance != 0) {
                this.mSubtitleTextView.setTextAppearance(context, this.mSubtitleTextAppearance);
            }
            if (this.mSubtitleTextColor != 0) {
                this.mSubtitleTextView.setTextColor(this.mSubtitleTextColor);
            }
        }
        if (!isChildOrHidden(this.mSubtitleTextView)) {
            addSystemView(this.mSubtitleTextView, true);
        }
    } else if (this.mSubtitleTextView != null && isChildOrHidden(this.mSubtitleTextView)) {
        removeView(this.mSubtitleTextView);
        this.mHiddenViews.remove(this.mSubtitleTextView);
    }
    if (this.mSubtitleTextView != null) {
        this.mSubtitleTextView.setText(subtitle);
    }
    this.mSubtitleText = subtitle;
}
 
Example 7
Project: simple-share-android   File: RecentsCreateFragment.java   Source Code and License 6 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_doc_list, parent, false);
    }

    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final View line2 = convertView.findViewById(R.id.line2);

    final DocumentStack stack = getItem(position);
    iconMime.setImageDrawable(stack.root.loadIcon(context));

    final Drawable crumb = ContextCompat.getDrawable(context, R.drawable.ic_breadcrumb_arrow);
    crumb.setBounds(0, 0, crumb.getIntrinsicWidth(), crumb.getIntrinsicHeight());

    final SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(stack.root.title);
    for (int i = stack.size() - 2; i >= 0; i--) {
        appendDrawable(builder, crumb);
        builder.append(stack.get(i).displayName);
    }
    title.setText(builder);
    title.setEllipsize(TruncateAt.MIDDLE);

    if (line2 != null) line2.setVisibility(View.GONE);

    return convertView;
}
 
Example 8
Project: Cable-Android   File: EmojiTextView.java   Source Code and License 6 votes vote down vote up
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
  final int size = MeasureSpec.getSize(widthMeasureSpec);
  final int mode = MeasureSpec.getMode(widthMeasureSpec);
  if (!useSystemEmoji()                                            &&
      getEllipsize() == TruncateAt.END                             &&
      !TextUtils.isEmpty(source)                                   &&
      (mode == MeasureSpec.AT_MOST || mode == MeasureSpec.EXACTLY) &&
      getPaint().breakText(source, 0, source.length()-1, true, size, null) != source.length())
  {
    needsEllipsizing = true;
    FontMetricsInt font = getPaint().getFontMetricsInt();
    super.onMeasure(MeasureSpec.makeMeasureSpec(size, MeasureSpec.EXACTLY),
                    MeasureSpec.makeMeasureSpec(Math.abs(font.top - font.bottom), MeasureSpec.EXACTLY));
  } else {
    needsEllipsizing = false;
    super.onMeasure(widthMeasureSpec, heightMeasureSpec);
  }
}
 
Example 9
Project: solved-hacking-problem   File: Toolbar.java   Source Code and License 6 votes vote down vote up
public void setSubtitle(CharSequence charSequence) {
    if (!TextUtils.isEmpty(charSequence)) {
        if (this.f1243d == null) {
            Context context = getContext();
            this.f1243d = new TextView(context);
            this.f1243d.setSingleLine();
            this.f1243d.setEllipsize(TruncateAt.END);
            if (this.f1252m != 0) {
                this.f1243d.setTextAppearance(context, this.f1252m);
            }
            if (this.f1264y != 0) {
                this.f1243d.setTextColor(this.f1264y);
            }
        }
        if (!m2431d(this.f1243d)) {
            m2421a(this.f1243d, true);
        }
    } else if (this.f1243d != null && m2431d(this.f1243d)) {
        removeView(this.f1243d);
        this.f1228C.remove(this.f1243d);
    }
    if (this.f1243d != null) {
        this.f1243d.setText(charSequence);
    }
    this.f1262w = charSequence;
}
 
Example 10
Project: solved-hacking-problem   File: Toolbar.java   Source Code and License 6 votes vote down vote up
public void setTitle(CharSequence charSequence) {
    if (!TextUtils.isEmpty(charSequence)) {
        if (this.f1242c == null) {
            Context context = getContext();
            this.f1242c = new TextView(context);
            this.f1242c.setSingleLine();
            this.f1242c.setEllipsize(TruncateAt.END);
            if (this.f1251l != 0) {
                this.f1242c.setTextAppearance(context, this.f1251l);
            }
            if (this.f1263x != 0) {
                this.f1242c.setTextColor(this.f1263x);
            }
        }
        if (!m2431d(this.f1242c)) {
            m2421a(this.f1242c, true);
        }
    } else if (this.f1242c != null && m2431d(this.f1242c)) {
        removeView(this.f1242c);
        this.f1228C.remove(this.f1242c);
    }
    if (this.f1242c != null) {
        this.f1242c.setText(charSequence);
    }
    this.f1261v = charSequence;
}
 
Example 11
Project: solved-hacking-problem   File: Toolbar.java   Source Code and License 6 votes vote down vote up
public void setSubtitle(CharSequence charSequence) {
    if (!TextUtils.isEmpty(charSequence)) {
        if (this.f1243d == null) {
            Context context = getContext();
            this.f1243d = new TextView(context);
            this.f1243d.setSingleLine();
            this.f1243d.setEllipsize(TruncateAt.END);
            if (this.f1252m != 0) {
                this.f1243d.setTextAppearance(context, this.f1252m);
            }
            if (this.f1264y != 0) {
                this.f1243d.setTextColor(this.f1264y);
            }
        }
        if (!m2431d(this.f1243d)) {
            m2421a(this.f1243d, true);
        }
    } else if (this.f1243d != null && m2431d(this.f1243d)) {
        removeView(this.f1243d);
        this.f1228C.remove(this.f1243d);
    }
    if (this.f1243d != null) {
        this.f1243d.setText(charSequence);
    }
    this.f1262w = charSequence;
}
 
Example 12
Project: solved-hacking-problem   File: Toolbar.java   Source Code and License 6 votes vote down vote up
public void setTitle(CharSequence charSequence) {
    if (!TextUtils.isEmpty(charSequence)) {
        if (this.f1242c == null) {
            Context context = getContext();
            this.f1242c = new TextView(context);
            this.f1242c.setSingleLine();
            this.f1242c.setEllipsize(TruncateAt.END);
            if (this.f1251l != 0) {
                this.f1242c.setTextAppearance(context, this.f1251l);
            }
            if (this.f1263x != 0) {
                this.f1242c.setTextColor(this.f1263x);
            }
        }
        if (!m2431d(this.f1242c)) {
            m2421a(this.f1242c, true);
        }
    } else if (this.f1242c != null && m2431d(this.f1242c)) {
        removeView(this.f1242c);
        this.f1228C.remove(this.f1242c);
    }
    if (this.f1242c != null) {
        this.f1242c.setText(charSequence);
    }
    this.f1261v = charSequence;
}
 
Example 13
Project: AndroidChromium   File: TemplatePreservingTextView.java   Source Code and License 6 votes vote down vote up
private CharSequence getTruncatedText(int availWidth) {
    final TextPaint paint = getPaint();

    // Calculate the width the template takes.
    final String emptyTemplate = String.format(mTemplate, "");
    final float emptyTemplateWidth = paint.measureText(emptyTemplate);

    // Calculate the available width for the content.
    final float contentWidth = Math.max(availWidth - emptyTemplateWidth, 0.f);

    // Ellipsize the content to the available width.
    CharSequence clipped = TextUtils.ellipsize(mContent, paint, contentWidth, TruncateAt.END);

    // Build the full string, which should fit within availWidth.
    return String.format(mTemplate, clipped);
}
 
Example 14
Project: j2se_for_android   File: JMenuItem.java   Source Code and License 6 votes vote down vote up
private void addText(boolean isLeftToRight) {
	textView = new TextView(ActivityManager.getActivity());
	textView.setText(text);
	textView.setSingleLine(true);
	textView.setTextColor(isEnable?AndroidUIUtil.WIN_FONT_COLOR.toAndroid():AndroidUIUtil.WIN_FONT_DISABLE_COLOR.toAndroid());
	UICore.setTextSize(textView, getScreenAdapterAdAPI());
	textView.setMaxWidth(300);
	textView.setEllipsize(TruncateAt.MARQUEE);
	textView.setGravity(Gravity.CENTER_VERTICAL | (isLeftToRight?Gravity.LEFT:Gravity.RIGHT));
	LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
			LinearLayout.LayoutParams.WRAP_CONTENT, LinearLayout.LayoutParams.WRAP_CONTENT);
	lp.gravity = textView.getGravity();
	if(isLeftToRight){
		lp.leftMargin = 5;
	}else{
		lp.rightMargin = 5;
	}
	AndroidUIUtil.addView(defaultLinearLayout, textView, lp, viewRelation);
}
 
Example 15
Project: msb-android   File: FavoriteFolderItemView.java   Source Code and License 6 votes vote down vote up
private TextView createQuestionTextView(MQuestion question, boolean isLastItem) {
	TextView textView = new TextView(getContext());
	textView.setMaxLines(3);
	textView.setEllipsize(TruncateAt.END);
	String description = removeBlankLine(question.description);
	textView.setText(description);
	
	int vPadding = getResources().getDimensionPixelSize(R.dimen.question_item_padding_v);
	textView.setPadding(mPadding, vPadding, mPadding, isLastItem ? vPadding : 0);
	
	int textColor = getResources().getColor(R.color.favorite_folder_question_desc);
	textView.setTextColor(textColor);
	
	int textSize = getResources().getDimensionPixelSize(R.dimen.favorite_folder_question_text_size);
	textView.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSize);
	
	return textView;
}
 
Example 16
Project: Vafrinn   File: TemplatePreservingTextView.java   Source Code and License 6 votes vote down vote up
private CharSequence getTruncatedText(int availWidth) {
    final TextPaint paint = getPaint();

    // Calculate the width the template takes.
    final String emptyTemplate = String.format(mTemplate, "");
    final float emptyTemplateWidth = paint.measureText(emptyTemplate);

    // Calculate the available width for the content.
    final float contentWidth = Math.max(availWidth - emptyTemplateWidth, 0.f);

    // Ellipsize the content to the available width.
    CharSequence clipped = TextUtils.ellipsize(mContent, paint, contentWidth, TruncateAt.END);

    // Build the full string, which should fit within availWidth.
    return String.format(mTemplate, clipped);
}
 
Example 17
Project: FMTech   File: dzn.java   Source Code and License 6 votes vote down vote up
public dzn(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  this.a = loj.a(paramContext);
  this.g = new dzo(paramContext);
  if (!this.c) {}
  for (int i1 = 19;; i1 = 10)
  {
    Button localButton = lur.a(paramContext, paramAttributeSet, paramInt, i1, this.a.aQ, 0);
    localButton.setSingleLine(true);
    localButton.setEllipsize(TextUtils.TruncateAt.END);
    localButton.setCompoundDrawablePadding(this.a.n);
    localButton.setOnClickListener(this);
    this.i = localButton;
    this.i.setText(getContext().getString(aau.iJ));
    this.l = new MediaView(paramContext, paramAttributeSet, paramInt);
    this.l.setOnClickListener(this);
    this.l.setContentDescription(getResources().getString(aau.dg));
    this.h = new ArrayList();
    this.j = new ImageView(paramContext, paramAttributeSet, paramInt);
    this.j.setImageBitmap(this.a.f);
    this.j.setScaleType(ImageView.ScaleType.CENTER);
    this.o = new TextView(paramContext, paramAttributeSet, paramInt);
    return;
  }
}
 
Example 18
Project: FMTech   File: dxm.java   Source Code and License 6 votes vote down vote up
private dxm(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, 0);
  this.a = new TextView(paramContext);
  this.a.setGravity(17);
  this.a.setMaxLines(2);
  this.a.setEllipsize(TextUtils.TruncateAt.END);
  this.a.setGravity(1);
  this.a.setTextAppearance(paramContext, efj.yu);
  this.b = new ImageView(paramContext);
  this.b.setScaleType(ImageView.ScaleType.CENTER_INSIDE);
  this.i = ((lwj)mbb.a(paramContext, lwj.class));
  Resources localResources = paramContext.getResources();
  setBackgroundResource(da.aY);
  if (e == 0)
  {
    e = (int)localResources.getDimension(efj.mq);
    f = (int)localResources.getDimension(efj.mo);
    g = (int)localResources.getDimension(efj.ml);
  }
}
 
Example 19
Project: FMTech   File: dws.java   Source Code and License 6 votes vote down vote up
public dws(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  if (!f)
  {
    Resources localResources = paramContext.getResources();
    a = localResources.getString(aau.gh);
    g = localResources.getDimension(efj.nK);
    h = localResources.getColor(efj.ko);
    f = true;
  }
  float f1 = g;
  int i = h;
  TextView localTextView = new TextView(paramContext, paramAttributeSet, paramInt);
  localTextView.setTextSize(0, f1);
  localTextView.setSingleLine(true);
  localTextView.setTextColor(i);
  localTextView.setEllipsize(TextUtils.TruncateAt.END);
  this.c = localTextView;
  addView(this.c);
  this.b = new dvb(paramContext, paramAttributeSet, paramInt);
  addView(this.b);
  this.d = 0;
  this.e = 0;
}
 
Example 20
Project: FMTech   File: dwq.java   Source Code and License 6 votes vote down vote up
public dwq(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  this.j = paramContext;
  this.i = paramAttributeSet;
  this.k = paramInt;
  Resources localResources = paramContext.getResources();
  if (!d)
  {
    e = localResources.getColor(efj.kp);
    f = localResources.getDimension(efj.nK);
    g = localResources.getColor(efj.kp);
    h = localResources.getDimension(efj.nJ);
    d = true;
  }
  float f1 = f;
  int m = e;
  TextView localTextView = new TextView(paramContext, paramAttributeSet, paramInt);
  localTextView.setTextSize(0, f1);
  localTextView.setSingleLine(true);
  localTextView.setTextColor(m);
  localTextView.setEllipsize(TextUtils.TruncateAt.END);
  localTextView.setTypeface(Typeface.DEFAULT_BOLD);
  this.a = localTextView;
  addView(this.a);
}
 
Example 21
Project: FMTech   File: lha.java   Source Code and License 6 votes vote down vote up
public final void a(Context paramContext, int paramInt, View paramView, boolean paramBoolean)
{
  SquareAvatarView localSquareAvatarView = (SquareAvatarView)paramView.findViewById(dl.am);
  lgu locallgu = (lgu)this.ab.get(paramInt);
  String str = locallgu.b;
  if (str != null) {
    localSquareAvatarView.a.a(null, str);
  }
  TextView localTextView = (TextView)paramView.findViewById(dl.an);
  localTextView.setText(locallgu.a.b);
  localTextView.setTextSize(0, g().getDimension(ehr.dS));
  localTextView.setTypeface(localTextView.getTypeface(), 1);
  localTextView.setMaxLines(2);
  localTextView.setEllipsize(TextUtils.TruncateAt.END);
  localTextView.setIncludeFontPadding(false);
  localTextView.setTextColor(g().getColor(aau.CC));
  efj.a(paramView, new kuw(pjo.u, locallgu.a.a));
}
 
Example 22
Project: FMTech   File: hfq.java   Source Code and License 6 votes vote down vote up
public hfq(Context paramContext)
{
  super(paramContext);
  Context localContext = getContext();
  this.d = ((hfr)mbb.a(localContext, hfr.class));
  Resources localResources = localContext.getResources();
  int i = localResources.getDimensionPixelOffset(aaw.nr);
  this.b = localResources.getInteger(aau.yQ);
  setPadding(i, i, i, i);
  this.a = lur.b(localContext, null, 0, 3, i, 0);
  this.a.setClickable(false);
  addView(this.a);
  ImageButton localImageButton = this.a;
  nj.a.c(localImageButton, 2);
  this.a.setFocusable(false);
  this.a.setFocusableInTouchMode(false);
  this.c = new TextView(localContext);
  this.c.setTextAppearance(localContext, aaw.nI);
  this.c.setMaxLines(1);
  this.c.setEllipsize(TextUtils.TruncateAt.END);
  addView(this.c);
  this.e = new gqw(this);
}
 
Example 23
Project: FMTech   File: dvk.java   Source Code and License 6 votes vote down vote up
public dvk(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  this.b = new TextView(paramContext, paramAttributeSet, paramInt);
  this.b.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
  this.b.setTextAppearance(paramContext, efj.yr);
  this.b.setSingleLine();
  this.b.setEllipsize(TextUtils.TruncateAt.END);
  addView(this.b);
  this.e = new Point();
  this.a = new TextView(paramContext, paramAttributeSet, paramInt);
  this.a.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
  this.a.setTextAppearance(paramContext, efj.yD);
  this.a.setSingleLine();
  this.a.setEllipsize(TextUtils.TruncateAt.END);
  addView(this.a);
  this.g = new Point();
  this.c = new TextView(paramContext, paramAttributeSet, paramInt);
  this.c.setTextAppearance(paramContext, efj.yo);
  this.c.setMovementMethod(lxy.a());
  addView(this.c);
}
 
Example 24
Project: FMTech   File: hgl.java   Source Code and License 6 votes vote down vote up
public final void a(String paramString)
{
  if (this.m == null)
  {
    Context localContext = getContext();
    this.m = new TextView(localContext);
    this.m.setSingleLine(true);
    this.m.setEllipsize(TextUtils.TruncateAt.END);
    this.m.setGravity(16);
    this.m.setLayoutParams(new ViewGroup.LayoutParams(-2, -2));
    this.m.setTextAppearance(localContext, efj.Hr);
    addView(this.m);
  }
  this.m.setText(paramString);
  this.m.setVisibility(0);
  this.D = true;
}
 
Example 25
Project: TextSecureSMP   File: EmojiFilter.java   Source Code and License 6 votes vote down vote up
@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);
  }
}
 
Example 26
Project: QuickControlPanel   File: MusicViewFactory.java   Source Code and License 6 votes vote down vote up
private TextView getMetadataTextView(ViewGroup.LayoutParams params, OnClickListener l) {
	final ColorStateList colors = new ColorStateList(
			new int[][]{
					new int[]{android.R.attr.state_pressed},
					new int[] { android.R.attr.state_enabled}
			},
			new int[] {
					ColorsResolver.getPressedColor(mContext),
					ColorsResolver.getTextColor(mContext)
			});


	TextView result = new TextView(mContext);
	result.setLayoutParams(params);
	result.setText(R.string.unknown);
	result.setOnClickListener(l);
	result.setMaxLines(1);
	result.setSingleLine();
	result.setMarqueeRepeatLimit(-1);
	result.setSelected(true);
	result.setGravity(Gravity.CENTER);
	result.setEllipsize(TruncateAt.MARQUEE);
	result.setTextColor(colors);
	result.setTextSize(TypedValue.COMPLEX_UNIT_SP, MusicResolver.getMetadataTextSize(mContext));
	return result;
}
 
Example 27
Project: sticky-dictionary   File: EllipsizingTextView.java   Source Code and License 6 votes vote down vote up
/**
 * Causes words in the text that are longer than the view is wide to be ellipsized
 * instead of broken in the middle. Use {@code null} to turn off ellipsizing.
 * <p/>
 * Note: Method does nothing for {@link android.text.TextUtils.TruncateAt#MARQUEE}
 * ellipsizing type.
 *
 * @param where part of text to ellipsize
 */
@Override
public void setEllipsize(TruncateAt where) {
    if (where == null) {
        mEllipsizeStrategy = new EllipsizeNoneStrategy();
        return;
    }

    switch (where) {
        case END:
            mEllipsizeStrategy = new EllipsizeEndStrategy();
            break;
        case START:
            mEllipsizeStrategy = new EllipsizeStartStrategy();
            break;
        case MIDDLE:
            mEllipsizeStrategy = new EllipsizeMiddleStrategy();
            break;
        case MARQUEE:
        default:
            mEllipsizeStrategy = new EllipsizeNoneStrategy();
            break;
    }
}
 
Example 28
Project: 365browser   File: PaymentRequestSection.java   Source Code and License 6 votes vote down vote up
@Override
public void setDisplayMode(int displayMode) {
    // Displays the summary left text view in at most three lines if in focus mode,
    // otherwise display it in a single line.
    if (displayMode == DISPLAY_MODE_FOCUSED) {
        setSummaryProperties(TruncateAt.END, false /* leftIsSingleLine */,
                null /* rightTruncate */, false /* rightIsSingleLine */);
        getSummaryLeftTextView().setMaxLines(3);
    } else {
        setSummaryProperties(TruncateAt.END, true /* leftIsSingleLine */,
                null /* rightTruncate */, false /* rightIsSingleLine */);
        getSummaryLeftTextView().setMaxLines(1);
    }

    super.setDisplayMode(displayMode);
}
 
Example 29
Project: 365browser   File: TemplatePreservingTextView.java   Source Code and License 6 votes vote down vote up
private CharSequence getTruncatedText(int availWidth) {
    final TextPaint paint = getPaint();

    // Calculate the width the template takes.
    final String emptyTemplate = String.format(mTemplate, "");
    final float emptyTemplateWidth = paint.measureText(emptyTemplate);

    // Calculate the available width for the content.
    final float contentWidth = Math.max(availWidth - emptyTemplateWidth, 0.f);

    // Ellipsize the content to the available width.
    CharSequence clipped = TextUtils.ellipsize(mContent, paint, contentWidth, TruncateAt.END);

    // Build the full string, which should fit within availWidth.
    return String.format(mTemplate, clipped);
}
 
Example 30
Project: PeSanKita-android   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
public static CharSequence ellipsize(@Nullable CharSequence text, @NonNull TextView view) {
  if (TextUtils.isEmpty(text) || view.getWidth() == 0 || view.getEllipsize() != TruncateAt.END) {
    return text;
  } else {
    return TextUtils.ellipsize(text,
                               view.getPaint(),
                               view.getWidth() - view.getPaddingRight() - view.getPaddingLeft(),
                               TruncateAt.END);
  }
}
 
Example 31
Project: easyfilemanager   File: RecentsCreateFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_doc_list, parent, false);
    }

    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final View line2 = convertView.findViewById(R.id.line2);

    final DocumentStack stack = getItem(position);
    iconMime.setImageDrawable(stack.root.loadIcon(context));

    final Drawable crumb = ContextCompat.getDrawable(context, R.drawable.ic_breadcrumb_arrow);
    crumb.setBounds(0, 0, crumb.getIntrinsicWidth(), crumb.getIntrinsicHeight());

    final SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(stack.root.title);
    for (int i = stack.size() - 2; i >= 0; i--) {
        appendDrawable(builder, crumb);
        builder.append(stack.get(i).displayName);
    }
    title.setText(builder);
    title.setEllipsize(TruncateAt.MIDDLE);

    if (line2 != null) line2.setVisibility(View.GONE);

    return convertView;
}
 
Example 32
Project: chromium-for-android-56-debug-video   File: PaymentRequestSection.java   Source Code and License 5 votes vote down vote up
/**
 * Sets how the summary text should be displayed.
 *
 * @param leftTruncate How to truncate the left summary text.  Set to null to clear.
 * @param rightTruncate How to truncate the right summary text.  Set to null to clear.
 */
public void setSummaryProperties(@Nullable TruncateAt leftTruncate, boolean leftIsSingleLine,
        @Nullable TruncateAt rightTruncate, boolean rightIsSingleLine) {
    mSummaryLeftTextView.setEllipsize(leftTruncate);
    mSummaryLeftTextView.setSingleLine(leftIsSingleLine);

    mSummaryRightTextView.setEllipsize(rightTruncate);
    mSummaryRightTextView.setSingleLine(rightIsSingleLine);
}
 
Example 33
Project: chromium-for-android-56-debug-video   File: PaymentRequestSection.java   Source Code and License 5 votes vote down vote up
/**
 * Sets how the extra texts should be displayed.
 *
 * @param textsTruncate How to truncate the extra texts. Set the element to null to clear.
 * @param textsAreSingleLine Whether the extra texts should be displayed in a single line.
 */
public void setExtraTextsProperties(
        TruncateAt[] textsTruncate, boolean[] textsAreSingleLine) {
    assert textsTruncate.length == mExtraTextViews.length;
    assert textsAreSingleLine.length == mExtraTextViews.length;

    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i].setEllipsize(textsTruncate[i]);
        mExtraTextViews[i].setSingleLine(textsAreSingleLine[i]);
    }
}
 
Example 34
Project: letv   File: WeiboSdkBrowser.java   Source Code and License 5 votes vote down vote up
private View initTitleBar() {
    RelativeLayout titleBar = new RelativeLayout(this);
    titleBar.setLayoutParams(new LayoutParams(-1, ResourceManager.dp2px(this, 45)));
    titleBar.setBackgroundDrawable(ResourceManager.getNinePatchDrawable(this, "weibosdk_navigationbar_background.9.png"));
    this.mLeftBtn = new TextView(this);
    this.mLeftBtn.setClickable(true);
    this.mLeftBtn.setTextSize(2, 17.0f);
    this.mLeftBtn.setTextColor(ResourceManager.createColorStateList(-32256, 1728020992));
    this.mLeftBtn.setText(ResourceManager.getString(this, CANCEL_EN, "关闭", "关闭"));
    RelativeLayout.LayoutParams leftBtnLp = new RelativeLayout.LayoutParams(-2, -2);
    leftBtnLp.addRule(5);
    leftBtnLp.addRule(15);
    leftBtnLp.leftMargin = ResourceManager.dp2px(this, 10);
    leftBtnLp.rightMargin = ResourceManager.dp2px(this, 10);
    this.mLeftBtn.setLayoutParams(leftBtnLp);
    titleBar.addView(this.mLeftBtn);
    this.mTitleText = new TextView(this);
    this.mTitleText.setTextSize(2, 18.0f);
    this.mTitleText.setTextColor(-11382190);
    this.mTitleText.setEllipsize(TruncateAt.END);
    this.mTitleText.setSingleLine(true);
    this.mTitleText.setGravity(17);
    this.mTitleText.setMaxWidth(ResourceManager.dp2px(this, 160));
    RelativeLayout.LayoutParams titleTextLy = new RelativeLayout.LayoutParams(-2, -2);
    titleTextLy.addRule(13);
    this.mTitleText.setLayoutParams(titleTextLy);
    titleBar.addView(this.mTitleText);
    return titleBar;
}
 
Example 35
Project: PlusGram   File: EditTextCaption.java   Source Code and License 5 votes vote down vote up
@SuppressLint({"DrawAllocation"})
protected void onMeasure(int i, int i2) {
    try {
        super.onMeasure(i, i2);
    } catch (Throwable e) {
        FirebaseCrash.report(e);
        setMeasuredDimension(MeasureSpec.getSize(i), AndroidUtilities.dp(51.0f));
        FileLog.e("tmessages", e);
    }
    this.f399b = null;
    if (this.f398a != null && this.f398a.length() > 0) {
        CharSequence text = getText();
        if (text.length() > 1 && text.charAt(0) == '@') {
            int indexOf = TextUtils.indexOf(text, ' ');
            if (indexOf != -1) {
                TextPaint paint = getPaint();
                int ceil = (int) Math.ceil((double) paint.measureText(text, 0, indexOf + 1));
                int measuredWidth = (getMeasuredWidth() - getPaddingLeft()) - getPaddingRight();
                this.f400c = text.subSequence(0, indexOf + 1).length();
                CharSequence ellipsize = TextUtils.ellipsize(this.f398a, paint, (float) (measuredWidth - ceil), TruncateAt.END);
                this.f401d = ceil;
                try {
                    this.f399b = new StaticLayout(ellipsize, getPaint(), measuredWidth - ceil, Alignment.ALIGN_NORMAL, DefaultRetryPolicy.DEFAULT_BACKOFF_MULT, 0.0f, false);
                    if (this.f399b.getLineCount() > 0) {
                        this.f401d = (int) (((float) this.f401d) + (-this.f399b.getLineLeft(0)));
                    }
                    this.f402e = ((getMeasuredHeight() - this.f399b.getLineBottom(0)) / 2) + AndroidUtilities.dp(0.5f);
                } catch (Throwable e2) {
                    FirebaseCrash.report(e2);
                    FileLog.e("tmessages", e2);
                }
            }
        }
    }
}
 
Example 36
Project: FireFiles   File: RecentsCreateFragment.java   Source Code and License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
    final Context context = parent.getContext();

    if (convertView == null) {
        final LayoutInflater inflater = LayoutInflater.from(context);
        convertView = inflater.inflate(R.layout.item_doc_list, parent, false);
    }

    final ImageView iconMime = (ImageView) convertView.findViewById(R.id.icon_mime);
    final TextView title = (TextView) convertView.findViewById(android.R.id.title);
    final View line2 = convertView.findViewById(R.id.line2);

    final DocumentStack stack = getItem(position);
    iconMime.setImageDrawable(stack.root.loadIcon(context));

    final Drawable crumb = ContextCompat.getDrawable(context, R.drawable.ic_breadcrumb_arrow);
    crumb.setBounds(0, 0, crumb.getIntrinsicWidth(), crumb.getIntrinsicHeight());

    final SpannableStringBuilder builder = new SpannableStringBuilder();
    builder.append(stack.root.title);
    for (int i = stack.size() - 2; i >= 0; i--) {
        appendDrawable(builder, crumb);
        builder.append(stack.get(i).displayName);
    }
    title.setText(builder);
    title.setEllipsize(TruncateAt.MIDDLE);

    if (line2 != null) line2.setVisibility(View.GONE);

    return convertView;
}
 
Example 37
Project: threed   File: Threed.java   Source Code and License 5 votes vote down vote up
public static void init(TextView view, AttributeSet attrs, int defStyleAttr) {
    Threed t = getThreed(view);
    TypedArray a = view.getContext().obtainStyledAttributes(attrs, MoreTextView, 0, defStyleAttr);
    t.moreText = a.getString(MoreTextView_moreText);
    t.moreTextColor = a.getColor(MoreTextView_moreTextColor, view.getTextColors().getDefaultColor());
    a.recycle();
    view.setEllipsize(TruncateAt.END);
    if (!isEmpty(t.moreText)) {
        view.setOnClickListener(t);
    }
}
 
Example 38
Project: boohee_v5.6   File: DietKeyboard.java   Source Code and License 5 votes vote down vote up
public void initUnit() {
    if (this.mUnits != null && this.mUnits.size() != 0 && this.currentUnit != null) {
        LayoutParams parms = new LayoutParams(-1, -2, 1.0f);
        this.ll_diet_unit.removeAllViews();
        this.unitTextViews.clear();
        for (int i = 0; i < this.mUnits.size(); i++) {
            TextView textView = new TextView(getContext());
            textView.setText(((Unit) this.mUnits.get(i)).unit_name);
            textView.setGravity(17);
            textView.setTextSize(18.0f);
            textView.setTextColor(getResources().getColor(R.color.color_light));
            textView.setBackgroundColor(getResources().getColor(R.color.color_divider));
            textView.setSingleLine(true);
            textView.setEllipsize(TruncateAt.END);
            textView.setId(i);
            textView.setOnClickListener(new UnitListener());
            if (TextUtils.equals(((Unit) this.mUnits.get(i)).unit_name, this.currentUnit
                    .unit_name)) {
                textView.setTextColor(-1);
                textView.setBackgroundColor(getResources().getColor(R.color.color_bg_number));
            }
            this.unitTextViews.add(textView);
            this.ll_diet_unit.addView(textView, parms);
        }
        if (this.mAmount < 0.0f) {
            this.mAmount = 100.0f;
        }
        this.mGram = Float.parseFloat(this.currentUnit.eat_weight) * this.mAmount;
        this.mCalory = this.mWeight * this.mGram;
        this.txt_value.setText(this.mAmount + "");
        swithTxt();
    }
}
 
Example 39
Project: Cable-Android   File: ViewUtil.java   Source Code and License 5 votes vote down vote up
public static CharSequence ellipsize(@Nullable CharSequence text, @NonNull TextView view) {
  if (TextUtils.isEmpty(text) || view.getWidth() == 0 || view.getEllipsize() != TruncateAt.END) {
    return text;
  } else {
    return TextUtils.ellipsize(text,
                               view.getPaint(),
                               view.getWidth() - view.getPaddingRight() - view.getPaddingLeft(),
                               TruncateAt.END);
  }
}
 
Example 40
Project: AndroidChromium   File: PaymentRequestSection.java   Source Code and License 5 votes vote down vote up
/**
 * Sets how the summary text should be displayed.
 *
 * @param leftTruncate How to truncate the left summary text.  Set to null to clear.
 * @param rightTruncate How to truncate the right summary text.  Set to null to clear.
 */
public void setSummaryProperties(@Nullable TruncateAt leftTruncate, boolean leftIsSingleLine,
        @Nullable TruncateAt rightTruncate, boolean rightIsSingleLine) {
    mSummaryLeftTextView.setEllipsize(leftTruncate);
    mSummaryLeftTextView.setSingleLine(leftIsSingleLine);

    mSummaryRightTextView.setEllipsize(rightTruncate);
    mSummaryRightTextView.setSingleLine(rightIsSingleLine);
}
 
Example 41
Project: AndroidChromium   File: PaymentRequestSection.java   Source Code and License 5 votes vote down vote up
/**
 * Sets how the extra texts should be displayed.
 *
 * @param textsTruncate How to truncate the extra texts. Set the element to null to clear.
 * @param textsAreSingleLine Whether the extra texts should be displayed in a single line.
 */
public void setExtraTextsProperties(
        TruncateAt[] textsTruncate, boolean[] textsAreSingleLine) {
    assert textsTruncate.length == mExtraTextViews.length;
    assert textsAreSingleLine.length == mExtraTextViews.length;

    for (int i = 0; i < mExtraTextViews.length; i++) {
        mExtraTextViews[i].setEllipsize(textsTruncate[i]);
        mExtraTextViews[i].setSingleLine(textsAreSingleLine[i]);
    }
}
 
Example 42
Project: j2se_for_android   File: HCDesktop.java   Source Code and License 5 votes vote down vote up
public HCDesktop(final Image image, String toolTip, final JPopupMenu menu){
	this.toolTip = toolTip;
	this.popupMenu = menu;
	
	statusIconView = new ImageView(ActivityManager.getActivity());
	messageView = new TextView(ActivityManager.getActivity());
	messageView.setLines(1);
	messageView.setTextColor(AndroidUIUtil.WINDOW_TITLE_FONT_COLOR.toAndroid());
	messageView.setEllipsize(TruncateAt.MARQUEE);//以跑马灯的方式显示
	
	setImage(image);
}
 
Example 43
Project: RecordHelper   File: SizeAdapter.java   Source Code and License 5 votes vote down vote up
@Override
public View getView(int position, View convertView, ViewGroup parent) {
	TextView view = new TextView(parent.getContext());
	view.setText(String.format("%s: %sx%s", "Video", sizes.get(position).width, sizes.get(position).height));
	view.setEllipsize(TruncateAt.END);
	view.setPadding(16, 16, 16, 16);
	return view;
}
 
Example 44
Project: vlc-android   File: Util.java   Source Code and License 5 votes vote down vote up
/**
 * Set the alignment mode of the specified TextView with the desired align
 * mode from preferences.
 *
 * See @array/audio_title_alignment_values
 *
 * @param alignMode Align mode as read from preferences
 * @param t Reference to the textview
 */
public static void setAlignModeByPref(int alignMode, TextView t) {
    if(alignMode == 1)
        t.setEllipsize(TruncateAt.END);
    else if(alignMode == 2)
        t.setEllipsize(TruncateAt.START);
    else if(alignMode == 3) {
        t.setEllipsize(TruncateAt.MARQUEE);
        t.setMarqueeRepeatLimit(-1);
        t.setSelected(true);
    }
}
 
Example 45
Project: Pink-Music   File: ActivitySettings.java   Source Code and License 5 votes vote down vote up
@SuppressWarnings("deprecation")
private void prepareHeader(TextView hdr) {
	hdr.setMaxLines(2);
	hdr.setEllipsize(TruncateAt.END);
	hdr.setPadding(UI.controlMargin, UI.controlMargin, UI.controlMargin, UI.controlMargin);
	if (UI.isLargeScreen)
		UI.largeText(hdr);
	else
		UI.mediumText(hdr);
	hdr.setTextColor(UI.colorState_text_highlight_static);
	hdr.setBackgroundDrawable(new ColorDrawable(UI.color_highlight));
}
 
Example 46
Project: material-master   File: TabPageIndicator.java   Source Code and License 5 votes vote down vote up
private void notifyDataSetChanged() {
       mTabContainer.removeAllViews();

       PagerAdapter adapter = mViewPager.getAdapter();
       final int count = adapter.getCount();

       if (mSelectedPosition > count)
           mSelectedPosition = count - 1;

       for (int i = 0; i < count; i++) {
           CharSequence title = adapter.getPageTitle(i);
           if (title == null)
               title = "NULL";

           CheckedTextView tv = new CheckedTextView(getContext());
           tv.setCheckMarkDrawable(null);
           tv.setText(title);
           tv.setGravity(Gravity.CENTER);
           tv.setTextAppearance(getContext(), mTextAppearance);
           if(mTabSingleLine)
               tv.setSingleLine(true);
           else {
               tv.setSingleLine(false);
               tv.setMaxLines(2);
           }
           tv.setEllipsize(TruncateAt.END);
           tv.setOnClickListener(this);
           tv.setTag(i);
           if(mTabRippleStyle > 0)
               ViewUtil.setBackground(tv, new RippleDrawable.Builder(getContext(), mTabRippleStyle).build());

           tv.setPadding(mTabPadding, 0, mTabPadding, 0);
           mTabContainer.addView(tv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
       }
       
       setCurrentItem(mSelectedPosition);
       requestLayout();
}
 
Example 47
Project: material-master   File: TabPageIndicator.java   Source Code and License 5 votes vote down vote up
private void addTemporaryTab(){
	for (int i = 0; i < 3; i++) {
           CharSequence title = null;
           if (i == 0) 
               title = "TAB ONE";        
           else if (i == 1) 
               title = "TAB TWO";
           else if (i == 2) 
               title = "TAB THREE";
           
           CheckedTextView tv = new CheckedTextView(getContext());
           tv.setCheckMarkDrawable(null);
           tv.setText(title);
           tv.setGravity(Gravity.CENTER);
           tv.setTextAppearance(getContext(), mTextAppearance);
           tv.setSingleLine(true);
           tv.setEllipsize(TruncateAt.END);
           tv.setTag(i);
           tv.setChecked(i == 0);
           if(mMode == MODE_SCROLL){
           	tv.setPadding(mTabPadding, 0, mTabPadding, 0);
           	mTabContainer.addView(tv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
           }
           else if(mMode == MODE_FIXED){
           	LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
           	params.weight = 1f;
           	mTabContainer.addView(tv, params);            	
           }            	
       } 	
}
 
Example 48
Project: Tada   File: TextView.java   Source Code and License 5 votes vote down vote up
private void startStopMarquee(boolean start) {
    if (mEllipsize == TextUtils.TruncateAt.MARQUEE) {
        if (start) {
            startMarquee();
        } else {
            stopMarquee();
        }
    }
}
 
Example 49
Project: Tada   File: TextView.java   Source Code and License 5 votes vote down vote up
@Override
public void setSelected(boolean selected) {
    boolean wasSelected = isSelected();

    super.setSelected(selected);

    if (selected != wasSelected && mEllipsize == TextUtils.TruncateAt.MARQUEE) {
        if (selected) {
            startMarquee();
        } else {
            stopMarquee();
        }
    }
}
 
Example 50
Project: Tada   File: TextView.java   Source Code and License 5 votes vote down vote up
@Override
protected float getRightFadingEdgeStrength() {
    if (mEllipsize == TextUtils.TruncateAt.MARQUEE &&
            mMarqueeFadeMode != MARQUEE_FADE_SWITCH_SHOW_ELLIPSIS) {
        if (mMarquee != null && !mMarquee.isStopped()) {
            final Marquee marquee = mMarquee;
            final float maxFadeScroll = marquee.getMaxFadeScroll();
            final float scroll = marquee.getScroll();
            return (maxFadeScroll - scroll) / getHorizontalFadingEdgeLength();
        } else if (getLineCount() == 1) {
            final int layoutDirection = getLayoutDirection();
            final int absoluteGravity = Gravity.getAbsoluteGravity(mGravity, layoutDirection);
            switch (absoluteGravity & Gravity.HORIZONTAL_GRAVITY_MASK) {
                case Gravity.LEFT:
                    final int textWidth = (mRight - mLeft) - getCompoundPaddingLeft() -
                            getCompoundPaddingRight();
                    final float lineWidth = mLayout.getLineWidth(0);
                    return (lineWidth - textWidth) / getHorizontalFadingEdgeLength();
                case Gravity.RIGHT:
                    return 0.0f;
                case Gravity.CENTER_HORIZONTAL:
                case Gravity.FILL_HORIZONTAL:
                    final int textDirection = mLayout.getParagraphDirection(0);
                    if (textDirection == Layout.DIR_RIGHT_TO_LEFT) {
                        return 0.0f;
                    } else {
                        return (mLayout.getLineWidth(0) - ((mRight - mLeft) -
                            getCompoundPaddingLeft() - getCompoundPaddingRight())) /
                            getHorizontalFadingEdgeLength();
                    }
            }
        }
    }
    return super.getRightFadingEdgeStrength();
}
 
Example 51
Project: FMTech   File: ExtrasItemSnippet.java   Source Code and License 5 votes vote down vote up
public final void updateContentView()
{
  VideoDetails localVideoDetails = this.mDocument.getVideoDetails();
  this.mExtrasItemTitle.setText(this.mDocument.mDocument.title);
  this.mExtrasItemTitle.setMaxLines(2);
  this.mExtrasItemTitle.setEllipsize(TextUtils.TruncateAt.END);
  Account localAccount1 = FinskyApp.get().getCurrentAccount();
  Libraries localLibraries = FinskyApp.get().mLibraries;
  final Account localAccount2 = LibraryUtils.getOwnerWithCurrentAccount(this.mDocument, localLibraries, localAccount1);
  if (localAccount2 != null)
  {
    this.mDuration.setText(null);
    this.mPlayButton.setVisibility(0);
    this.mPlayButton.setDrawAsLabel(false);
    this.mPlayButton.setActionStyle(2);
    this.mPlayButton.setEnabled(true);
    this.mPlayButton.configure(4, 2131362550, new View.OnClickListener()
    {
      public final void onClick(View paramAnonymousView)
      {
        FinskyApp.get().getEventLogger().logClickEvent(218, null, ExtrasItemSnippet.this.mParentNode);
        ExtrasItemSnippet.this.mNavigationManager.openItem(localAccount2, ExtrasItemSnippet.this.mDocument, false);
      }
    });
    return;
  }
  this.mPlayButton.setVisibility(8);
  this.mDuration.setText(localVideoDetails.duration.toUpperCase(Locale.getDefault()));
}
 
Example 52
Project: Material-Components   File: TabPageIndicator.java   Source Code and License 5 votes vote down vote up
private void addTemporaryTab(){
	for (int i = 0; i < 3; i++) {
           CharSequence title = null;
           if (i == 0) 
               title = "TAB ONE";        
           else if (i == 1) 
               title = "TAB TWO";
           else if (i == 2) 
               title = "TAB THREE";
           
           CheckedTextView tv = new CheckedTextView(getContext());
           tv.setCheckMarkDrawable(null);
           tv.setText(title);
           tv.setGravity(Gravity.CENTER);
           tv.setTextAppearance(getContext(), mTextAppearance);
           tv.setSingleLine(true);
           tv.setEllipsize(TruncateAt.END);
           tv.setTag(i);
           tv.setChecked(i == 0);
           if(mMode == MODE_SCROLL){
           	tv.setPadding(mTabPadding, 0, mTabPadding, 0);
           	mTabContainer.addView(tv, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WRAP_CONTENT, ViewGroup.LayoutParams.MATCH_PARENT));
           }
           else if(mMode == MODE_FIXED){
           	LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, LinearLayout.LayoutParams.MATCH_PARENT);
           	params.weight = 1f;
           	mTabContainer.addView(tv, params);            	
           }            	
       } 	
}
 
Example 53
Project: FMTech   File: EpisodeSnippet.java   Source Code and License 5 votes vote down vote up
public final void updateContentView()
{
  TvEpisodeDetails localTvEpisodeDetails = this.mEpisode.getTvEpisodeDetails();
  this.mEpisodeNumber.setText(Integer.toString(localTvEpisodeDetails.episodeIndex));
  TextView localTextView = this.mEpisodeNumber;
  Resources localResources = getResources();
  Object[] arrayOfObject = new Object[1];
  arrayOfObject[0] = Integer.valueOf(localTvEpisodeDetails.episodeIndex);
  localTextView.setContentDescription(localResources.getString(2131361985, arrayOfObject));
  this.mEpisodeTitle.setText(this.mEpisode.mDocument.title);
  this.mEpisodeTitle.setMaxLines(2);
  this.mEpisodeTitle.setEllipsize(TextUtils.TruncateAt.END);
  updateBuyButtonState(getResources(), this.mBuyButton, this.mAddedState, this.mAddedDrawable, this.mSeasonDocument, this.mEpisode, this.mIsNewPurchase, this.mNavigationManager, this);
}
 
Example 54
Project: FMTech   File: Toolbar.java   Source Code and License 5 votes vote down vote up
public void setSubtitle(CharSequence paramCharSequence)
{
  if (!TextUtils.isEmpty(paramCharSequence))
  {
    if (this.mSubtitleTextView == null)
    {
      Context localContext = getContext();
      this.mSubtitleTextView = new TextView(localContext);
      this.mSubtitleTextView.setSingleLine();
      this.mSubtitleTextView.setEllipsize(TextUtils.TruncateAt.END);
      if (this.mSubtitleTextAppearance != 0) {
        this.mSubtitleTextView.setTextAppearance(localContext, this.mSubtitleTextAppearance);
      }
      if (this.mSubtitleTextColor != 0) {
        this.mSubtitleTextView.setTextColor(this.mSubtitleTextColor);
      }
    }
    if (!isChildOrHidden(this.mSubtitleTextView)) {
      addSystemView(this.mSubtitleTextView, true);
    }
  }
  for (;;)
  {
    if (this.mSubtitleTextView != null) {
      this.mSubtitleTextView.setText(paramCharSequence);
    }
    this.mSubtitleText = paramCharSequence;
    return;
    if ((this.mSubtitleTextView != null) && (isChildOrHidden(this.mSubtitleTextView)))
    {
      removeView(this.mSubtitleTextView);
      this.mHiddenViews.remove(this.mSubtitleTextView);
    }
  }
}
 
Example 55
Project: FMTech   File: Toolbar.java   Source Code and License 5 votes vote down vote up
public void setTitle(CharSequence paramCharSequence)
{
  if (!TextUtils.isEmpty(paramCharSequence))
  {
    if (this.mTitleTextView == null)
    {
      Context localContext = getContext();
      this.mTitleTextView = new TextView(localContext);
      this.mTitleTextView.setSingleLine();
      this.mTitleTextView.setEllipsize(TextUtils.TruncateAt.END);
      if (this.mTitleTextAppearance != 0) {
        this.mTitleTextView.setTextAppearance(localContext, this.mTitleTextAppearance);
      }
      if (this.mTitleTextColor != 0) {
        this.mTitleTextView.setTextColor(this.mTitleTextColor);
      }
    }
    if (!isChildOrHidden(this.mTitleTextView)) {
      addSystemView(this.mTitleTextView, true);
    }
  }
  for (;;)
  {
    if (this.mTitleTextView != null) {
      this.mTitleTextView.setText(paramCharSequence);
    }
    this.mTitleText = paramCharSequence;
    return;
    if ((this.mTitleTextView != null) && (isChildOrHidden(this.mTitleTextView)))
    {
      removeView(this.mTitleTextView);
      this.mHiddenViews.remove(this.mTitleTextView);
    }
  }
}
 
Example 56
Project: FMTech   File: jxg.java   Source Code and License 5 votes vote down vote up
TextView a(Context paramContext, int paramInt, String paramString)
{
  Object localObject;
  if (paramInt < this.p.size())
  {
    localObject = (TextView)this.p.get(paramInt);
    ((TextView)localObject).setCompoundDrawablesWithIntrinsicBounds(null, null, null, null);
    ((TextView)localObject).setText(jr.a().a(paramString));
    i();
    addView((View)localObject);
    return localObject;
  }
  TextView localTextView = new TextView(paramContext);
  localTextView.setTextAppearance(paramContext, eyg.aV);
  localTextView.setBackgroundResource(efj.TG);
  localTextView.setPadding(o, g, o, g);
  if (this.L) {}
  for (int i1 = 5;; i1 = 3)
  {
    localTextView.setGravity(i1 | 0x10);
    localTextView.setClickable(true);
    localTextView.setOnClickListener(this.A);
    localTextView.setMaxLines(i);
    localTextView.setFilters(K);
    localTextView.setEllipsize(TextUtils.TruncateAt.END);
    this.p.add(localTextView);
    localObject = localTextView;
    break;
  }
}
 
Example 57
Project: EasyLinkNJ   File: ExDecorView.java   Source Code and License 5 votes vote down vote up
private TextView getTitleTextView(CharSequence text, int textColor, int textSizeDp, int textHoriPaddingDp,
		boolean isBold, OnClickListener lisn) {

	TextView tv = new TextView(getContext());
	if (isBold)
		tv.getPaint().setFakeBoldText(true);

	tv.setGravity(Gravity.CENTER);
	tv.setSingleLine();
	tv.setEllipsize(TruncateAt.END);
	tv.setText(text);

	if (textHoriPaddingDp > 0)
		tv.setPadding(textHoriPaddingDp, 0, textHoriPaddingDp, 0);

	if (textSizeDp > 0)
		tv.setTextSize(TypedValue.COMPLEX_UNIT_PX, textSizeDp);

	if (textColor != 0)
		tv.setTextColor(textColor);

	if (mStyle.mTitleClickerBackgroundResId != 0)
		tv.setBackgroundResource(mStyle.mTitleClickerBackgroundResId);

	if (lisn != null)
		tv.setOnClickListener(lisn);

	return tv;
}
 
Example 58
Project: FMTech   File: CircleWithAvatarsViewGroup.java   Source Code and License 5 votes vote down vote up
public CircleWithAvatarsViewGroup(Context paramContext)
{
  super(paramContext);
  Context localContext = getContext();
  Resources localResources = getResources();
  this.c = localResources.getDimensionPixelSize(efj.SO);
  this.e = localResources.getDimensionPixelSize(efj.SP);
  this.d = localResources.getDimensionPixelSize(efj.SN);
  this.j = new lve(this);
  this.h = new TextView(localContext);
  this.h.setMaxLines(1);
  this.h.setEllipsize(TextUtils.TruncateAt.END);
  this.h.setTextAppearance(localContext, ehr.dn);
  addView(this.h);
  this.i = new TextView(localContext);
  this.i.setMaxLines(1);
  this.i.setEllipsize(TextUtils.TruncateAt.END);
  this.i.setTextAppearance(localContext, ehr.dl);
  addView(this.i);
  this.f = new AvatarGroupView(localContext);
  this.f.setTag("avatar_group_view");
  addView(this.f);
  this.g = new joo(localContext);
  this.g.setTag("circle_icon_view");
  addView(this.g);
  this.k = localResources.getColor(ehr.dg);
}
 
Example 59
Project: FMTech   File: CircleWithAvatarsViewGroup.java   Source Code and License 5 votes vote down vote up
public CircleWithAvatarsViewGroup(Context paramContext, AttributeSet paramAttributeSet)
{
  super(paramContext, paramAttributeSet);
  Context localContext = getContext();
  Resources localResources = getResources();
  this.c = localResources.getDimensionPixelSize(efj.SO);
  this.e = localResources.getDimensionPixelSize(efj.SP);
  this.d = localResources.getDimensionPixelSize(efj.SN);
  this.j = new lve(this);
  this.h = new TextView(localContext);
  this.h.setMaxLines(1);
  this.h.setEllipsize(TextUtils.TruncateAt.END);
  this.h.setTextAppearance(localContext, ehr.dn);
  addView(this.h);
  this.i = new TextView(localContext);
  this.i.setMaxLines(1);
  this.i.setEllipsize(TextUtils.TruncateAt.END);
  this.i.setTextAppearance(localContext, ehr.dl);
  addView(this.i);
  this.f = new AvatarGroupView(localContext);
  this.f.setTag("avatar_group_view");
  addView(this.f);
  this.g = new joo(localContext);
  this.g.setTag("circle_icon_view");
  addView(this.g);
  this.k = localResources.getColor(ehr.dg);
}
 
Example 60
Project: FMTech   File: CircleWithAvatarsViewGroup.java   Source Code and License 5 votes vote down vote up
public CircleWithAvatarsViewGroup(Context paramContext, AttributeSet paramAttributeSet, int paramInt)
{
  super(paramContext, paramAttributeSet, paramInt);
  Context localContext = getContext();
  Resources localResources = getResources();
  this.c = localResources.getDimensionPixelSize(efj.SO);
  this.e = localResources.getDimensionPixelSize(efj.SP);
  this.d = localResources.getDimensionPixelSize(efj.SN);
  this.j = new lve(this);
  this.h = new TextView(localContext);
  this.h.setMaxLines(1);
  this.h.setEllipsize(TextUtils.TruncateAt.END);
  this.h.setTextAppearance(localContext, ehr.dn);
  addView(this.h);
  this.i = new TextView(localContext);
  this.i.setMaxLines(1);
  this.i.setEllipsize(TextUtils.TruncateAt.END);
  this.i.setTextAppearance(localContext, ehr.dl);
  addView(this.i);
  this.f = new AvatarGroupView(localContext);
  this.f.setTag("avatar_group_view");
  addView(this.f);
  this.g = new joo(localContext);
  this.g.setTag("circle_icon_view");
  addView(this.g);
  this.k = localResources.getColor(ehr.dg);
}