I am getting below ANR while trying to update image view pager. Does anyone have an idea ? below is my code. I suspect when I do the setcurrentItem getting this ANR : Input dispatching timed out (Waiting to send non-key event because the touched window has not finished processing certain input events that were delivered to it over 500.0ms ago. Wait queue length: 5.
private void setRelavantColourPic(ValueList valueList){
if(valueList.getPictureId() != 0 && productImages != null && productImages.size() > 0){
i = 0;
for (ProductPictureList productPictureList : productImages ){
int pictureId = Integer.parseInt(productPictureList.getPictureId());
i ++;
if(pictureId == valueList.getPictureId()){
foundIndex = i-1;
}
}
mDelayHandler.postDelayed(
mRunnable = new Runnable() {
@Override
public void run() {
mProductImageViewPager.setCurrentItem(foundIndex);
}
}, 1);
// mDelayHandler.post(mRunnable);
}
}
I think it is recursing and blocking the main thread. Try removing the below statement,
mDelayHandler.post(mRunnable);
it will work.