Skip to content

Commit

Permalink
Merge pull request #150 from hkjeffchan/master
Browse files Browse the repository at this point in the history
Fix android TransactionTooLargeException
  • Loading branch information
EddyVerbruggen authored Mar 21, 2019
2 parents dc70f4e + 2d9ed07 commit c34e17b
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 2 deletions.
1 change: 1 addition & 0 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@

<source-file src="src/android/com/synconset/ImagePicker/ImagePicker.java" target-dir="src/com/synconset" />
<source-file src="src/android/com/synconset/ImagePicker/FakeR.java" target-dir="src/com/synconset" />
<source-file src="src/android/com/synconset/ImagePicker/ResultIPC.java" target-dir="src/com/synconset" />

<source-file src="src/android/Library/src/ImageFetcher.java" target-dir="src/com/synconset"/>
<source-file src="src/android/Library/src/MultiImageChooserActivity.java" target-dir="src/com/synconset"/>
Expand Down
3 changes: 2 additions & 1 deletion src/android/Library/src/MultiImageChooserActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,8 @@ protected void onPostExecute(ArrayList<String> al) {
res.putInt("TOTALFILES", imagecursor.getCount());
}

data.putExtras(res);
int sync = ResultIPC.get().setLargeData(res);
data.putExtra("bigdata:synccode", sync);
setResult(RESULT_OK, data);

} else {
Expand Down
6 changes: 5 additions & 1 deletion src/android/com/synconset/ImagePicker/ImagePicker.java
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,11 @@ private void requestReadPermission() {

public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (resultCode == Activity.RESULT_OK && data != null) {
ArrayList<String> fileNames = data.getStringArrayListExtra("MULTIPLEFILENAMES");
int sync = data.getIntExtra("bigdata:synccode", -1);
final Bundle bigData = ResultIPC.get().getLargeData(sync);

ArrayList<String> fileNames = bigData.getStringArrayList("MULTIPLEFILENAMES");

JSONArray res = new JSONArray(fileNames);
callbackContext.success(res);

Expand Down
27 changes: 27 additions & 0 deletions src/android/com/synconset/ImagePicker/ResultIPC.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.synconset;

import android.os.Bundle;

public class ResultIPC {

private static ResultIPC instance;

public synchronized static ResultIPC get() {
if (instance == null) {
instance = new ResultIPC ();
}
return instance;
}

private int sync = 0;

private Bundle largeData;
public int setLargeData(Bundle largeData) {
this.largeData = largeData;
return ++sync;
}

public Bundle getLargeData(int request) {
return (request == sync) ? largeData : null;
}
}

0 comments on commit c34e17b

Please sign in to comment.