for循环中的异步任务

时间:2018-11-20 13:35:57

标签: android android-fragments android-asynctask

我在for循环中使用异步任务,并使用get方法从异步调用中检索结果值。但有时屏幕空白。 如何解决这个问题。

代码如下:

for (ArrayList<HashMap> item : response) {
        // Log.i("Arraylist testing",String.valueOf(item.size())) ;
        for (HashMap map : item) {

                AsynchronousCallForProductType asynchronousCallForProductType = new AsynchronousCallForProductType(productId.toString(), null, view.getContext());
                //asynchronousCallForProductType.completeResult = PutAwayDetailsFragment.this;
                try {
                    HashMap output = asynchronousCallForProductType.execute().get();
                    serializedFlag = Boolean.valueOf(output.get("serializedFlag").toString());
                    optionalFlag = Boolean.valueOf(output.get("optionalFlag").toString());
                } catch (ExecutionException e) {
                    e.printStackTrace();
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                Log.i("test2", "test two");
                String sourceLogisticsAreaId = null;
                PutAwayLineItemDataPojo pojo = new PutAwayLineItemDataPojo(putAwayLineItemId, putAwayOpenQuantity,
                        putAwayActualQuantity, product, putAwayTaskId, putAwaySiteLogisticsTaskUUID, putAwayReferenceObjectUUD,
                        putAwayOperationActivityUUID, putAwaySiteLogisticsMaterialOutputUUID, putAwayTargetLogisticsAreaId,
                        pickFlag, serializedFlag, optionalFlag, sourceLogisticsAreaId);
                putAwayLineItemDataList.add(pojo);


            }

0 个答案:

没有答案