use of org.telegram.ui.Cells.DialogsEmptyCell in project Telegram-FOSS by Telegram-FOSS-Team.
the class DialogsAdapter method onCreateViewHolder.
@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup viewGroup, int viewType) {
View view;
switch(viewType) {
case 0:
DialogCell dialogCell = new DialogCell(parentFragment, mContext, true, false, currentAccount, null);
dialogCell.setArchivedPullAnimation(pullForegroundDrawable);
dialogCell.setPreloader(preloader);
view = dialogCell;
break;
case 1:
FlickerLoadingView flickerLoadingView = new FlickerLoadingView(mContext);
flickerLoadingView.setIsSingleCell(true);
flickerLoadingView.setViewType(FlickerLoadingView.DIALOG_CELL_TYPE);
view = flickerLoadingView;
break;
case 2:
{
HeaderCell headerCell = new HeaderCell(mContext);
headerCell.setText(LocaleController.getString("RecentlyViewed", R.string.RecentlyViewed));
TextView textView = new TextView(mContext);
textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 15);
textView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueHeader));
textView.setText(LocaleController.getString("RecentlyViewedHide", R.string.RecentlyViewedHide));
textView.setGravity((LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL);
headerCell.addView(textView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.TOP, 17, 15, 17, 0));
textView.setOnClickListener(view1 -> {
MessagesController.getInstance(currentAccount).hintDialogs.clear();
SharedPreferences preferences = MessagesController.getGlobalMainSettings();
preferences.edit().remove("installReferer").commit();
notifyDataSetChanged();
});
view = headerCell;
break;
}
case 3:
FrameLayout frameLayout = new FrameLayout(mContext) {
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(12), MeasureSpec.EXACTLY));
}
};
frameLayout.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundGray));
View v = new View(mContext);
v.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
frameLayout.addView(v, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
view = frameLayout;
break;
case 4:
view = new DialogMeUrlCell(mContext);
break;
case 5:
view = new DialogsEmptyCell(mContext);
break;
case 6:
view = new UserCell(mContext, 8, 0, false);
break;
case 7:
view = new HeaderCell(mContext);
break;
case 8:
{
view = new ShadowSectionCell(mContext);
Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
combinedDrawable.setFullsize(true);
view.setBackgroundDrawable(combinedDrawable);
break;
}
case 9:
archiveHintCell = new ArchiveHintCell(mContext);
view = archiveHintCell;
break;
case 10:
{
view = new LastEmptyView(mContext);
break;
}
case 11:
{
view = new TextInfoPrivacyCell(mContext) {
private int movement;
private float moveProgress;
private long lastUpdateTime;
private int originalX;
private int originalY;
@Override
protected void afterTextDraw() {
if (arrowDrawable != null) {
Rect bounds = arrowDrawable.getBounds();
arrowDrawable.setBounds(originalX, originalY, originalX + bounds.width(), originalY + bounds.height());
}
}
@Override
protected void onTextDraw() {
if (arrowDrawable != null) {
Rect bounds = arrowDrawable.getBounds();
int dx = (int) (moveProgress * AndroidUtilities.dp(3));
originalX = bounds.left;
originalY = bounds.top;
arrowDrawable.setBounds(originalX + dx, originalY + AndroidUtilities.dp(1), originalX + dx + bounds.width(), originalY + AndroidUtilities.dp(1) + bounds.height());
long newUpdateTime = SystemClock.elapsedRealtime();
long dt = newUpdateTime - lastUpdateTime;
if (dt > 17) {
dt = 17;
}
lastUpdateTime = newUpdateTime;
if (movement == 0) {
moveProgress += dt / 664.0f;
if (moveProgress >= 1.0f) {
movement = 1;
moveProgress = 1.0f;
}
} else {
moveProgress -= dt / 664.0f;
if (moveProgress <= 0.0f) {
movement = 0;
moveProgress = 0.0f;
}
}
getTextView().invalidate();
}
}
};
Drawable drawable = Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow);
CombinedDrawable combinedDrawable = new CombinedDrawable(new ColorDrawable(Theme.getColor(Theme.key_windowBackgroundGray)), drawable);
combinedDrawable.setFullsize(true);
view.setBackgroundDrawable(combinedDrawable);
break;
}
case 12:
default:
{
view = new TextCell(mContext);
}
}
view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, viewType == 5 ? RecyclerView.LayoutParams.MATCH_PARENT : RecyclerView.LayoutParams.WRAP_CONTENT));
return new RecyclerListView.Holder(view);
}
Aggregations