]> iEval git - fonbot.git/blobdiff - src/ro/ieval/fonbot/PollResultCallback.java
Let the user choose which camera to take photos with
[fonbot.git] / src / ro / ieval / fonbot / PollResultCallback.java
index 2517fce29f8e65d04f8cb3963ff05612af770416..d3c84cebc1a2dde5eaacbbabba9b7801bfe0a6ed 100644 (file)
@@ -3,6 +3,7 @@ package ro.ieval.fonbot;
 import static ro.ieval.fonbot.Utils.toNonNull;
 
 import java.io.InputStream;
+import org.eclipse.jdt.annotation.Nullable;
 
 import org.json.JSONArray;
 import org.json.JSONObject;
@@ -53,9 +54,8 @@ final class PollResultCallback implements ResultCallback {
        }
 
        @Override
-       public void onResult(int responseCode, String responseMessage,
-                       InputStream inputStream) {
-               if(responseCode!=200)
+       public void onResult(final int responseCode, final String responseMessage, final @Nullable InputStream inputStream) {
+               if(responseCode!=200 || inputStream==null)
                        return;
 
                final Handler handler=new Handler(Looper.getMainLooper());
@@ -63,9 +63,9 @@ final class PollResultCallback implements ResultCallback {
                try{
                        final JSONArray array;
                        {
-                               final byte[] buf=new byte[4096*1024];
-                               inputStream.read(buf);
-                               array=new JSONArray(new String(buf));
+                               final byte[] buf=new byte[2048*1024];
+                               final int length=inputStream.read(buf);
+                               array=new JSONArray(new String(buf, 0, length));
                        }
 
                        for(int i=0;i<array.length();i++){
This page took 0.017865 seconds and 4 git commands to generate.