Updated the code so that only a maximum of four (4) shared images are attached to a toot, the rest are quietly discarded.
This commit is contained in:
parent
809a0fd9b5
commit
be4cd3a2c4
|
@ -524,26 +524,34 @@ public class TootActivity extends AppCompatActivity implements OnRetrieveSearcAc
|
||||||
public void uploadSharedImage(ArrayList<Uri> uri)
|
public void uploadSharedImage(ArrayList<Uri> uri)
|
||||||
{
|
{
|
||||||
if (!uri.isEmpty()) {
|
if (!uri.isEmpty()) {
|
||||||
for(Uri fileUri: uri) {
|
int count = 0;
|
||||||
if (fileUri != null) {
|
for(Uri fileUri: uri) {
|
||||||
picture_scrollview.setVisibility(View.VISIBLE);
|
if (fileUri != null) {
|
||||||
|
if (count == 4)
|
||||||
try {
|
{
|
||||||
InputStream inputStream = getContentResolver().openInputStream(fileUri);
|
break;
|
||||||
loading_picture.setVisibility(View.VISIBLE);
|
|
||||||
toot_picture.setEnabled(false);
|
|
||||||
new UploadActionAsyncTask(getApplicationContext(), inputStream, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
|
||||||
} catch (FileNotFoundException e) {
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
|
|
||||||
loading_picture.setVisibility(View.GONE);
|
|
||||||
toot_picture.setEnabled(true);
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
picture_scrollview.setVisibility(View.VISIBLE);
|
||||||
|
|
||||||
|
try {
|
||||||
|
InputStream inputStream = getContentResolver().openInputStream(fileUri);
|
||||||
|
loading_picture.setVisibility(View.VISIBLE);
|
||||||
|
toot_picture.setEnabled(false);
|
||||||
|
new UploadActionAsyncTask(getApplicationContext(), inputStream, TootActivity.this).executeOnExecutor(AsyncTask.THREAD_POOL_EXECUTOR);
|
||||||
|
count++;
|
||||||
|
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
|
||||||
|
loading_picture.setVisibility(View.GONE);
|
||||||
|
toot_picture.setEnabled(true);
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Toast.makeText(getApplicationContext(), R.string.toot_select_image_error, Toast.LENGTH_LONG).show();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
Loading…
Reference in New Issue