Fixes issue #288 - Crash when sharing a .mp4 file
This commit is contained in:
parent
852c5f268f
commit
ec61cd2b0c
|
@ -18,6 +18,7 @@ import android.Manifest;
|
|||
import android.annotation.SuppressLint;
|
||||
import android.app.Activity;
|
||||
import android.content.BroadcastReceiver;
|
||||
import android.content.ContentResolver;
|
||||
import android.content.IntentFilter;
|
||||
import android.content.pm.PackageManager;
|
||||
import android.graphics.BitmapFactory;
|
||||
|
@ -747,11 +748,18 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
super.onActivityResult(requestCode, resultCode, data);
|
||||
if (requestCode == PICK_IMAGE && resultCode == Activity.RESULT_OK) {
|
||||
picture_scrollview.setVisibility(View.VISIBLE);
|
||||
if (data == null) {
|
||||
if (data == null || data.getData() == null) {
|
||||
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
|
||||
return;
|
||||
}
|
||||
try {
|
||||
|
||||
ContentResolver cr = getContentResolver();
|
||||
String mime = cr.getType(data.getData());
|
||||
if(mime != null && mime.toLowerCase().contains("video")) {
|
||||
InputStream inputStream = getContentResolver().openInputStream(data.getData());
|
||||
new HttpsConnection(TootActivity.this).upload(inputStream, TootActivity.this);
|
||||
} else if(mime != null && mime.toLowerCase().contains("image")) {
|
||||
//noinspection ConstantConditions
|
||||
InputStream inputStream = getContentResolver().openInputStream(data.getData());
|
||||
File photoFiletmp;
|
||||
|
@ -774,6 +782,9 @@ public class TootActivity extends BaseActivity implements OnRetrieveSearcAccount
|
|||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}else {
|
||||
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
Toast.makeText(getApplicationContext(),R.string.toot_select_image_error,Toast.LENGTH_LONG).show();
|
||||
toot_picture.setEnabled(true);
|
||||
|
|
Loading…
Reference in New Issue