1
0
Fork 0
mirror of https://github.com/vanitasvitae/Spherical synced 2024-11-25 05:42:09 +01:00

Load images in AsyncTask. Fixes #10.

This commit is contained in:
vanitasvitae 2017-09-15 01:40:27 +02:00
parent bd921bfc1b
commit 0fe9bb7ce7
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
2 changed files with 26 additions and 3 deletions

View file

@ -0,0 +1,23 @@
package de.trac.spherical;
import android.content.Intent;
import android.os.AsyncTask;
/**
* Created by vanitas on 15.09.17.
*/
public class HandleImageTask extends AsyncTask<Intent, Void, Void> {
private MainActivity mainActivity;
public HandleImageTask(MainActivity mainActivity) {
this.mainActivity = mainActivity;
}
@Override
protected Void doInBackground(Intent... params) {
mainActivity.handleSentImageIntent(params[0]);
return null;
}
}

View file

@ -119,7 +119,7 @@ public class MainActivity extends AppCompatActivity {
private void checkPermissionAndHandleSentImage(Intent intent) {
int status = ContextCompat.checkSelfPermission(this, Manifest.permission.READ_EXTERNAL_STORAGE);
if (status == PackageManager.PERMISSION_GRANTED) {
handleSentImageIntent(intent);
new HandleImageTask(this).doInBackground(intent);
}
// Cache intent and request permission
@ -137,7 +137,7 @@ public class MainActivity extends AppCompatActivity {
// If request is cancelled, the result arrays are empty.
if (grantResults.length > 0
&& grantResults[0] == PackageManager.PERMISSION_GRANTED) {
handleSentImageIntent(cachedIntent);
new HandleImageTask(this).doInBackground(cachedIntent);
} else {
Toast.makeText(this, R.string.toast_missing_permission, Toast.LENGTH_LONG).show();
}
@ -184,7 +184,7 @@ public class MainActivity extends AppCompatActivity {
* displayed, while images with MIME type image/* are being manually tested using {@link PhotoSphereParser}.
* @param intent incoming intent.
*/
private void handleSentImageIntent(Intent intent) {
void handleSentImageIntent(Intent intent) {
String type = intent.getType();
if (type != null) {