当图像设置为齐射json时进度对话框UI冻结/缓慢

时间:2018-12-12 09:57:06

标签: json android-studio android-volley picasso progressdialog

我想使用Volley / Picasso显示进度条。

从JSON API获取图像时,我的图像尺寸很大,但是当图像设置为截距JSON时,它第一次卡住或冻结,或者进度对话框UI冻结/缓慢。

我已使用Picasso库进行图像加载。这是我的代码:

 public void InfoJson() {
    dialog.ShowProgressDialog();
    RequestQueue requestQueue = Volley.newRequestQueue(context);
    StringRequest stringRequest = new StringRequest(Request.Method.POST, Constant.Base_Url+"BookingGuestData.php?", new Response.Listener<String>() {
        @Override
        public void onResponse(String response) {
            try {

                JSONObject obj = new JSONObject(response);
                String error = obj.getString("error");


                if (error.equals("true")) {
                    ids = obj.getString("id");
                    aadhar_str = obj.getString("aadhar");
                    name_name = obj.getString("name");
                    mobile = obj.getString("mobile");
                    photo_str = obj.getString("photo");
                    id_proof_str = obj.getString("id_proof");
                    address_proof_str = obj.getString("address_proof");


                    Picasso.with(context).load(photo_str).into(ivImage0);
                    Picasso.with(context).load(id_proof_str).into(ivImage);
                    Picasso.with(context).load(address_proof_str).into(ivImage2);

                    thumbnail0 = getBitmapFromURL(photo_str);
                    thumbnail = getBitmapFromURL(id_proof_str);
                    thumbnail2 = getBitmapFromURL(address_proof_str);


                    name.setText(name_name);
                    phone.setText(mobile);
                    adhaar.setText(aadhar_str);

                }
                else
                {
                    TastyToast.makeText(context,  obj.getString("msg"), TastyToast.LENGTH_LONG, TastyToast.ERROR);
                }
                dialog.CancelProgressDialog();
            } catch (JSONException e) {
                e.printStackTrace();
            }
        }
    }, new Response.ErrorListener() {
        @Override
        public void onErrorResponse(VolleyError error) {
            VolleyLog.d(TAG, "Error: " + error.getMessage());
            dialog.CancelProgressDialog();
            //item_progress_bar.setVisibility(View.GONE);
        }
    }) {
        @Override
        protected Map<String, String> getParams() {
            Map<String, String> params = new HashMap<>();
            params.put("gid", ids);
            Log.e("params", String.valueOf(params));
            return params;
        }
    };

    requestQueue.add(stringRequest);
}

请帮助我解决此问题。

0 个答案:

没有答案