ECn Categories > Browser Embedded Incorrectly (BEI) > Map File Embedded Incorrectly (MFEI)
A blank image is displayed because there is no connection to internet. The app does not warn that there is no connection to internet or do it in a bad way.
Amount of Issues | App List |
---|---|
10 | (A10) OsmAnd, (A15) WordPress, (A18) FBReader, (A22) Hubble Gallery, (A26) Opengur, (A30) Earth Viewer, (A36) Stepik, (A39) Habitica, (A50) Kickstarter |
Examples
Opengur
The following code snippets show the classes and files that are involved in the generation of the previuos issue.
To start reviewing this example, we can see in the following snippet the imageview that belong to the layout used in the gallery grid.
src/main/res/layout/gallery_item.xml
<ImageView
10. android:id="@+id/image"
android:layout_width="match_parent"
android:layout_height="@dimen/gallery_column_height"
android:scaleType="centerCrop"
android:transitionName="@string/gallery_item_transition"
tools:src="@drawable/ic_launcher" />
To continue, we have to see the adapter used to fill the gridview.
src/main/java/com/kenny/openimgur/ui/adapters/GalleryAdapter.java
31. public class GalleryAdapter extends BaseRecyclerAdapter<ImgurBaseObject> {
First, the “onBindViewHolder” has at the line 124 the actual binding from the image to the imageView, and calls the “displayImage” method with the image url and the view holder from the line 106.
src/main/java/com/kenny/openimgur/ui/adapters/GalleryAdapter.java
@Override
public void onBindViewHolder(BaseViewHolder holder, int position) {
106. GalleryHolder galleryHolder = (GalleryHolder) holder;
ImgurBaseObject obj = getItem(position);
// Get the appropriate photo to display
if (obj.isNSFW() && !mAllowNSFWThumb) {
galleryHolder.image.setImageResource(R.drawable.ic_nsfw);
galleryHolder.itemType.setVisibility(View.GONE);
} else if (obj instanceof ImgurPhoto) {
ImgurPhoto photoObject = ((ImgurPhoto) obj);
String photoUrl;
// Check if the link is a thumbed version of a large gif
if (photoObject.hasVideoLink() && photoObject.isLinkAThumbnail() && ImgurPhoto.IMAGE_TYPE_GIF.equals(photoObject.getType())) {
photoUrl = photoObject.getThumbnail(ImgurPhoto.THUMBNAIL_GALLERY, true, FileUtil.EXTENSION_GIF);
} else {
photoUrl = ((ImgurPhoto) obj).getThumbnail(ImgurPhoto.THUMBNAIL_GALLERY, false, null);
}
124. displayImage(galleryHolder.image, photoUrl);
Gallery holder definition used in the previous snippet. It represents each slot of the gridView.
src/main/java/com/kenny/openimgur/ui/adapters/GalleryAdapter.java
public static class GalleryHolder extends BaseViewHolder {
235. @BindView(R.id.image)
236. ImageView image;
@BindView(R.id.score)
TextView score;
@BindView(R.id.itemType)
ImageView itemType;
public GalleryHolder(View view) {
super(view);
}
}
In order to display, the image a “ImageLoader” is required, nevertheless this imageloader belongs to a external Library.
src/main/java/com/kenny/openimgur/ui/adapters/BaseRecyclerAdapter.java
28. private ImageLoader imageLoader;
Finally, when the “displayImage” method is called it redirects the event flow to “ImageLoader.displayImage” method that can not be accesible. Nevertheless we know that due to connectionless state the library has to be reacting and using a pre-defined image when it can not retrieve the requiered image.
src/main/java/com/kenny/openimgur/ui/adapters/BaseRecyclerAdapter.java
/**
* Displays the image
*
* @param imageView
* @param url
*/
protected void displayImage(ImageView imageView, String url) {
if (imageLoader == null) {
throw new IllegalStateException("Image Loader has not been created");
}
imageLoader.cancelDisplayTask(imageView);
60. imageLoader.displayImage(url, imageView, getDisplayOptions());
}