导航菜单

页面标题

页面副标题

Plus 12 v10.13.1.1 - GiftInfoAdapter.java 源代码

正在查看: Plus 12 v10.13.1.1 应用的 GiftInfoAdapter.java JAVA 源代码文件

本页面展示 JAVA 反编译生成的源代码文件,支持语法高亮显示。 仅供安全研究与技术分析使用,严禁用于任何非法用途。请遵守相关法律法规。


package org.telegram.ui.Components.Premium.boosts.adapters;

import android.content.Context;
import android.os.Bundle;
import android.view.View;
import android.view.ViewGroup;
import android.widget.FrameLayout;
import androidx.recyclerview.widget.RecyclerView;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesStorage;
import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.Utilities;
import org.telegram.tgnet.TLObject;
import org.telegram.tgnet.TLRPC;
import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.Components.Premium.boosts.BoostDialogs;
import org.telegram.ui.Components.Premium.boosts.BoostRepository;
import org.telegram.ui.Components.Premium.boosts.cells.ActionBtnCell;
import org.telegram.ui.Components.Premium.boosts.cells.HeaderCell;
import org.telegram.ui.Components.Premium.boosts.cells.LinkCell;
import org.telegram.ui.Components.Premium.boosts.cells.TableCell;
import org.telegram.ui.Components.Premium.boosts.cells.TextInfoCell;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.DialogsActivity;
import org.telegram.ui.TopicsFragment;

public abstract class GiftInfoAdapter extends RecyclerListView.SelectionAdapter {
    public BaseFragment baseFragment;
    public FrameLayout container;
    public TLRPC.TL_payments_checkedGiftCode giftCode;
    public boolean isUnused;
    public final Theme.ResourcesProvider resourcesProvider;
    public String slug;

    public abstract void afterCodeApplied();

    public abstract void dismiss();

    public int getItemCount() {
        return 5;
    }

    public int getItemViewType(int position) {
        if (position == 0) {
            return 0;
        }
        int i = 1;
        if (position != 1) {
            i = 2;
            if (position != 2) {
                i = 3;
                if (position != 3) {
                    i = 4;
                    if (position != 4) {
                        return 5;
                    }
                }
            }
        }
        return i;
    }

    public boolean isEnabled(RecyclerView.ViewHolder holder) {
        return false;
    }

    public abstract void onHiddenLinkClicked();

    public abstract void onObjectClicked(TLObject object);

    public GiftInfoAdapter(Theme.ResourcesProvider resourcesProvider) {
        this.resourcesProvider = resourcesProvider;
    }

