mirror of
https://github.com/oxen-io/session-android.git
synced 2025-12-02 02:32:37 +00:00
committed by
Moxie Marlinspike
parent
bbf33f88e0
commit
c36c759c8b
@@ -18,8 +18,13 @@ package org.thoughtcrime.securesms.util;
|
||||
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.support.annotation.DrawableRes;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.text.TextUtils;
|
||||
import android.text.TextUtils.TruncateAt;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.TextView;
|
||||
|
||||
public class ViewUtil {
|
||||
public static void setBackgroundSavingPadding(View v, Drawable drawable) {
|
||||
@@ -45,4 +50,15 @@ public class ViewUtil {
|
||||
if (childIndex > -1) parent.removeView(toRemove);
|
||||
parent.addView(toAdd, childIndex > -1 ? childIndex : defaultIndex);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user