Invalid error types in Android: Object and int

I import the source code, and I have this error in two places in the code:

Error: (86, 60) error: incomparable types: Object and int

if (selectedPhotos.containsKey(photoEntry.imageId)) {
  selectedPhotos.remove(photoEntry.imageId);
  v.setChecked(false, true);
  photoEntry.imagePath = null;
  photoEntry.thumbPath = null;
  v.setPhotoEntry(photoEntry, v.getTag() == MediaController.allPhotosAlbumEntry.photos.size() - 1);
                                   // ^-here-^
} else {
  selectedPhotos.put(photoEntry.imageId, photoEntry);
  v.setChecked(true, true);

And this one:

if (passwordFrameLayout.getTag() != 0) {
//                               ^Here
  t = (Integer) passwordFrameLayout.getTag();
}

What changes should I make with these?

  • I searched on Stack, but I could not fix them. I am new to this, please help.

  • I am using the latest version of Android Studio.

  • I am developing the main source of telegrams unchanged.

And get the tag function:

@ViewDebug.ExportedProperty
  public Object getTag() {
    return mTag;
  }

located in android-23 / android / view / View.java

+4
source share
1 answer
if (passwordFrameLayout.getTag() instanceOf Integer && (Integer)passwordFrameLayout.getTag() != 0) {
//         
    t = (Integer) passwordFrameLayout.getTag();
}

Gotta do the trick. getTag()returns an object you must

  • make sure it integer first
  • pass it to Integer

Integer

+3

Source: https://habr.com/ru/post/1621458/


All Articles