Search in sources :

Example 1 with ContactsEmptyView

use of org.telegram.ui.Components.ContactsEmptyView 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)

Aggregations

ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 View (android.view.View)1 FrameLayout (android.widget.FrameLayout)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 DividerCell (org.telegram.ui.Cells.DividerCell)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 RecyclerListView (org.telegram.ui.Components.RecyclerListView)1