mirror of
https://github.com/vanitasvitae/Spherical
synced 2024-11-22 04:12:07 +01:00
display progress indicator while loading image
This commit is contained in:
parent
e1ffec96a5
commit
055a39cd50
1 changed files with 44 additions and 32 deletions
|
@ -6,6 +6,7 @@ import android.content.pm.PackageManager;
|
|||
import android.graphics.Bitmap;
|
||||
import android.graphics.BitmapFactory;
|
||||
import android.net.Uri;
|
||||
import android.os.AsyncTask;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.annotation.NonNull;
|
||||
|
@ -165,24 +166,37 @@ public class MainActivity extends AppCompatActivity {
|
|||
if (intent == null) {
|
||||
throw new AssertionError("Intent is null!");
|
||||
}
|
||||
String type = intent.getType();
|
||||
if (type != null) {
|
||||
|
||||
Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
final String type = intent.getType();
|
||||
if (type == null) {
|
||||
Toast.makeText(this, "TODO: Figure out what to do :D", Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
final Uri imageUri = intent.getParcelableExtra(Intent.EXTRA_STREAM);
|
||||
if (imageUri == null) {
|
||||
Toast.makeText(this, R.string.toast_file_not_found, Toast.LENGTH_SHORT).show();
|
||||
return;
|
||||
}
|
||||
|
||||
Log.d(TAG, "START LOADING BITMAP");
|
||||
// process image asynchronous.
|
||||
new AsyncTask<Uri, Void, Void>() {
|
||||
@Override
|
||||
protected Void doInBackground(Uri... params) {
|
||||
Uri uri = params[0];
|
||||
|
||||
try {
|
||||
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(imageUri));
|
||||
metadata = PhotoSphereParser.parse(getContentResolver().openInputStream(imageUri));
|
||||
bitmap = BitmapFactory.decodeStream(getContentResolver().openInputStream(uri));
|
||||
metadata = PhotoSphereParser.parse(getContentResolver().openInputStream(uri));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
Log.d(TAG, "FINISHED LOADING BITMAP");
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onPostExecute(Void result) {
|
||||
switch (type) {
|
||||
case MIME_PHOTO_SPHERE:
|
||||
displayPhotoSphere();
|
||||
|
@ -196,10 +210,8 @@ public class MainActivity extends AppCompatActivity {
|
|||
}
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
Toast.makeText(this, "TODO: Figure out what to do :D", Toast.LENGTH_SHORT).show();
|
||||
}
|
||||
}.execute(imageUri);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue