Incompatible types required: Object found: BarcodeGraphic

297 Views Asked by At

I am getting the above mentioned error when I try to loop over all the graphics displayed on my camera preview in Android on the following line.

for(BarcodeGraphic graphic : mGraphicOverlay.getGraphics){
//blah blah blah
} 

The BarcodeGraphic is a class that represents a graphic on a preview display and is defined as such

class BarcodeGraphic extends TrackedGraphic<Barcode>{
//all the code regarding my graphic
}

and the getGraphics is a function in the GraphicOverlay class which the above class extends to and is defined as follows.

public class GraphicOverlay<T extends GraphicOverlay.Graphic> extends View{
private List<BarcodeGraphic> mGraphics = new ArrayList<>();
public List<BarcodeGraphic> getGraphics(){
synchronized (mLock){
return mGraphics;
}
} 

Update: However if I make a List within the calling class right above the offender code the error goes away.

List<BarcodeGraphic> bgraphic = new ArrayList<>();
for (BarcodeGraphic graphic : bgraphic){
//this works fine
}

But the getGraphics function basically returns a List just like this one. I am really confused now.

I believe I have included all the relevant pieces of the code but my code is based on the Google sample in case you need more clarification. Can someone point why I am getting the above error?

0

There are 0 best solutions below