예제 #1
0
 @Override
 public void setPhotoChecked(int index) {
   boolean add = true;
   if (selectedAlbum != null) {
     if (index < 0 || index >= selectedAlbum.photos.size()) {
       return;
     }
     MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index);
     if (selectedPhotos.containsKey(photoEntry.imageId)) {
       selectedPhotos.remove(photoEntry.imageId);
       add = false;
     } else {
       selectedPhotos.put(photoEntry.imageId, photoEntry);
     }
   } else {
     MediaController.SearchImage photoEntry;
     ArrayList<MediaController.SearchImage> array;
     if (searchResult.isEmpty() && lastSearchString == null) {
       array = recentImages;
     } else {
       array = searchResult;
     }
     if (index < 0 || index >= array.size()) {
       return;
     }
     photoEntry = array.get(index);
     if (selectedWebPhotos.containsKey(photoEntry.id)) {
       selectedWebPhotos.remove(photoEntry.id);
       add = false;
     } else {
       selectedWebPhotos.put(photoEntry.id, photoEntry);
     }
   }
   int count = listView.getChildCount();
   for (int a = 0; a < count; a++) {
     View view = listView.getChildAt(a);
     int num = (Integer) view.getTag();
     if (num == index) {
       ((PhotoPickerPhotoCell) view).checkBox.setChecked(add, false);
       break;
     }
   }
   pickerBottomLayout.updateSelectedCount(selectedPhotos.size() + selectedWebPhotos.size(), true);
   delegate.selectedPhotosChanged();
 }
예제 #2
0
 @Override
 public void updatePhotoAtIndex(int index) {
   PhotoPickerPhotoCell cell = getCellForIndex(index);
   if (cell != null) {
     if (selectedAlbum != null) {
       cell.photoImage.setOrientation(0, true);
       MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index);
       if (photoEntry.thumbPath != null) {
         cell.photoImage.setImage(
             photoEntry.thumbPath,
             null,
             cell.getContext().getResources().getDrawable(R.drawable.nophotos));
       } else if (photoEntry.path != null) {
         cell.photoImage.setOrientation(photoEntry.orientation, true);
         if (photoEntry.isVideo) {
           cell.photoImage.setImage(
               "vthumb://" + photoEntry.imageId + ":" + photoEntry.path,
               null,
               cell.getContext().getResources().getDrawable(R.drawable.nophotos));
         } else {
           cell.photoImage.setImage(
               "thumb://" + photoEntry.imageId + ":" + photoEntry.path,
               null,
               cell.getContext().getResources().getDrawable(R.drawable.nophotos));
         }
       } else {
         cell.photoImage.setImageResource(R.drawable.nophotos);
       }
     } else {
       ArrayList<MediaController.SearchImage> array;
       if (searchResult.isEmpty() && lastSearchString == null) {
         array = recentImages;
       } else {
         array = searchResult;
       }
       MediaController.SearchImage photoEntry = array.get(index);
       if (photoEntry.thumbPath != null) {
         cell.photoImage.setImage(
             photoEntry.thumbPath,
             null,
             cell.getContext().getResources().getDrawable(R.drawable.nophotos));
       } else if (photoEntry.thumbUrl != null && photoEntry.thumbUrl.length() > 0) {
         cell.photoImage.setImage(
             photoEntry.thumbUrl,
             null,
             cell.getContext().getResources().getDrawable(R.drawable.nophotos));
       } else {
         cell.photoImage.setImageResource(R.drawable.nophotos);
       }
     }
   }
 }
