Search in sources :

Example 1 with DialogsEmptyCell

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);
}
Also used : ArchiveHintCell(org.telegram.ui.Cells.ArchiveHintCell) Rect(android.graphics.Rect) FrameLayout(android.widget.FrameLayout) AndroidUtilities(org.telegram.messenger.AndroidUtilities) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) TextCell(org.telegram.ui.Cells.TextCell) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) DialogsActivity(org.telegram.ui.DialogsActivity) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) PorterDuff(android.graphics.PorterDuff) ConnectionsManager(org.telegram.tgnet.ConnectionsManager) ViewGroup(android.view.ViewGroup) UserConfig(org.telegram.messenger.UserConfig) TextView(android.widget.TextView) PorterDuffColorFilter(android.graphics.PorterDuffColorFilter) Context(android.content.Context) Theme(org.telegram.ui.ActionBar.Theme) ViewPager(androidx.viewpager.widget.ViewPager) SystemClock(android.os.SystemClock) LocaleController(org.telegram.messenger.LocaleController) HeaderCell(org.telegram.ui.Cells.HeaderCell) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) ArrayList(java.util.ArrayList) HashSet(java.util.HashSet) TLRPC(org.telegram.tgnet.TLRPC) ActionBar(org.telegram.ui.ActionBar.ActionBar) DialogMeUrlCell(org.telegram.ui.Cells.DialogMeUrlCell) TLObject(org.telegram.tgnet.TLObject) SharedConfig(org.telegram.messenger.SharedConfig) DialogsEmptyCell(org.telegram.ui.Cells.DialogsEmptyCell) BuildVars(org.telegram.messenger.BuildVars) Build(android.os.Build) DialogCell(org.telegram.ui.Cells.DialogCell) DialogObject(org.telegram.messenger.DialogObject) UserCell(org.telegram.ui.Cells.UserCell) R(org.telegram.messenger.R) LayoutHelper(org.telegram.ui.Components.LayoutHelper) FileLog(org.telegram.messenger.FileLog) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) MessagesController(org.telegram.messenger.MessagesController) Gravity(android.view.Gravity) SharedPreferences(android.content.SharedPreferences) TypedValue(android.util.TypedValue) ContactsController(org.telegram.messenger.ContactsController) Collections(java.util.Collections) RecyclerListView(org.telegram.ui.Components.RecyclerListView) HeaderCell(org.telegram.ui.Cells.HeaderCell) TextCell(org.telegram.ui.Cells.TextCell) DialogCell(org.telegram.ui.Cells.DialogCell) DialogsEmptyCell(org.telegram.ui.Cells.DialogsEmptyCell) TextView(android.widget.TextView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) UserCell(org.telegram.ui.Cells.UserCell) Rect(android.graphics.Rect) ShadowSectionCell(org.telegram.ui.Cells.ShadowSectionCell) SharedPreferences(android.content.SharedPreferences) ColorDrawable(android.graphics.drawable.ColorDrawable) Drawable(android.graphics.drawable.Drawable) PullForegroundDrawable(org.telegram.ui.Components.PullForegroundDrawable) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) TextInfoPrivacyCell(org.telegram.ui.Cells.TextInfoPrivacyCell) View(android.view.View) RecyclerView(androidx.recyclerview.widget.RecyclerView) TextView(android.widget.TextView) FlickerLoadingView(org.telegram.ui.Components.FlickerLoadingView) RecyclerListView(org.telegram.ui.Components.RecyclerListView) DialogMeUrlCell(org.telegram.ui.Cells.DialogMeUrlCell) ColorDrawable(android.graphics.drawable.ColorDrawable) FrameLayout(android.widget.FrameLayout) CombinedDrawable(org.telegram.ui.Components.CombinedDrawable) ArchiveHintCell(org.telegram.ui.Cells.ArchiveHintCell) RecyclerView(androidx.recyclerview.widget.RecyclerView)

Aggregations

Context (android.content.Context)1 SharedPreferences (android.content.SharedPreferences)1 PorterDuff (android.graphics.PorterDuff)1 PorterDuffColorFilter (android.graphics.PorterDuffColorFilter)1 Rect (android.graphics.Rect)1 ColorDrawable (android.graphics.drawable.ColorDrawable)1 Drawable (android.graphics.drawable.Drawable)1 Build (android.os.Build)1 SystemClock (android.os.SystemClock)1 TypedValue (android.util.TypedValue)1 Gravity (android.view.Gravity)1 View (android.view.View)1 ViewGroup (android.view.ViewGroup)1 FrameLayout (android.widget.FrameLayout)1 TextView (android.widget.TextView)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 ViewPager (androidx.viewpager.widget.ViewPager)1 ArrayList (java.util.ArrayList)1 Collections (java.util.Collections)1 HashSet (java.util.HashSet)1