gt:                 view = new StickerSetNameCell(context, false, true);
context: package org.telegram.ui.Adapters;
  
  import android.content.Context;
  import android.graphics.PorterDuff;
  import android.graphics.PorterDuffColorFilter;
  import android.text.TextUtils;
  import android.util.LongSparseArray;
  import android.util.SparseArray;
  import android.util.SparseIntArray;
  import android.util.TypedValue;
  import android.view.Gravity;
  import android.view.View;
  import android.view.ViewGroup;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.Space;
  import android.widget.TextView;
  
  import androidx.annotation.NonNull;
  import androidx.recyclerview.widget.RecyclerView;
  
  import org.telegram.messenger.AndroidUtilities;
  import org.telegram.messenger.Emoji;
  import org.telegram.messenger.LocaleController;
  import org.telegram.messenger.MediaDataController;
  import org.telegram.messenger.R;
  import org.telegram.messenger.UserConfig;
  import org.telegram.tgnet.ConnectionsManager;
  import org.telegram.tgnet.TLRPC;
  import org.telegram.ui.ActionBar.Theme;
  import org.telegram.ui.ActionBar.ThemeDescription;
  import org.telegram.ui.Cells.EmptyCell;
  import org.telegram.ui.Cells.FeaturedStickerSetInfoCell;
  import org.telegram.ui.Cells.StickerEmojiCell;
  import org.telegram.ui.Cells.StickerSetNameCell;
  import org.telegram.ui.Components.LayoutHelper;
  import org.telegram.ui.Components.RecyclerListView;
  
  import java.util.ArrayList;
  import java.util.Arrays;
  import java.util.HashMap;
  import java.util.List;
  
  public class StickersSearchAdapter extends RecyclerListView.SelectionAdapter {
  
      public static final int PAYLOAD_ANIMATED = 0;
  
      public interface Delegate {
  
          void onSearchStart();
  
          void onSearchStop();
  
          void setAdapterVisible(boolean visible);
  
          void onStickerSetAdd(TLRPC.StickerSetCovered stickerSet, boolean primary);
  
          void onStickerSetRemove(TLRPC.StickerSetCovered stickerSet);
  
          int getStickersPerRow();
  
          String[] getLastSearchKeyboardLanguage();
  
          void setLastSearchKeyboardLanguage(String[] language);
      }
  
      private final int currentAccount = UserConfig.selectedAccount;
  
      private final Context context;
      private final Delegate delegate;
      private final TLRPC.StickerSetCovered[] primaryInstallingStickerSets;
      private final LongSparseArray<TLRPC.StickerSetCovered> installingStickerSets;
      private final LongSparseArray<TLRPC.StickerSetCovered> removingStickerSets;
  
      private SparseArray<Object> rowStartPack = new SparseArray<>();
      private SparseArray<Object> cache = new SparseArray<>();
      private SparseArray<Object> cacheParent = new SparseArray<>();
      private SparseIntArray positionToRow = new SparseIntArray();
      private SparseArray<String> positionToEmoji = new SparseArray<>();
      private int totalItems;
  
      private ArrayList<TLRPC.StickerSetCovered> serverPacks = new ArrayList<>();
      private ArrayList<TLRPC.TL_messages_stickerSet> localPacks = new ArrayList<>();
      private HashMap<TLRPC.TL_messages_stickerSet, Boolean> localPacksByShortName = new HashMap<>();
      private HashMap<TLRPC.TL_messages_stickerSet, Integer> localPacksByName = new HashMap<>();
      private HashMap<ArrayList<TLRPC.Document>, String> emojiStickers = new HashMap<>();
      private ArrayList<ArrayList<TLRPC.Document>> emojiArrays = new ArrayList<>();
      private SparseArray<TLRPC.StickerSetCovered> positionsToSets = new SparseArray<>();
  
      private ImageView emptyImageView;
      private TextView emptyTextView;
  
      private int reqId;
      private int reqId2;
  
      private int emojiSearchId;
      boolean cleared;
      private String searchQuery;
      private Runnable searchRunnable = new Runnable() {
  
          private void clear() {
              if (cleared) {
                  return;
              }
              cleared = true;
              emojiStickers.clear();
              emojiArrays.clear();
              localPacks.clear();
              serverPacks.clear();
              localPacksByShortName.clear();
              localPacksByName.clear();
          }
  
          @Override
          public void run() {
              if (TextUtils.isEmpty(searchQuery)) {
                  return;
              }
              delegate.onSearchStart();
              cleared = false;
              int lastId = ++emojiSearchId;
  
              final ArrayList<TLRPC.Document> emojiStickersArray = new ArrayList<>(0);
              final LongSparseArray<TLRPC.Document> emojiStickersMap = new LongSparseArray<>(0);
              HashMap<String, ArrayList<TLRPC.Document>> allStickers = MediaDataController.getInstance(currentAccount).getAllStickers();
              if (searchQuery.length() <= 14) {
                  CharSequence emoji = searchQuery;
                  int length = emoji.length();
                  for (int a = 0; a < length; a++) {
                      if (a < length - 1 && (emoji.charAt(a) == 0xD83C && emoji.charAt(a + 1) >= 0xDFFB && emoji.charAt(a + 1) <= 0xDFFF || emoji.charAt(a) == 0x200D && (emoji.charAt(a + 1) == 0x2640 || emoji.charAt(a + 1) == 0x2642))) {
                          emoji = TextUtils.concat(emoji.subSequence(0, a), emoji.subSequence(a + 2, emoji.length()));
                          length -= 2;
                          a--;
                      } else if (emoji.charAt(a) == 0xfe0f) {
                          emoji = TextUtils.concat(emoji.subSequence(0, a), emoji.subSequence(a + 1, emoji.length()));
                          length--;
                          a--;
                      }
                  }
                  ArrayList<TLRPC.Document> newStickers = allStickers != null ? allStickers.get(emoji.toString()) : null;
                  if (newStickers != null && !newStickers.isEmpty()) {
                      clear();
                      emojiStickersArray.addAll(newStickers);
                      for (int a = 0, size = newStickers.size(); a < size; a++) {
                          TLRPC.Document document = newStickers.get(a);
                          emojiStickersMap.put(document.id, document);
                      }
                      emojiStickers.put(emojiStickersArray, searchQuery);
                      emojiArrays.add(emojiStickersArray);
                  }
              }
              if (allStickers != null && !allStickers.isEmpty() && searchQuery.length() > 1) {
                  String[] newLanguage = AndroidUtilities.getCurrentKeyboardLanguage();
                  if (!Arrays.equals(delegate.getLastSearchKeyboardLanguage(), newLanguage)) {
                      MediaDataController.getInstance(currentAccount).fetchNewEmojiKeywords(newLanguage);
                  }
                  delegate.setLastSearchKeyboardLanguage(newLanguage);
                  MediaDataController.getInstance(currentAccount).getEmojiSuggestions(delegate.getLastSearchKeyboardLanguage(), searchQuery, false, (param, alias) -> {
                      if (lastId != emojiSearchId) {
                          return;
                      }
                      boolean added = false;
                      for (int a = 0, size = param.size(); a < size; a++) {
                          String emoji = param.get(a).emoji;
                          ArrayList<TLRPC.Document> newStickers = allStickers != null ? allStickers.get(emoji) : null;
                          if (newStickers != null && !newStickers.isEmpty()) {
                              clear();
                              if (!emojiStickers.containsKey(newStickers)) {
                                  emojiStickers.put(newStickers, emoji);
                                  emojiArrays.add(newStickers);
                                  added = true;
                              }
                          }
                      }
                      if (added) {
                          notifyDataSetChanged();
                      }
                  });
              }
              ArrayList<TLRPC.TL_messages_stickerSet> local = MediaDataController.getInstance(currentAccount).getStickerSets(MediaDataController.TYPE_IMAGE);
              int index;
              for (int a = 0, size = local.size(); a < size; a++) {
                  TLRPC.TL_messages_stickerSet set = local.get(a);
                  if ((index = AndroidUtilities.indexOfIgnoreCase(set.set.title, searchQuery)) >= 0) {
                      if (index == 0 || set.set.title.charAt(index - 1) == ' ') {
                          clear();
                          localPacks.add(set);
                          localPacksByName.put(set, index);
                      }
                  } else if (set.set.short_name != null && (index = AndroidUtilities.indexOfIgnoreCase(set.set.short_name, searchQuery)) >= 0) {
                      if (index == 0 || set.set.short_name.charAt(index - 1) == ' ') {
                          clear();
                          localPacks.add(set);
                          localPacksByShortName.put(set, true);
                      }
                  }
              }
              local = MediaDataController.getInstance(currentAccount).getStickerSets(MediaDataController.TYPE_FEATURED);
              for (int a = 0, size = local.size(); a < size; a++) {
                  TLRPC.TL_messages_stickerSet set = local.get(a);
                  if ((index = AndroidUtilities.indexOfIgnoreCase(set.set.title, searchQuery)) >= 0) {
                      if (index == 0 || set.set.title.charAt(index - 1) == ' ') {
                          clear();
                          localPacks.add(set);
                          localPacksByName.put(set, index);
                      }
                  } else if (set.set.short_name != null && (index = AndroidUtilities.indexOfIgnoreCase(set.set.short_name, searchQuery)) >= 0) {
                      if (index == 0 || set.set.short_name.charAt(index - 1) == ' ') {
                          clear();
                          localPacks.add(set);
                          localPacksByShortName.put(set, true);
                      }
                  }
              }
              if ((!localPacks.isEmpty() || !emojiStickers.isEmpty())) {
                  delegate.setAdapterVisible(true);
              }
              final TLRPC.TL_messages_searchStickerSets req = new TLRPC.TL_messages_searchStickerSets();
              req.q = searchQuery;
              reqId = ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
                  if (response instanceof TLRPC.TL_messages_foundStickerSets) {
                      AndroidUtilities.runOnUIThread(() -> {
                          if (req.q.equals(searchQuery)) {
                              clear();
                              delegate.onSearchStop();
                              reqId = 0;
                              delegate.setAdapterVisible(true);
                              TLRPC.TL_messages_foundStickerSets res = (TLRPC.TL_messages_foundStickerSets) response;
                              serverPacks.addAll(res.sets);
                              notifyDataSetChanged();
                          }
                      });
                  }
              });
              if (Emoji.isValidEmoji(searchQuery)) {
                  final TLRPC.TL_messages_getStickers req2 = new TLRPC.TL_messages_getStickers();
                  req2.emoticon = searchQuery;
                  req2.hash = 0;
                  reqId2 = ConnectionsManager.getInstance(currentAccount).sendRequest(req2, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
                      if (req2.emoticon.equals(searchQuery)) {
                          reqId2 = 0;
                          if (!(response instanceof TLRPC.TL_messages_stickers)) {
                              return;
                          }
                          TLRPC.TL_messages_stickers res = (TLRPC.TL_messages_stickers) response;
                          int oldCount = emojiStickersArray.size();
                          for (int a = 0, size = res.stickers.size(); a < size; a++) {
                              TLRPC.Document document = res.stickers.get(a);
                              if (emojiStickersMap.indexOfKey(document.id) >= 0) {
                                  continue;
                              }
                              emojiStickersArray.add(document);
                          }
                          int newCount = emojiStickersArray.size();
                          if (oldCount != newCount) {
                              emojiStickers.put(emojiStickersArray, searchQuery);
                              if (oldCount == 0) {
                                  emojiArrays.add(emojiStickersArray);
                              }
                              notifyDataSetChanged();
                          }
                      }
                  }));
              }
              notifyDataSetChanged();
          }
      };
  
      public StickersSearchAdapter(Context context, Delegate delegate, TLRPC.StickerSetCovered[] primaryInstallingStickerSets, LongSparseArray<TLRPC.StickerSetCovered> installingStickerSets, LongSparseArray<TLRPC.StickerSetCovered> removingStickerSets) {
          this.context = context;
          this.delegate = delegate;
          this.primaryInstallingStickerSets = primaryInstallingStickerSets;
          this.installingStickerSets = installingStickerSets;
          this.removingStickerSets = removingStickerSets;
      }
  
      @Override
      public boolean isEnabled(RecyclerView.ViewHolder holder) {
          return false;
      }
  
      @Override
      public int getItemCount() {
          return Math.max(1, totalItems + 1);
      }
  
      public Object getItem(int i) {
          return cache.get(i);
      }
  
      public void search(String text) {
          if (reqId != 0) {
              ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId, true);
              reqId = 0;
          }
          if (reqId2 != 0) {
              ConnectionsManager.getInstance(currentAccount).cancelRequest(reqId2, true);
              reqId2 = 0;
          }
          if (TextUtils.isEmpty(text)) {
              searchQuery = null;
              localPacks.clear();
              emojiStickers.clear();
              serverPacks.clear();
              delegate.setAdapterVisible(false);
              notifyDataSetChanged();
          } else {
              searchQuery = text.toLowerCase();
          }
          AndroidUtilities.cancelRunOnUIThread(searchRunnable);
          AndroidUtilities.runOnUIThread(searchRunnable, 300);
      }
  
      @Override
      public int getItemViewType(int position) {
          if (position == 0 && totalItems == 0) {
              return 5;
          } else if (position == getItemCount() - 1) {
              return 4;
          }
          Object object = cache.get(position);
          if (object != null) {
              if (object instanceof TLRPC.Document) {
                  return 0;
              } else if (object instanceof TLRPC.StickerSetCovered) {
                  return 3;
              } else {
                  return 2;
              }
          }
          return 1;
      }
  
      @Override
      public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
          View view = null;
          switch (viewType) {
              case 0:
                  StickerEmojiCell stickerEmojiCell = new StickerEmojiCell(context, false) {
                      public void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
                          super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(82), MeasureSpec.EXACTLY));
                      }
                  };
                  view = stickerEmojiCell;
                  stickerEmojiCell.getImageView().setLayerNum(3);
                  break;
              case 1:
                  view = new EmptyCell(context);
                  break;
              case 2:
  