下面列出了android.widget.TextView#setEllipsize ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
public CheckBoxUserCell(Context context, boolean alert) {
super(context);
textView = new TextView(context);
textView.setTextColor(Theme.getColor(alert ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 94), 0, (LocaleController.isRTL ? 94 : 17), 0));
avatarDrawable = new AvatarDrawable();
imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(36));
addView(imageView, LayoutHelper.createFrame(36, 36, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 48, 6, 48, 0));
checkBox = new CheckBoxSquare(context, alert);
addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 15, (LocaleController.isRTL ? 17 : 0), 0));
}
public DialogRadioCell(Context context, boolean dialog) {
super(context);
textView = new TextView(context);
if (dialog) {
textView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack));
} else {
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
}
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 23 : 61, 0, LocaleController.isRTL ? 61 : 23, 0));
radioButton = new RadioButton(context);
radioButton.setSize(AndroidUtilities.dp(20));
if (dialog) {
radioButton.setColor(Theme.getColor(Theme.key_dialogRadioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked));
} else {
radioButton.setColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_radioBackgroundChecked));
}
addView(radioButton, LayoutHelper.createFrame(22, 22, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 20, 15, 20, 0));
}
private void initTabLayout() {
if (quickReplies != null && quickReplies.keySet().size() > 0) {
tabLayout.removeAllViews();
for (String s : quickReplies.keySet()) {
TextView textView = new TextView(context);
textView.setLayoutParams(new LayoutParams(Utils.getScreenWidth(context) / 4, ViewGroup.LayoutParams.MATCH_PARENT));
textView.setText(s);
textView.setMaxLines(1);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setTag(s);
textView.setPadding(8, 0, 8, 0);
textView.setGravity(Gravity.CENTER);
textView.setOnClickListener(new TabOnClickListener());
TextView splitView = new TextView(context);
splitView.setLayoutParams(new LayoutParams(Utils.dpToPx(context, 1), ViewGroup.LayoutParams.MATCH_PARENT));
splitView.setBackgroundResource(R.color.atom_ui_light_gray_DD);
tabLayout.addView(textView);
tabLayout.addView(splitView);
}
selectedTab = tabLayout.getChildAt(0);
selectedTab.setBackgroundResource(selectTabColor);
}
}
public AttachButton(Context context) {
super(context);
setWillNotDraw(false);
imageView = new RLottieImageView(context) {
@Override
public void setScaleX(float scaleX) {
super.setScaleX(scaleX);
AttachButton.this.invalidate();
}
};
imageView.setScaleType(ImageView.ScaleType.CENTER);
addView(imageView, LayoutHelper.createFrame(32, 32, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 0, 18, 0, 0));
textView = new TextView(context);
textView.setMaxLines(2);
textView.setGravity(Gravity.CENTER_HORIZONTAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setTextColor(Theme.getColor(Theme.key_dialogTextGray2));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 12);
textView.setLineSpacing(-AndroidUtilities.dp(2), 1.0f);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.TOP, 0, 62, 0, 0));
}
private TextView newTextView(){
TextView textView = new TextView(getContext());
FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT, Gravity.CENTER_VERTICAL);
textView.setLayoutParams(lp);
textView.setCompoundDrawablePadding(10);
textView.setGravity(Gravity.CENTER_VERTICAL);
textView.setLines(2);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setTextColor(Color.parseColor(DEFAULT_TEXT_COLOR));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, DEFAULT_TEXT_SIZE);
return textView;
}
public AlbumView(Context context) {
super(context);
imageView = new BackupImageView(context);
addView(imageView,
LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
linearLayout.setBackgroundColor(0x7f000000);
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 28,
Gravity.LEFT | Gravity.BOTTOM));
nameTextView = new TextView(context);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
nameTextView.setTextColor(0xffffffff);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setMaxLines(1);
nameTextView.setGravity(Gravity.CENTER_VERTICAL);
linearLayout.addView(nameTextView,
LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, 8, 0, 0, 0));
countTextView = new TextView(context);
countTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
countTextView.setTextColor(0xffaaaaaa);
countTextView.setSingleLine(true);
countTextView.setEllipsize(TextUtils.TruncateAt.END);
countTextView.setMaxLines(1);
countTextView.setGravity(Gravity.CENTER_VERTICAL);
linearLayout.addView(countTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT,
LayoutHelper.MATCH_PARENT, 4, 0, 4, 0));
selector = new View(context);
selector.setBackgroundResource(R.drawable.list_selector);
addView(selector,
LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
}
public BotSwitchCell(Context context) {
super(context);
textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTextColor(Theme.getColor(Theme.key_chat_botSwitchToInlineText));
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setMaxLines(1);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT));
addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 14, 0, 14, 0));
}
/**
* Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
* @param view the text view to be configured
*/
protected void configureTextView(TextView view) {
view.setTextColor(textColor);
view.setGravity(Gravity.CENTER);
view.setTextSize(textSize);
view.setEllipsize(TextUtils.TruncateAt.END);
view.setLines(1);
// view.setCompoundDrawablePadding(20);
// view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
}
public PaymentInfoCell(Context context) {
super(context);
imageView = new BackupImageView(context);
addView(imageView, LayoutHelper.createFrame(100, 100, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), 10, 10, 10, 0));
nameTextView = new TextView(context);
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
nameTextView.setLines(1);
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 9, LocaleController.isRTL ? 123 : 10, 0));
detailTextView = new TextView(context);
detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
detailTextView.setMaxLines(3);
detailTextView.setEllipsize(TextUtils.TruncateAt.END);
detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 33, LocaleController.isRTL ? 123 : 10, 0));
detailExTextView = new TextView(context);
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 13);
detailExTextView.setLines(1);
detailExTextView.setMaxLines(1);
detailExTextView.setSingleLine(true);
detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 10 : 123, 90, LocaleController.isRTL ? 123 : 10, 0));
}
public DrawerUserCell(Context context) {
super(context);
avatarDrawable = new AvatarDrawable();
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(18));
addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 14, 6, 0, 0));
textView = new TextView(context);
textView.setTextColor(Theme.getColor(Theme.key_chats_menuItemText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 72, 0, 60, 0));
checkBox = new GroupCreateCheckBox(context);
checkBox.setChecked(true, false);
checkBox.setCheckScale(0.9f);
checkBox.setInnerRadDiff(AndroidUtilities.dp(1.5f));
checkBox.setColorKeysOverrides(Theme.key_chats_unreadCounterText, Theme.key_chats_unreadCounter, Theme.key_chats_menuBackground);
addView(checkBox, LayoutHelper.createFrame(18, 18, Gravity.LEFT | Gravity.TOP, 37, 27, 0, 0));
setWillNotDraw(false);
}
public LocationCell(Context context) {
super(context);
imageView = new BackupImageView(context);
imageView.setBackgroundResource(R.drawable.round_grey);
imageView.setSize(AndroidUtilities.dp(30), AndroidUtilities.dp(30));
imageView.getImageReceiver().setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3), PorterDuff.Mode.MULTIPLY));
addView(imageView, LayoutHelper.createFrame(40, 40, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), LocaleController.isRTL ? 0 : 17, 8, LocaleController.isRTL ? 17 : 0, 0));
nameTextView = new TextView(context);
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
nameTextView.setMaxLines(1);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setSingleLine(true);
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
nameTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
addView(nameTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), (LocaleController.isRTL ? 16 : 72), 5, (LocaleController.isRTL ? 72 : 16), 0));
addressTextView = new TextView(context);
addressTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
addressTextView.setMaxLines(1);
addressTextView.setEllipsize(TextUtils.TruncateAt.END);
addressTextView.setSingleLine(true);
addressTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
addressTextView.setGravity(LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT);
addView(addressTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT), (LocaleController.isRTL ? 16 : 72), 30, (LocaleController.isRTL ? 72 : 16), 0));
}
/**
* Configures text view. Is called for the TEXT_VIEW_ITEM_RESOURCE views.
*
* @param view the text view to be configured
*/
protected void configureTextView(TextView view) {
view.setTextColor(textColor);
view.setGravity(Gravity.CENTER);
view.setTextSize(textSize);
view.setEllipsize(TextUtils.TruncateAt.END);
view.setLines(1);
view.setPadding(0, 5, 0, 5);//设置条目间距
// view.setCompoundDrawablePadding(20);
// view.setTypeface(Typeface.SANS_SERIF, Typeface.BOLD);
}
public CheckBoxCell(Context context, int type) {
super(context);
textView = new TextView(context);
textView.setTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextBlack : Theme.key_windowBackgroundWhiteBlackText));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
if (type == 2) {
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 29), 0, (LocaleController.isRTL ? 29 : 0), 0));
} else {
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 17 : 46), 0, (LocaleController.isRTL ? 46 : 17), 0));
}
valueTextView = new TextView(context);
valueTextView.setTextColor(Theme.getColor(type == 1 ? Theme.key_dialogTextBlue : Theme.key_windowBackgroundWhiteValueText));
valueTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
valueTextView.setLines(1);
valueTextView.setMaxLines(1);
valueTextView.setSingleLine(true);
valueTextView.setEllipsize(TextUtils.TruncateAt.END);
valueTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 0, 17, 0));
checkBox = new CheckBoxSquare(context, type == 1);
if (type == 2) {
addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 0, 15, 0, 0));
} else {
addView(checkBox, LayoutHelper.createFrame(18, 18, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 17), 15, (LocaleController.isRTL ? 17 : 0), 0));
}
}
private void initView(Context context) {
mLeftText = new TextView(context);
mCenterLayout = new LinearLayout(context);
mRightLayout = new LinearLayout(context);
mDividerView = new View(context);
LayoutParams layoutParams = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT);
mLeftText.setTextSize(DEFAULT_ACTION_TEXT_SIZE);
mLeftText.setSingleLine();
mLeftText.setGravity(Gravity.CENTER_VERTICAL);
mLeftText.setPadding(mOutPadding + mActionPadding, 0, mOutPadding, 0);
mCenterText = new TextView(context);
mSubTitleText = new TextView(context);
mCenterLayout.addView(mCenterText);
mCenterLayout.addView(mSubTitleText);
mCenterLayout.setGravity(Gravity.CENTER);
mCenterText.setTextSize(DEFAULT_MAIN_TEXT_SIZE);
mCenterText.setSingleLine();
mCenterText.setGravity(Gravity.CENTER);
mCenterText.setEllipsize(TextUtils.TruncateAt.END);
mSubTitleText.setTextSize(DEFAULT_SUB_TEXT_SIZE);
mSubTitleText.setSingleLine();
mSubTitleText.setGravity(Gravity.CENTER);
mSubTitleText.setEllipsize(TextUtils.TruncateAt.END);
mRightLayout.setPadding(mOutPadding, 0, mOutPadding, 0);
addView(mLeftText, layoutParams);
addView(mCenterLayout);
addView(mRightLayout, layoutParams);
addView(mDividerView, new LayoutParams(LayoutParams.MATCH_PARENT, 1));
}
public AccountSelectCell(Context context) {
super(context);
avatarDrawable = new AvatarDrawable();
avatarDrawable.setTextSize(AndroidUtilities.dp(12));
imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(18));
addView(imageView, LayoutHelper.createFrame(36, 36, Gravity.LEFT | Gravity.TOP, 10, 10, 0, 0));
textView = new TextView(context);
textView.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSubmenuItem));
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setGravity(Gravity.LEFT | Gravity.CENTER_VERTICAL);
textView.setEllipsize(TextUtils.TruncateAt.END);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 61, 0, 56, 0));
checkImageView = new ImageView(context);
checkImageView.setImageResource(R.drawable.account_check);
checkImageView.setScaleType(ImageView.ScaleType.CENTER);
checkImageView.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_chats_menuItemCheck), PorterDuff.Mode.MULTIPLY));
addView(checkImageView, LayoutHelper.createFrame(40, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 0, 6, 0));
}
/**
* Updates the total and how it's broken down.
*
* @param cart The shopping cart contents and the total.
*/
public void update(ShoppingCart cart) {
Context context = mBreakdownLayout.getContext();
CharSequence totalPrice = createValueString(
cart.getTotal().getCurrency(), cart.getTotal().getPrice(), true);
// Show the updated text view if the total changed.
showUpdateIfTextChanged(totalPrice);
// Update the summary to display information about the total.
setSummaryText(cart.getTotal().getLabel(), totalPrice);
mBreakdownLayout.removeAllViews();
if (cart.getContents() == null) return;
int maximumDescriptionWidthPx =
((View) mBreakdownLayout.getParent()).getWidth() * 2 / 3;
// Update the breakdown, using one row per {@link LineItem}.
int numItems = cart.getContents().size();
mBreakdownLayout.setRowCount(numItems);
for (int i = 0; i < numItems; i++) {
LineItem item = cart.getContents().get(i);
TextView description = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(description, item.getIsPending()
? R.style.PaymentsUiSectionPendingTextEndAligned
: R.style.PaymentsUiSectionDescriptiveTextEndAligned);
description.setText(item.getLabel());
description.setEllipsize(TruncateAt.END);
description.setMaxLines(2);
if (maximumDescriptionWidthPx > 0) {
description.setMaxWidth(maximumDescriptionWidthPx);
}
TextView amount = new TextView(context);
ApiCompatibilityUtils.setTextAppearance(amount, item.getIsPending()
? R.style.PaymentsUiSectionPendingTextEndAligned
: R.style.PaymentsUiSectionDescriptiveTextEndAligned);
amount.setText(createValueString(item.getCurrency(), item.getPrice(), false));
// Each item is represented by a row in the GridLayout.
GridLayout.LayoutParams descriptionParams = new GridLayout.LayoutParams(
GridLayout.spec(i, 1, GridLayout.END),
GridLayout.spec(0, 1, GridLayout.END));
GridLayout.LayoutParams amountParams = new GridLayout.LayoutParams(
GridLayout.spec(i, 1, GridLayout.END),
GridLayout.spec(1, 1, GridLayout.END));
ApiCompatibilityUtils.setMarginStart(amountParams,
context.getResources().getDimensionPixelSize(
R.dimen.payments_section_descriptive_item_spacing));
mBreakdownLayout.addView(description, descriptionParams);
mBreakdownLayout.addView(amount, amountParams);
}
}
public SessionCell(Context context, int type) {
super(context);
LinearLayout linearLayout = new LinearLayout(context);
linearLayout.setOrientation(LinearLayout.HORIZONTAL);
linearLayout.setWeightSum(1);
if (type == 1) {
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 49), 11, (LocaleController.isRTL ? 49 : 15), 0));
avatarDrawable = new AvatarDrawable();
avatarDrawable.setTextSize(AndroidUtilities.dp(10));
imageView = new BackupImageView(context);
imageView.setRoundRadius(AndroidUtilities.dp(10));
addView(imageView, LayoutHelper.createFrame(20, 20, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 0 : 21), 13, (LocaleController.isRTL ? 21 : 0), 0));
} else {
addView(linearLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 30, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, (LocaleController.isRTL ? 15 : 21), 11, (LocaleController.isRTL ? 21 : 15), 0));
}
nameTextView = new TextView(context);
nameTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
nameTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
nameTextView.setLines(1);
nameTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
nameTextView.setMaxLines(1);
nameTextView.setSingleLine(true);
nameTextView.setEllipsize(TextUtils.TruncateAt.END);
nameTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
onlineTextView = new TextView(context);
onlineTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
onlineTextView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP);
if (LocaleController.isRTL) {
linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.LEFT | Gravity.TOP, 0, 2, 0, 0));
linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.RIGHT | Gravity.TOP, 10, 0, 0, 0));
} else {
linearLayout.addView(nameTextView, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1.0f, Gravity.LEFT | Gravity.TOP, 0, 0, 10, 0));
linearLayout.addView(onlineTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, Gravity.RIGHT | Gravity.TOP, 0, 2, 0, 0));
}
detailTextView = new TextView(context);
detailTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
detailTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
detailTextView.setLines(1);
detailTextView.setMaxLines(1);
detailTextView.setSingleLine(true);
detailTextView.setEllipsize(TextUtils.TruncateAt.END);
detailTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(detailTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 36, 21, 0));
detailExTextView = new TextView(context);
detailExTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText3));
detailExTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
detailExTextView.setLines(1);
detailExTextView.setMaxLines(1);
detailExTextView.setSingleLine(true);
detailExTextView.setEllipsize(TextUtils.TruncateAt.END);
detailExTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP);
addView(detailExTextView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 59, 21, 0));
}
public ThemeCell(Context context, boolean nightTheme) {
super(context);
setWillNotDraw(false);
isNightTheme = nightTheme;
paint = new Paint(Paint.ANTI_ALIAS_FLAG);
paintStroke = new Paint(Paint.ANTI_ALIAS_FLAG);
paintStroke.setStyle(Paint.Style.STROKE);
paintStroke.setStrokeWidth(AndroidUtilities.dp(2));
textView = new TextView(context);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
textView.setLines(1);
textView.setMaxLines(1);
textView.setSingleLine(true);
textView.setPadding(0, 0, 0, AndroidUtilities.dp(1));
textView.setEllipsize(TextUtils.TruncateAt.END);
textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, LocaleController.isRTL ? 53 + 48 + 4 : 60, 0, LocaleController.isRTL ? 60 : 53 + 48 + 4, 0));
checkImage = new ImageView(context);
checkImage.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_featuredStickers_addedIcon), PorterDuff.Mode.MULTIPLY));
checkImage.setImageResource(R.drawable.sticker_added);
if (!isNightTheme) {
addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21 + 38, 0, 21 + 38, 0));
optionsButton = new ImageView(context);
optionsButton.setFocusable(false);
optionsButton.setBackgroundDrawable(Theme.createSelectorDrawable(Theme.getColor(Theme.key_stickers_menuSelector)));
optionsButton.setImageResource(R.drawable.ic_ab_other);
optionsButton.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_stickers_menu), PorterDuff.Mode.MULTIPLY));
optionsButton.setScaleType(ImageView.ScaleType.CENTER);
optionsButton.setContentDescription(LocaleController.getString("AccDescrMoreOptions", R.string.AccDescrMoreOptions));
addView(optionsButton, LayoutHelper.createFrame(48, 48, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP));
} else {
addView(checkImage, LayoutHelper.createFrame(19, 14, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 21, 0, 21, 0));
}
}
HeaderViewHolder(View view) {
super(view);
iconView = (ImageView) view.findViewById(R.id.icon);
titleView = (TextView) view.findViewById(R.id.title);
authorView = (TextView) view.findViewById(R.id.author);
lastUpdateView = (TextView) view.findViewById(R.id.text_last_update);
summaryView = (TextView) view.findViewById(R.id.summary);
whatsNewView = (TextView) view.findViewById(R.id.whats_new);
descriptionView = (TextView) view.findViewById(R.id.description);
descriptionMoreView = (TextView) view.findViewById(R.id.description_more);
antiFeaturesSectionView = view.findViewById(R.id.anti_features_section);
antiFeaturesLabelView = (TextView) view.findViewById(R.id.label_anti_features);
antiFeaturesWarningView = view.findViewById(R.id.anti_features_warning);
antiFeaturesListingView = view.findViewById(R.id.anti_features_full_listing);
buttonLayout = view.findViewById(R.id.button_layout);
buttonPrimaryView = (Button) view.findViewById(R.id.primaryButtonView);
buttonSecondaryView = (Button) view.findViewById(R.id.secondaryButtonView);
progressLayout = view.findViewById(R.id.progress_layout);
progressBar = (ProgressBar) view.findViewById(R.id.progress_bar);
progressLabel = (TextView) view.findViewById(R.id.progress_label);
progressPercent = (TextView) view.findViewById(R.id.progress_percent);
progressCancel = view.findViewById(R.id.progress_cancel);
descriptionView.setMaxLines(MAX_LINES);
descriptionView.setEllipsize(TextUtils.TruncateAt.MARQUEE);
descriptionMoreView.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// Make this "header section" the focused child, so that RecyclerView will use
// it as the anchor in the layout process. Otherwise the RV might select another
// view as the anchor, resulting in that the top of this view is instead scrolled
// off the screen. Refer to LinearLayoutManager.updateAnchorFromChildren(...).
recyclerView.requestChildFocus(itemView, itemView);
if (TextViewCompat.getMaxLines(descriptionView) != MAX_LINES) {
descriptionView.setMaxLines(MAX_LINES);
descriptionMoreView.setText(R.string.more);
descriptionIsExpanded = false;
} else {
descriptionView.setMaxLines(Integer.MAX_VALUE);
descriptionMoreView.setText(R.string.less);
descriptionIsExpanded = true;
}
updateAntiFeaturesWarning();
}
});
}
private void init() {
LinearLayout llIcon = new LinearLayout(getContext());
llIcon.setOrientation(LinearLayout.HORIZONTAL);
addView(llIcon, new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT,
Gravity.CENTER));
ivIcon = new ImageView(getContext());
ivIcon.setPadding(0, 0, 0, UIUtil.dip2pix(0.75f));
LinearLayout.LayoutParams lpIcon = new LinearLayout.LayoutParams(LayoutParams
.MATCH_PARENT, LayoutParams.MATCH_PARENT);
lpIcon.topMargin = UIUtil.dip2pix(3);
lpIcon.bottomMargin = UIUtil.dip2pix(3);
lpIcon.gravity = Gravity.CENTER;
ivIcon.setScaleType(ScaleType.CENTER_INSIDE);
llIcon.addView(ivIcon, lpIcon);
tvText = new TextView(getContext());
tvText.setTextColor(Color.WHITE);
tvText.setTextSize(TypedValue.COMPLEX_UNIT_SP, 20);
tvText.setTypeface(null, Typeface.BOLD);
tvText.setShadowLayer(0.5f, 1, -1, Color.argb(100, 0, 0, 0));
tvText.setPadding(0, 0, 0, UIUtil.dip2pix(0.75f));
tvText.setLines(1);
tvText.setEllipsize(TruncateAt.END);
llIcon.addView(tvText);
ivArrowDown = new ImageView(getContext());
llIcon.addView(ivArrowDown, LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
((LinearLayout.LayoutParams) ivArrowDown.getLayoutParams()).gravity = Gravity
.CENTER_VERTICAL;
LinearLayout.LayoutParams lpText = (LinearLayout.LayoutParams) tvText.getLayoutParams();
lpText.weight = 1;
lpText.width = 0;
lpText.gravity = Gravity.CENTER_VERTICAL;
lpText.leftMargin = UIUtil.dip2pix(-7);
LayoutParams lpBottom = new LayoutParams(LayoutParams.MATCH_PARENT, UIUtil.dip2pix(2.67f));
lpBottom.bottomMargin = UIUtil.dip2pix(0.75f);
lpBottom.gravity = Gravity.BOTTOM;
tbtnBottom = new ToggleButton(getContext());
tbtnBottom.setTextOff("");
tbtnBottom.setTextOn("");
tbtnBottom.setText("");
tbtnBottom.setBackgroundResource(R.drawable.tab_bottom_background_selector);
tbtnBottom.setFocusable(false);
tbtnBottom.setClickable(false);
addView(tbtnBottom, lpBottom);
tvCount = new TextView(getContext());
tvCount.setTextSize(TypedValue.COMPLEX_UNIT_SP, 9);
tvCount.setGravity(Gravity.CENTER);
tvCount.setTextColor(Color.WHITE);
tvCount.setBackgroundResource(R.drawable.new_message_bg);
LayoutParams lpCount = new LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT, Gravity.CENTER);
lpCount.leftMargin = UIUtil.dip2pix(21);
lpCount.bottomMargin = UIUtil.dip2pix(11);
addView(tvCount, lpCount);
tvCount.setVisibility(View.GONE);
tvText.getViewTreeObserver().addOnGlobalLayoutListener(new OnGlobalLayoutListener() {
@Override
public void onGlobalLayout() {
if (!ellipsized) {
return;
}
ellipsized = false;
Layout l = tvText.getLayout();
if (l != null) {
int lines = l.getLineCount();
if (lines > 0) {
if (l.getEllipsisCount(lines - 1) > 0) {
ellipsized = true;
}
}
}
updateArrow();
}
}
);
}