public DialogHolder( Context context, FrameLayout fl, final OnItemClickedListener<Dialog> onClickListener) { super(fl); this.context = context; final int paddingH = Screen.dp(11); final int paddingV = Screen.dp(9); pendingColor = context.getResources().getColor(R.color.chats_state_pending); sentColor = context.getResources().getColor(R.color.chats_state_sent); receivedColor = context.getResources().getColor(R.color.chats_state_delivered); readColor = context.getResources().getColor(R.color.chats_state_read); errorColor = context.getResources().getColor(R.color.chats_state_error); fl.setLayoutParams( new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, Screen.dp(73))); fl.setBackgroundResource(R.drawable.selector_fill); avatar = new AvatarView(context); avatar.init(Screen.dp(52), 24); { FrameLayout.LayoutParams avatarLayoutParams = new FrameLayout.LayoutParams(Screen.dp(52), Screen.dp(52)); avatarLayoutParams.gravity = Gravity.CENTER_VERTICAL | Gravity.LEFT; avatarLayoutParams.leftMargin = paddingH; avatar.setLayoutParams(avatarLayoutParams); } fl.addView(avatar); LinearLayout linearLayout = new LinearLayout(context); linearLayout.setOrientation(LinearLayout.VERTICAL); linearLayout.setGravity(Gravity.TOP); { FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT); layoutParams.rightMargin = paddingH; layoutParams.leftMargin = Screen.dp(79); layoutParams.topMargin = paddingV; layoutParams.bottomMargin = paddingV; linearLayout.setLayoutParams(layoutParams); } LinearLayout firstRow = new LinearLayout(context); firstRow.setOrientation(LinearLayout.HORIZONTAL); { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT); firstRow.setLayoutParams(params); } title = new TextView(context); title.setTextColor(context.getResources().getColor(R.color.chats_title)); title.setTypeface(Fonts.medium()); title.setTextSize(17); title.setPadding(0, Screen.dp(1), 0, 0); title.setSingleLine(); title.setCompoundDrawablePadding(Screen.dp(4)); title.setEllipsize(TextUtils.TruncateAt.END); { LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(0, ViewGroup.LayoutParams.WRAP_CONTENT); params.weight = 1; title.setLayoutParams(params); } firstRow.addView(title); time = new TextView(context); time.setTextColor(context.getResources().getColor(R.color.chats_time)); time.setTypeface(Fonts.regular()); time.setTextSize(13); time.setPadding(Screen.dp(6), 0, 0, 0); time.setSingleLine(); firstRow.addView(time); linearLayout.addView(firstRow); text = new TextView(context); text.setTypeface(Fonts.regular()); text.setTextColor(context.getResources().getColor(R.color.chats_text)); text.setTextSize(15); text.setPadding(0, Screen.dp(5), Screen.dp(28), 0); text.setSingleLine(); text.setEllipsize(TextUtils.TruncateAt.END); linearLayout.addView(text); fl.addView(linearLayout); separator = new View(context); separator.setBackgroundColor(context.getResources().getColor(R.color.chats_divider)); FrameLayout.LayoutParams divLayoutParams = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.MATCH_PARENT, context.getResources().getDimensionPixelSize(R.dimen.div_size)); divLayoutParams.leftMargin = Screen.dp(76); divLayoutParams.gravity = Gravity.BOTTOM; fl.addView(separator, divLayoutParams); state = new TintImageView(context); { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( Screen.dp(28), Screen.dp(12), Gravity.BOTTOM | Gravity.RIGHT); params.bottomMargin = Screen.dp(16); params.rightMargin = Screen.dp(9); state.setLayoutParams(params); fl.addView(state); } counter = new TextView(context); counter.setTextColor(context.getResources().getColor(R.color.chats_counter)); counter.setBackgroundColor(context.getResources().getColor(R.color.chats_counter_bg)); counter.setPadding(Screen.dp(4), 0, Screen.dp(4), 0); counter.setTextSize(10); counter.setTypeface(Fonts.regular()); counter.setGravity(Gravity.CENTER); counter.setIncludeFontPadding(false); counter.setMinWidth(Screen.dp(14)); { FrameLayout.LayoutParams params = new FrameLayout.LayoutParams( ViewGroup.LayoutParams.WRAP_CONTENT, Screen.dp(14), Gravity.BOTTOM | Gravity.RIGHT); params.bottomMargin = Screen.dp(12); params.rightMargin = Screen.dp(10); counter.setLayoutParams(params); fl.addView(counter); } fl.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { if (bindedItem != null) { onClickListener.onClicked(bindedItem); } } }); fl.setOnLongClickListener( new View.OnLongClickListener() { @Override public boolean onLongClick(View v) { if (bindedItem != null) { return onClickListener.onLongClicked(bindedItem); } return false; } }); }