示例#1
1
 @Override
 public void setPressed(boolean pressed) {
   if (imageView.getImageReceiver().getPressed() != pressed) {
     imageView.getImageReceiver().setPressed(pressed);
     imageView.invalidate();
   }
   super.setPressed(pressed);
 }
示例#2
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;
    }