mirror of
https://github.com/vanitasvitae/Spherical
synced 2025-09-10 10:49:42 +02:00
Fix NPE, add permission for external storage
This commit is contained in:
parent
179d3b7bd2
commit
a6f93088df
3 changed files with 23 additions and 8 deletions
|
@ -72,7 +72,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
displayPhotoSphere(imageUri);
|
||||
break;
|
||||
|
||||
case MIME_IMAGE:
|
||||
default:
|
||||
displayMaybePhotoSphere(imageUri);
|
||||
break;
|
||||
}
|
||||
|
@ -92,12 +92,10 @@ public class MainActivity extends AppCompatActivity {
|
|||
String xml = SphereParser.getXMLContent(inputStream);
|
||||
PhotoSphereMetadata metadata = SphereParser.parse(xml);
|
||||
|
||||
inputStream = getContentResolver().openInputStream(uri);
|
||||
|
||||
if (metadata.isUsePanoramaViewer()) {
|
||||
displayPhotoSphere(inputStream, metadata);
|
||||
if (metadata == null || !metadata.isUsePanoramaViewer()) {
|
||||
displayFlatImage(getContentResolver().openInputStream(uri));
|
||||
} else {
|
||||
displayFlatImage(inputStream);
|
||||
displayPhotoSphere(getContentResolver().openInputStream(uri), metadata);
|
||||
}
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -117,6 +115,11 @@ public class MainActivity extends AppCompatActivity {
|
|||
String xml = SphereParser.getXMLContent(inputStream);
|
||||
PhotoSphereMetadata metadata = SphereParser.parse(xml);
|
||||
|
||||
if (metadata == null) {
|
||||
Log.e(TAG, "Metadata is null. Fall back to flat image.");
|
||||
displayFlatImage(getContentResolver().openInputStream(uri));
|
||||
}
|
||||
|
||||
displayPhotoSphere(getContentResolver().openInputStream(uri), metadata);
|
||||
|
||||
} catch (FileNotFoundException e) {
|
||||
|
@ -130,6 +133,7 @@ public class MainActivity extends AppCompatActivity {
|
|||
|
||||
private void displayPhotoSphere(InputStream inputStream, PhotoSphereMetadata metadata) {
|
||||
//Please fill me!
|
||||
Log.d(TAG, "Display Photo Sphere!");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -137,6 +141,6 @@ public class MainActivity extends AppCompatActivity {
|
|||
* @param inputStream
|
||||
*/
|
||||
private void displayFlatImage(InputStream inputStream) {
|
||||
|
||||
Log.d(TAG, "Display Flat Image!");
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue