public static void deleteAllImagesFormDb() { List<MImages> imageList = new ArrayList<MImages>(); imageList = MImages.all(); for (int i = 0; i < imageList.size(); i++) { MImages.delete(imageList.get(i).id); } // for } // deleteAllImagesFormDb;
public static void updateLikesInDbLocal(String imageId, String displayId) { Logger.info(" --update local likes in db for image: " + imageId); List<MImages> images = new ArrayList<MImages>(); images = MImages.all(); // find the right image based on imageId for (int i = 0; i < images.size(); i++) { MImages image = images.get(i); if (image.idInstagram.equals(imageId)) { Logger.info( " i= " + i + " imageId: " + image.idInstagram + " author: " + image.authorName); // update likes in db (local likes +1) // TODO find a way to update the filed, not to delete and add the same image image.updateNumberOfLikesLocal(); MImages.delete(image.id); MImages.addNew( new MImages( image.idInstagram, image.url, "instagram", image.authorName, image.authorPic, image.timeCreated, image.numberOfLikesIns, image.numberOfLikesLocall)); } // if } // for // send the like update to all clients except the source sendLikeUpdateToClients(imageId, displayId); // update the hot images updateHotImages(); Logger.info("-----------------------------"); } // updateLikesInDbLocal