void bind(FolderInfo info) {
    mInfo = info;
    ArrayList<ShortcutInfo> children = info.contents;
    ArrayList<ShortcutInfo> overflow = new ArrayList<ShortcutInfo>();
    setupContentForNumItems(children.size());
    placeInReadingOrder(children);
    int count = 0;
    for (int i = 0; i < children.size(); i++) {
      ShortcutInfo child = (ShortcutInfo) children.get(i);
      if (createAndAddShortcut(child) == null) {
        overflow.add(child);
      } else {
        count++;
      }
    }

    // We rearrange the items in case there are any empty gaps
    setupContentForNumItems(count);

    // If our folder has too many items we prune them from the list. This is an issue
    // when upgrading from the old Folders implementation which could contain an unlimited
    // number of items.
    for (ShortcutInfo item : overflow) {
      mInfo.remove(item);
      LauncherModel.deleteItemFromDatabase(mLauncher, item);
    }

    mItemsInvalidated = true;
    updateTextViewFocus();
    mInfo.addListener(this);

    if (!sDefaultFolderName.contentEquals(mInfo.title)) {
      mFolderName.setText(mInfo.title);
    } else {
      mFolderName.setText("");
    }
    updateItemLocationsInDatabase();

    // In case any children didn't come across during loading, clean up the folder accordingly
    mFolderIcon.post(
        new Runnable() {
          public void run() {
            if (getItemCount() <= 1) {
              replaceFolderWithFinalItem();
            }
          }
        });
  }
예제 #2
0
  void bind(FolderInfo info) {
    mInfo = info;
    ArrayList<ShortcutInfo> children = info.contents;
    ArrayList<ShortcutInfo> overflow = new ArrayList<ShortcutInfo>(); // 超出数量的item
    setupContentForNumItems(children.size());
    placeInReadingOrder(children);
    int count = 0;
    for (int i = 0; i < children.size(); i++) {
      ShortcutInfo child = (ShortcutInfo) children.get(i);
      if (!createAndAddShortcut(child)) {
        overflow.add(child);
      } else {
        count++;
      }
    }

    // 重新排序以防止有空的间隔。应该是防止万一数据有不对。
    setupContentForNumItems(count);

    // If our folder has too many items we prune them from the list. This is
    // an issue
    // when upgrading from the old Folders implementation which could
    // contain an unlimited
    // number of items.
    // 如果文件夹里面有太多项目的话,我们把他们从list里面删掉。
    // 因为从以前版本的数据库升级的时候有可能会出现许许多多的item(以前没有限制?)
    for (ShortcutInfo item : overflow) {
      mInfo.remove(item);
      LauncherModel.deleteItemFromDatabase(mLauncher, item);
    }

    mItemsInvalidated = true;
    updateTextViewFocus();
    mInfo.addListener(this);

    if (!sDefaultFolderName.contentEquals(mInfo.title)) {
      mFolderName.setText(mInfo.title);
    } else {
      mFolderName.setText("");
    }
    updateItemLocationsInDatabase(); // 更新数据库里面的位置,万一以前里面的有错误(也太小心了……)
  }
예제 #3
0
  void bind(FolderInfo info) {
    mInfo = info;
    ArrayList<ShortcutInfo> children = info.contents;
    ArrayList<ShortcutInfo> overflow = new ArrayList<ShortcutInfo>();
    setupContentForNumItems(children.size());
    int count = 0;
    for (int i = 0; i < children.size(); i++) {
      ShortcutInfo child = (ShortcutInfo) children.get(i);
      if (!createAndAddShortcut(child)) {
        overflow.add(child);
      } else {
        count++;
      }
    }

    // We rearrange the items in case there are any empty gaps
    setupContentForNumItems(count);

    // If our folder has too many items we prune them from the list. This is an issue
    // when upgrading from the old Folders implementation which could contain an unlimited
    // number of items.
    for (ShortcutInfo item : overflow) {
      mInfo.remove(item);
      LauncherModel.deleteItemFromDatabase(mLauncher, item);
    }

    mItemsInvalidated = true;
    updateStyledTextFooFocus();
    mInfo.addListener(this);

    if (!sDefaultFolderName.contentEquals(mInfo.title)) {
      mFolderName.setText(mInfo.title);
    } else {
      mFolderName.setText("");
    }
  }