public ArrayList<Path> getSelected(boolean expandSet) {
   ArrayList<Path> selected = new ArrayList<Path>();
   if (mIsAlbumSet) {
     if (mInverseSelection) {
       int total = getTotalCount();
       for (int i = 0; i < total; i++) {
         MediaSet set = mSourceMediaSet.getSubMediaSet(i);
         Path id = set.getPath();
         if (!mClickedSet.contains(id)) {
           if (expandSet) {
             expandMediaSet(selected, set);
           } else {
             selected.add(id);
           }
         }
       }
     } else {
       for (Path id : mClickedSet) {
         if (expandSet) {
           expandMediaSet(selected, mDataManager.getMediaSet(id));
         } else {
           selected.add(id);
         }
       }
     }
   } else {
     if (mInverseSelection) {
       int total = getTotalCount();
       int index = 0;
       while (index < total) {
         int count = Math.min(total - index, MediaSet.MEDIAITEM_BATCH_FETCH_COUNT);
         ArrayList<MediaItem> list = mSourceMediaSet.getMediaItem(index, count);
         for (MediaItem item : list) {
           Path id = item.getPath();
           if (!mClickedSet.contains(id)) selected.add(id);
         }
         index += count;
       }
     } else {
       for (Path id : mClickedSet) {
         selected.add(id);
       }
     }
   }
   return selected;
 }
  private static void expandMediaSet(ArrayList<Path> items, MediaSet set) {
    int subCount = set.getSubMediaSetCount();
    for (int i = 0; i < subCount; i++) {
      expandMediaSet(items, set.getSubMediaSet(i));
    }
    int total = set.getMediaItemCount();
    int batch = 50;
    int index = 0;

    while (index < total) {
      int count = index + batch < total ? batch : total - index;
      ArrayList<MediaItem> list = set.getMediaItem(index, count);
      for (MediaItem item : list) {
        items.add(item.getPath());
      }
      index += batch;
    }
  }