Skip to content

Commit 25c309c

Browse files
committed
Added an icon for when there are no pictures on the frame and when an image fails to load
1 parent 527e5ff commit 25c309c

File tree

3 files changed

+20
-1
lines changed

3 files changed

+20
-1
lines changed

app/src/main/java/nuts/deez/photoframeslideshow/MainActivity.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,22 @@ void updateImage() {
484484
showPictureAsync(nextPic);
485485

486486
} else {
487+
showNoPicturesIcon();
487488
Toast.makeText(getApplicationContext(), "No Pictures Found!", Toast.LENGTH_SHORT).show();
488489
}
489490
}
490491
}
491492

493+
void showNoPicturesIcon(){
494+
image = findViewById(R.id.imageView);
495+
image.setImageResource(R.drawable.no_images);
496+
}
497+
498+
void showBrokenImageIcon(){
499+
image = findViewById(R.id.imageView);
500+
image.setImageResource(R.drawable.broken_image);
501+
}
502+
492503
void goToPreviousImage(){
493504
if (imageIndex == 0){ //If it's showing the first picture...
494505
//Currently showing first picture, can't go back
@@ -703,6 +714,7 @@ protected Bitmap doInBackground(String... params) {
703714

704715
if (!imageFile.exists()) {
705716
Log.i(TAG, imageName + " does not exist?");
717+
showBrokenImageIcon();
706718
return null;
707719
}
708720

@@ -712,6 +724,8 @@ protected Bitmap doInBackground(String... params) {
712724
Bitmap bmImg = decodeFile(imageFile, frameWidth, frameHeight);
713725
if (bmImg == null) {
714726
Toast.makeText(getApplicationContext(), "Loaded null...", Toast.LENGTH_LONG).show();
727+
showBrokenImageIcon();
728+
return null;
715729
}
716730

717731
int orientation = ei.getAttributeInt(ExifInterface.TAG_ORIENTATION,
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
<vector android:height="512dp"
2+
android:viewportHeight="24" android:viewportWidth="24"
3+
android:width="512dp" xmlns:android="http://schemas.android.com/apk/res/android">
4+
<path android:fillColor="@android:color/white" android:pathData="M21.9,21.9l-8.49,-8.49l0,0L3.59,3.59l0,0L2.1,2.1L0.69,3.51L3,5.83V19c0,1.1 0.9,2 2,2h13.17l2.31,2.31L21.9,21.9zM5,18l3.5,-4.5l2.5,3.01L12.17,15l3,3H5zM21,18.17L5.83,3H19c1.1,0 2,0.9 2,2V18.17z"/>
5+
</vector>

app/src/main/res/layout/activity_main.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
app:layout_constraintTop_toTopOf="parent"
2525
app:layout_constraintVertical_bias="0.0"
2626
app:srcCompat="@color/black"
27-
tools:srcCompat="@tools:sample/backgrounds/scenic[1]"
27+
tools:srcCompat="@drawable/no_images"
2828
tools:visibility="visible" />
2929

3030
<ImageView

0 commit comments

Comments
 (0)