Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android error incomparable types: Object and int

I am importing a source code, and i've this error in two place of 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 do with these ones?

  • I've searched in Stack but I couldn't fix them. I'm a newbie at this, please help.

  • I am using Android Studio Last Version by the way!

  • I am developing the main Telegram source with no changes.

And get tag function :

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

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

like image 200
Moss Avatar asked Sep 25 '22 20:09

Moss


1 Answers

if (passwordFrameLayout.getTag() instanceOf Integer && (Integer)passwordFrameLayout.getTag() != 0) {
//         
    t = (Integer) passwordFrameLayout.getTag();
}

Should do the trick. getTag() returns an Object, you have to

  • make sure it's an Integer first
  • cast it to Integer

to compare it to another Integer

like image 173
fweigl Avatar answered Oct 17 '22 05:10

fweigl