    public void init(BaseFragment baseFragment, TLRPC.TL_payments_checkedGiftCode giftCode, String slug, FrameLayout container) {
        this.isUnused = giftCode.used_date == 0;
        this.baseFragment = baseFragment;
        this.giftCode = giftCode;
        this.slug = slug;
        this.container = container;
    }

    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View linkCell;
        Context context = parent.getContext();
        if (viewType == 1) {
            linkCell = new LinkCell(context, this.baseFragment, this.resourcesProvider);
        } else if (viewType == 2) {
            linkCell = new TableCell(context, this.resourcesProvider);
        } else if (viewType == 3) {
            linkCell = new TextInfoCell(context, this.resourcesProvider);
        } else if (viewType == 4) {
            linkCell = new ActionBtnCell(context, this.resourcesProvider);
            linkCell.setPadding(0, 0, 0, AndroidUtilities.dp(14.0f));
        } else if (viewType != 5) {
            linkCell = new HeaderCell(context, this.resourcesProvider);
        } else {
            linkCell = new View(context);
        }
        linkCell.setLayoutParams(new RecyclerView.LayoutParams(-1, -2));
        return new RecyclerListView.Holder(linkCell);
    }

    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        String string;
        int itemViewType = holder.getItemViewType();
        if (itemViewType == 0) {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (this.isUnused) {
                headerCell.setGiftLinkText();
            } else {
                headerCell.setUsedGiftLinkText();
            }
            TLRPC.TL_payments_checkedGiftCode tL_payments_checkedGiftCode = this.giftCode;
            if (tL_payments_checkedGiftCode.boost != null) {
                headerCell.setGiftLinkToUserText(tL_payments_checkedGiftCode.to_id, new Utilities.Callback() {
                    public final void run(Object obj) {
                        GiftInfoAdapter.this.onObjectClicked((TLObject) obj);
                    }
                });
            }
            if (this.giftCode.to_id == -1) {
                headerCell.setUnclaimedText();
                return;
            }
            return;
        }
        if (itemViewType == 1) {
            LinkCell linkCell = (LinkCell) holder.itemView;
            linkCell.setSlug(this.slug);
            if (this.giftCode.boost != null && this.slug == null) {
                linkCell.hideSlug(new Runnable() {
                    @Override
                    public final void run() {
                        GiftInfoAdapter.this.onHiddenLinkClicked();
                    }
                });
            }
            String str = this.slug;
            if ((str == null || str.isEmpty()) && this.giftCode.to_id == -1) {
                linkCell.hideSlug(new Runnable() {
                    @Override
                    public final void run() {
                        GiftInfoAdapter.this.onHiddenLinkClicked();
                    }
                });
                return;
            }
            return;
        }
        if (itemViewType == 2) {
            ((TableCell) holder.itemView).setData(this.giftCode, new Utilities.Callback() {
                public final void run(Object obj) {
                    GiftInfoAdapter.this.onObjectClicked((TLObject) obj);
                }
            });
            return;
        }
        if (itemViewType != 3) {
            if (itemViewType != 4) {
                return;
            }
            final ActionBtnCell actionBtnCell = (ActionBtnCell) holder.itemView;
            actionBtnCell.setOkStyle(this.isUnused);
            actionBtnCell.setOnClickListener(new View.OnClickListener() {
                @Override
                public final void onClick(View view) {
                    GiftInfoAdapter.this.lambda$onBindViewHolder$2(actionBtnCell, view);
                }
            });
            TLRPC.TL_payments_checkedGiftCode tL_payments_checkedGiftCode2 = this.giftCode;
            if (tL_payments_checkedGiftCode2.boost != null || tL_payments_checkedGiftCode2.flags == -1) {
                actionBtnCell.setCloseStyle();
                actionBtnCell.setOnClickListener(new View.OnClickListener() {
                    @Override
                    public final void onClick(View view) {
                        GiftInfoAdapter.this.lambda$onBindViewHolder$3(view);
                    }
                });
                return;
            }
            return;
        }
        TextInfoCell textInfoCell = (TextInfoCell) holder.itemView;
        textInfoCell.setTextGravity(17);
        textInfoCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
        textInfoCell.setTopPadding(14);
        textInfoCell.setBottomPadding(15);
        TLRPC.TL_payments_checkedGiftCode tL_payments_checkedGiftCode3 = this.giftCode;
        if (tL_payments_checkedGiftCode3.boost != null) {
            String str2 = this.slug;
            if (str2 == null || str2.isEmpty()) {
                textInfoCell.setText(LocaleController.getString("BoostingLinkNotActivated", R.string.BoostingLinkNotActivated));
                return;
            } else {
                textInfoCell.setFixedSize(14);
                textInfoCell.setText(null);
                return;
            }
        }
        if (this.isUnused) {
            if (tL_payments_checkedGiftCode3.to_id == -1) {
                string = LocaleController.getString("BoostingSendLinkToAnyone", R.string.BoostingSendLinkToAnyone);
            } else {
                string = LocaleController.getString("BoostingSendLinkToFriends", R.string.BoostingSendLinkToFriends);
            }
            textInfoCell.setText(AndroidUtilities.replaceSingleTag(string, Theme.key_chat_messageLinkIn, 0, new GiftInfoAdapter$$ExternalSyntheticLambda3(this), this.resourcesProvider));
            return;
        }
        Date date = new Date(this.giftCode.used_date * 1000);
        textInfoCell.setText(LocaleController.formatString("BoostingUsedLinkDate", R.string.BoostingUsedLinkDate, new Object[]{LocaleController.formatString("formatDateAtTime", R.string.formatDateAtTime, new Object[]{LocaleController.getInstance().formatterYear.format(date), LocaleController.getInstance().formatterDay.format(date)})}));
    }

    public void lambda$onBindViewHolder$2(final ActionBtnCell actionBtnCell, View view) {
        if (this.isUnused) {
            if (actionBtnCell.isLoading()) {
                return;
            }
            actionBtnCell.updateLoading(true);
            BoostRepository.applyGiftCode(this.slug, new Utilities.Callback() {
                public final void run(Object obj) {
                    GiftInfoAdapter.this.lambda$onBindViewHolder$0(actionBtnCell, (Void) obj);
                }
            }, new Utilities.Callback() {
                public final void run(Object obj) {
                    GiftInfoAdapter.this.lambda$onBindViewHolder$1(actionBtnCell, (TLRPC.TL_error) obj);
                }
            });
            return;
        }
        dismiss();
    }

    public void lambda$onBindViewHolder$0(ActionBtnCell actionBtnCell, Void r2) {
        actionBtnCell.updateLoading(false);
        afterCodeApplied();
        dismiss();
    }

    public void lambda$onBindViewHolder$1(ActionBtnCell actionBtnCell, TLRPC.TL_error tL_error) {
        actionBtnCell.updateLoading(false);
        BoostDialogs.processApplyGiftCodeError(tL_error, this.container, this.resourcesProvider, new GiftInfoAdapter$$ExternalSyntheticLambda3(this));
    }

    public void lambda$onBindViewHolder$3(View view) {
        dismiss();
    }

    public final void share() {
        final String str = "https://t.me/giftcode/" + this.slug;
        Bundle bundle = new Bundle();
        bundle.putBoolean("onlySelect", true);
        bundle.putInt("dialogsType", 3);
        DialogsActivity dialogsActivity = new DialogsActivity(bundle);
        dialogsActivity.setDelegate(new DialogsActivity.DialogsActivityDelegate() {
            @Override
            public final boolean didSelectDialogs(DialogsActivity dialogsActivity2, ArrayList arrayList, CharSequence charSequence, boolean z, TopicsFragment topicsFragment) {
                boolean lambda$share$4;
                lambda$share$4 = GiftInfoAdapter.this.lambda$share$4(str, dialogsActivity2, arrayList, charSequence, z, topicsFragment);
                return lambda$share$4;
            }

            @Override
            public boolean didSelectDialogs(DialogsActivity dialogsActivity2, ArrayList arrayList, CharSequence charSequence, boolean z, TopicsFragment topicsFragment, boolean z2) {
                return DialogsActivity.DialogsActivityDelegate.CC.$default$didSelectDialogs(this, dialogsActivity2, arrayList, charSequence, z, topicsFragment, z2);
            }
        });
        this.baseFragment.presentFragment(dialogsActivity);
        dismiss();
    }

    public boolean lambda$share$4(String str, DialogsActivity dialogsActivity, ArrayList arrayList, CharSequence charSequence, boolean z, TopicsFragment topicsFragment) {
        long j = 0;
        for (int i = 0; i < arrayList.size(); i++) {
            j = ((MessagesStorage.TopicKey) arrayList.get(i)).dialogId;
            this.baseFragment.getSendMessagesHelper().sendMessage(SendMessagesHelper.SendMessageParams.of(str, j, (MessageObject) null, (MessageObject) null, (TLRPC.WebPage) null, true, (ArrayList) null, (TLRPC.ReplyMarkup) null, (HashMap) null, true, 0, (MessageObject.SendAnimationData) null, false));
        }
        dialogsActivity.finishFragment();
        BoostDialogs.showGiftLinkForwardedBulletin(j);
        return true;
    }
}