Пример #1
0
  private void updateMicroThumbBackground(long newId) {
    for (int i = 1; i < mData.size(); i++) {
      StickerMicroThumb stickerMicroThumb = mData.get(i);
      stickerMicroThumb.isSelected = false;

      if (stickerMicroThumb.sticker != null) {
        if (stickerMicroThumb.sticker.setId == newId) {
          stickerMicroThumb.isSelected = true;
          mLinearLayoutManager.scrollToPosition(i);
        }
      }
    }

    if (newId == -1) {
      mData.get(1).isSelected = true;
      mLinearLayoutManager.scrollToPosition(0);
    }
    // без runInUI не работает на версии 4,1
    AndroidUtil.runInUI(
        new Runnable() {
          @Override
          public void run() {
            notifyDataSetChanged();
          }
        },
        1);
  }
Пример #2
0
  private void updateMicroThumbBackground(long oldId, long newId) {
    int counter = 0;

    if (newId == -1) {
      mData.get(1).isSelected = true;
      mLinearLayoutManager.scrollToPosition(0);
    } else {
      if (oldId == -1) {
        mData.get(1).isSelected = false;
      }
      for (int i = 2; i < mData.size(); i++) {
        StickerMicroThumb stickerMicroThumb = mData.get(i);
        if (stickerMicroThumb.sticker.setId == oldId) {
          stickerMicroThumb.isSelected = false;
          counter++;
        } else {
          stickerMicroThumb.isSelected = false;
        }

        if (stickerMicroThumb.sticker.setId == newId) {
          stickerMicroThumb.isSelected = true;
          if (i == 2) {
            mLinearLayoutManager.scrollToPosition(0);
          } else mLinearLayoutManager.scrollToPosition(i);
          counter++;
        }

        if (counter == 2) {
          break;
        }

        if (oldId == -1 && counter == 1) {
          break;
        }
      }
    }
    // без runInUI не работает на версии 4,1
    AndroidUtil.runInUI(
        new Runnable() {
          @Override
          public void run() {
            notifyDataSetChanged();
          }
        },
        1);
  }