예제 #3
0
    @Override
    public View getView(int i, View view, ViewGroup viewGroup) {
      int viewType = getItemViewType(i);
      if (viewType == 0) {
        PhotoPickerPhotoCell cell = (PhotoPickerPhotoCell) view;
        if (view == null) {
          view = new PhotoPickerPhotoCell(mContext);
          cell = (PhotoPickerPhotoCell) view;
          cell.checkFrame.setOnClickListener(
              new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                  int index = (Integer) ((View) v.getParent()).getTag();
                  if (selectedAlbum != null) {
                    MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(index);
                    if (selectedPhotos.containsKey(photoEntry.imageId)) {
                      selectedPhotos.remove(photoEntry.imageId);
                      photoEntry.imagePath = null;
                      photoEntry.thumbPath = null;
                      updatePhotoAtIndex(index);
                    } else {
                      selectedPhotos.put(photoEntry.imageId, photoEntry);
                    }
                    ((PhotoPickerPhotoCell) v.getParent())
                        .checkBox.setChecked(selectedPhotos.containsKey(photoEntry.imageId), true);
                  } else {
                    AndroidUtilities.hideKeyboard(getParentActivity().getCurrentFocus());
                    MediaController.SearchImage photoEntry;
                    if (searchResult.isEmpty() && lastSearchString == null) {
                      photoEntry = recentImages.get((Integer) ((View) v.getParent()).getTag());
                    } else {
                      photoEntry = searchResult.get((Integer) ((View) v.getParent()).getTag());
                    }
                    if (selectedWebPhotos.containsKey(photoEntry.id)) {
                      selectedWebPhotos.remove(photoEntry.id);
                      photoEntry.imagePath = null;
                      photoEntry.thumbPath = null;
                      updatePhotoAtIndex(index);
                    } else {
                      selectedWebPhotos.put(photoEntry.id, photoEntry);
                    }
                    ((PhotoPickerPhotoCell) v.getParent())
                        .checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), true);
                  }
                  pickerBottomLayout.updateSelectedCount(
                      selectedPhotos.size() + selectedWebPhotos.size(), true);
                  delegate.selectedPhotosChanged();
                }
              });
          cell.checkFrame.setVisibility(singlePhoto ? View.GONE : View.VISIBLE);
        }
        cell.itemWidth = itemWidth;
        BackupImageView imageView = ((PhotoPickerPhotoCell) view).photoImage;
        imageView.setTag(i);
        view.setTag(i);
        boolean showing;
        imageView.setOrientation(0, true);

        if (selectedAlbum != null) {
          MediaController.PhotoEntry photoEntry = selectedAlbum.photos.get(i);
          if (photoEntry.thumbPath != null) {
            imageView.setImage(
                photoEntry.thumbPath,
                null,
                mContext.getResources().getDrawable(R.drawable.nophotos));
          } else if (photoEntry.path != null) {
            imageView.setOrientation(photoEntry.orientation, true);
            if (photoEntry.isVideo) {
              imageView.setImage(
                  "vthumb://" + photoEntry.imageId + ":" + photoEntry.path,
                  null,
                  mContext.getResources().getDrawable(R.drawable.nophotos));
            } else {
              imageView.setImage(
                  "thumb://" + photoEntry.imageId + ":" + photoEntry.path,
                  null,
                  mContext.getResources().getDrawable(R.drawable.nophotos));
            }
          } else {
            imageView.setImageResource(R.drawable.nophotos);
          }
          cell.checkBox.setChecked(selectedPhotos.containsKey(photoEntry.imageId), false);
          showing = PhotoViewer.getInstance().isShowingImage(photoEntry.path);
        } else {
          MediaController.SearchImage photoEntry;
          if (searchResult.isEmpty() && lastSearchString == null) {
            photoEntry = recentImages.get(i);
          } else {
            photoEntry = searchResult.get(i);
          }
          if (photoEntry.thumbPath != null) {
            imageView.setImage(
                photoEntry.thumbPath,
                null,
                mContext.getResources().getDrawable(R.drawable.nophotos));
          } else if (photoEntry.thumbUrl != null && photoEntry.thumbUrl.length() > 0) {
            imageView.setImage(
                photoEntry.thumbUrl,
                null,
                mContext.getResources().getDrawable(R.drawable.nophotos));
          } else {
            imageView.setImageResource(R.drawable.nophotos);
          }
          cell.checkBox.setChecked(selectedWebPhotos.containsKey(photoEntry.id), false);
          showing = PhotoViewer.getInstance().isShowingImage(photoEntry.thumbUrl);
        }
        imageView.getImageReceiver().setVisible(!showing, true);
        cell.checkBox.setVisibility(singlePhoto || showing ? View.GONE : View.VISIBLE);
      } else if (viewType == 1) {
        if (view == null) {
          LayoutInflater li =
              (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          view = li.inflate(R.layout.media_loading_layout, viewGroup, false);
        }
        ViewGroup.LayoutParams params = view.getLayoutParams();
        params.width = itemWidth;
        params.height = itemWidth;
        view.setLayoutParams(params);
      }
      return view;
    }