mirror of
https://codeberg.org/Freeyourgadget/Gadgetbridge.git
synced 2025-01-27 00:51:44 +01:00
fixed crash on image not found
This commit is contained in:
parent
c0107676e6
commit
13d07751ae
@ -14,6 +14,7 @@ import org.json.JSONArray;
|
|||||||
import org.json.JSONException;
|
import org.json.JSONException;
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.BufferOverflowException;
|
import java.nio.BufferOverflowException;
|
||||||
@ -152,7 +153,7 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
|||||||
|
|
||||||
loadBackground();
|
loadBackground();
|
||||||
loadWidgets();
|
loadWidgets();
|
||||||
renderWidgets();
|
// renderWidgets();
|
||||||
// dunno if there is any point in doing this at start since when no watch is connected the QHybridSupport will not receive any intents anyway
|
// dunno if there is any point in doing this at start since when no watch is connected the QHybridSupport will not receive any intents anyway
|
||||||
|
|
||||||
queueWrite(new SetDeviceStateRequest(GBDevice.State.INITIALIZED));
|
queueWrite(new SetDeviceStateRequest(GBDevice.State.INITIALIZED));
|
||||||
@ -241,7 +242,17 @@ public class FossilHRWatchAdapter extends FossilWatchAdapter {
|
|||||||
|
|
||||||
for (CustomWidgetElement element : widget.getElements()) {
|
for (CustomWidgetElement element : widget.getElements()) {
|
||||||
if (element.getWidgetElementType() == CustomWidgetElement.WidgetElementType.TYPE_BACKGROUND) {
|
if (element.getWidgetElementType() == CustomWidgetElement.WidgetElementType.TYPE_BACKGROUND) {
|
||||||
|
File imageFile = new File(element.getValue());
|
||||||
|
|
||||||
|
if(!imageFile.exists() || !imageFile.isFile()){
|
||||||
|
logger.debug("Image file " + element.getValue() + " not found");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Bitmap imageBitmap = BitmapFactory.decodeFile(element.getValue());
|
Bitmap imageBitmap = BitmapFactory.decodeFile(element.getValue());
|
||||||
|
if(imageBitmap == null){
|
||||||
|
logger.debug("image file " + element.getValue() + " could not be decoded");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
Bitmap scaledBitmap = Bitmap.createScaledBitmap(imageBitmap, 76, 76, false);
|
Bitmap scaledBitmap = Bitmap.createScaledBitmap(imageBitmap, 76, 76, false);
|
||||||
|
|
||||||
widgetCanvas.drawBitmap(
|
widgetCanvas.drawBitmap(
|
||||||
|
Loading…
Reference in New Issue
Block a user