Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I've two api's one for retrieving list items and the other for retrieving Images based on the first api id. I'm able fetch the items and display it in recyclerview but the problem is that only for the last item in the list the image is shown

What I have tried:

First api call method that retrieves the list items and sets the items to HashMap<string,string>
Java
for (RetrieveItemCatalogListByItemCategoryListItem items : response.body()) {
              combinedHashMap = new HashMap<>();
              combinedHashMap.put("ID", String.valueOf(items.getId()));
              combinedHashMap.put("SUPPLIER_ID", String.valueOf(items.getiSupplierID()));
              combinedHashMap.put("SUPPLIER_STORE_NAME", items.getsSupplierStoreName());
              combinedHashMap.put("ITEM_CATEGORY_ID", String.valueOf(items.getiItemCategoryID()));
              combinedHashMap.put("ITEM_CATEGORY", items.getsItemCategory());
              combinedHashMap.put("PRODUCT_TYPE_ID", String.valueOf(items.getiProductTypeID()));
              combinedHashMap.put("PRODUCT_TYPE", items.getsProductType());
              combinedHashMap.put("AVAILABILITY_ID", String.valueOf(items.getiAvailabilityID()));
              combinedHashMap.put("AVAILABILITY", items.getsAvailability());
              combinedHashMap.put("CURRENT_STOCK", items.getsCurrentStock());
              combinedHashMap.put("CURRENT_PRICE", items.getsCurrentPrice());
              combinedHashMap.put("RETURN_POLICY_ID", String.valueOf(items.getiReturnPolicyID()));
              combinedHashMap.put("RETURN_POLICY", items.getsReturnPolicy());
              combinedHashMap.put("PRODUCT_NAME", items.getsProductName());
              combinedHashMap.put("PRODUCT_SERVICE_NAME", items.getsProductServiceName());
              combinedHashMap.put("PRODUCT_DESCRIPTION", items.getsProductDescription());
              combinedHashMap.put("WORKFLOW_STATUS_ID", String.valueOf(items.getiWorkflowStatusID()));
              combinedHashMap.put("WORKFLOW_STATUS", items.getsWorkflowStatus());
              combinedHashMap.put("CREATE_DATE", items.getsCreateDate());
              combinedHashMap.put("UPDATE_DATE", items.getsUpdateDate());
// Method to get Image based on ID
              retrieveImageSource(items.getiSupplierID());
// List<HashMap<String,String>> 
              productMap.add(combinedHashMap);

            }


Second API method to retrieve image
Java
for (RetrieveListBySourceTypeListItem items : response.body().getResult()) {
            List<HashMap<String, String>> fileMap = new ArrayList<>();
            combinedHashMap.put("FILE_NAME", items.getsFileName());
            combinedHashMap.put("SOURCE_ID", String.valueOf(items.getiSourceID()));
            combinedHashMap.put("SOURCE_TYPE_ID", String.valueOf(items.getiSourceTypeID()));


          }

          Log.d("Combined_Items", productMap.toString());
          binding.selectedItemsList.setAdapter(new SearchProductResultAdapter(SearchProductResultActivity.this, productMap, new SearchProductResultAdapter.OnItemClick() {
            @Override
            public void onClick(View view, HashMap<String, String> combinedListItem) {
              if (view.getId() == R.id.layoutItem) {
                String id = combinedListItem.get("ID");
                startActivity(new Intent(getApplicationContext(), ShoppingCartActivity.class)
                    .putExtra("ID", combinedListItem.get("ID")));
              }
            }
          }));
Posted
Updated 26-May-20 2:16am
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900