Search in sources :

Example 1 with DividerCell

use of org.telegram.ui.Cells.DividerCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class ContactsAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            view = new UserCell(mContext, 58, 1, false);
            break;
        case 1:
            view = new TextCell(mContext);
            break;
        case 2:
            view = new GraySectionCell(mContext);
            break;
        case 3:
            view = new DividerCell(mContext);
            view.setPadding(AndroidUtilities.dp(LocaleController.isRTL ? 28 : 72), AndroidUtilities.dp(8), AndroidUtilities.dp(LocaleController.isRTL ? 72 : 28), AndroidUtilities.dp(8));
            break;
        case 4:
            FrameLayout frameLayout = new FrameLayout(mContext) {

                @Override
                protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                    int height;
                    height = MeasureSpec.getSize(heightMeasureSpec);
                    if (height == 0) {
                        height = parent.getMeasuredHeight();
                    }
                    if (height == 0) {
                        height = AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0);
                    }
                    int cellHeight = AndroidUtilities.dp(50);
                    int totalHeight = onlyUsers != 0 ? 0 : cellHeight + AndroidUtilities.dp(30);
                    if (hasGps) {
                        totalHeight += cellHeight;
                    }
                    if (!isAdmin && !needPhonebook) {
                        totalHeight += cellHeight;
                    }
                    if (totalHeight < height) {
                        height = height - totalHeight;
                    } else {
                        height = 0;
                    }
                    super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(height, MeasureSpec.EXACTLY));
                }
            };
            ContactsEmptyView emptyView = new ContactsEmptyView(mContext);
            frameLayout.addView(emptyView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER));
            view = frameLayout;
            break;
        case 5:
        default:
            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;
    }
    return new RecyclerListView.Holder(view);
}
Also used : GraySectionCell(org.telegram.ui.Cells.GraySectionCell) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ContactsEmptyView(org.telegram.ui.Components.ContactsEmptyView) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) TextCell(org.telegram.ui.Cells.TextCell) DividerCell(org.telegram.ui.Cells.DividerCell) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) UserCell(org.telegram.ui.Cells.UserCell) ContactsEmptyView(org.telegram.ui.Components.ContactsEmptyView)

Example 2 with DividerCell

use of org.telegram.ui.Cells.DividerCell in project Telegram-FOSS by Telegram-FOSS-Team.

the class DrawerLayoutAdapter method onCreateViewHolder.

@Override
public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
    View view;
    switch(viewType) {
        case 0:
            view = profileCell = new DrawerProfileCell(mContext);
            break;
        case 2:
            view = new DividerCell(mContext);
            break;
        case 3:
            view = new DrawerActionCell(mContext);
            break;
        case 4:
            view = new DrawerUserCell(mContext);
            break;
        case 5:
            view = new DrawerAddCell(mContext);
            break;
        case 1:
        default:
            view = new EmptyCell(mContext, AndroidUtilities.dp(8));
            break;
    }
    view.setLayoutParams(new RecyclerView.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT));
    return new RecyclerListView.Holder(view);
}
Also used : DrawerActionCell(org.telegram.ui.Cells.DrawerActionCell) DrawerAddCell(org.telegram.ui.Cells.DrawerAddCell) EmptyCell(org.telegram.ui.Cells.EmptyCell) DrawerUserCell(org.telegram.ui.Cells.DrawerUserCell) RecyclerView(androidx.recyclerview.widget.RecyclerView) DrawerProfileCell(org.telegram.ui.Cells.DrawerProfileCell) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) DividerCell(org.telegram.ui.Cells.DividerCell)

Aggregations

View (android.view.View)2 RecyclerView (androidx.recyclerview.widget.RecyclerView)2 DividerCell (org.telegram.ui.Cells.DividerCell)2 RecyclerListView (org.telegram.ui.Components.RecyclerListView)2 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 FrameLayout (android.widget.FrameLayout)1 DrawerActionCell (org.telegram.ui.Cells.DrawerActionCell)1 DrawerAddCell (org.telegram.ui.Cells.DrawerAddCell)1 DrawerProfileCell (org.telegram.ui.Cells.DrawerProfileCell)1 DrawerUserCell (org.telegram.ui.Cells.DrawerUserCell)1 EmptyCell (org.telegram.ui.Cells.EmptyCell)1 GraySectionCell (org.telegram.ui.Cells.GraySectionCell)1 ShadowSectionCell (org.telegram.ui.Cells.ShadowSectionCell)1 TextCell (org.telegram.ui.Cells.TextCell)1 UserCell (org.telegram.ui.Cells.UserCell)1 CombinedDrawable (org.telegram.ui.Components.CombinedDrawable)1 ContactsEmptyView (org.telegram.ui.Components.ContactsEmptyView)1