You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have implemented the simple multipart request which also includes setOnProgressListener but the method doesn't get called hence progress bar doesn't show updated progress.
Here's my implementation
final int[] percentDone = {0};
param.put("uid", new SQLiteHandler(context).getUserDetails().get("uid"));
SimpleMultiPartRequest jsonRequest = new SimpleMultiPartRequest(Request.Method.POST, URL,
new Response.Listener<String>() {
@Override
public void onResponse(String response) {
listener.success(response);
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
if (error != null && error.getCause() != null && error.getMessage() != null) {
Log.d(tag, error.getMessage() + "");
} else
Log.d(tag, "Nothing");
listener.error(error);
}
});
for (String string :
param.keySet()) {
jsonRequest.addMultipartParam(string, "text/plain",
param.get(string));
}
// jsonRequest.setFixedStreamingMode(true);
jsonRequest.setOnProgressListener(new Response.ProgressListener() {
@Override
public void onProgress(long transferredBytes, long totalSize) {
System.out.println(">>>>>>" + transferredBytes);
final int latestPercentDone = (int) ((transferredBytes / (float) totalSize) * 100);
if (percentDone[0] != latestPercentDone) {
percentDone[0] = latestPercentDone;
if (progressDialog != null)
progressDialog.setProgress(percentDone[0]);
}
if (BuildConfig.DEBUG) Log.d(tag, percentDone[0] + "");
if (transferredBytes >= totalSize && progressDialog.isShowing()) {
progressDialog.dismiss();
}
}
});
RequestQueue mRequestQueue = Volley.newRequestQueue(context);
mRequestQueue.add(jsonRequest);
mRequestQueue.start();
The text was updated successfully, but these errors were encountered:
I have implemented the simple multipart request which also includes
setOnProgressListener
but the method doesn't get called hence progress bar doesn't show updated progress.Here's my implementation
The text was updated successfully, but these errors were encountered: