Return a List

59 views
Skip to first unread message

Pavitra

unread,
Jun 2, 2017, 3:31:13 PM6/2/17
to App Inventor Open Source Development
I am using Anjlab's In App Billing library and was implementing this instruction to get details of multiple product IDs.

When I compile this extension, there is always an error saying the List<String> cannot be converted to YailList. Please help me how to make it work? I don't know how to return a YailList.

The error that has been shown 
error: incompatible types: List<String> cannot be converted to YailList
   
[javac]               GotProductDetails(listOfProductDetails);

This is method that returns a List via an event.

 @SimpleFunction(description="Get Product Details.")
 
public void ProductDetails(ArrayList<String> listOfProductIds) {  
   
List<SkuDetails> sku = bp.getPurchaseListingDetails(listOfProductIds);
 
 
if (sku != null) {
 
List<String> listOfProductDetails = new ArrayList<String>();
   
for(SkuDetails item : sku) {
 listOfProductDetails
.add(item.productId + "," + item.title + "," + item.description + "," + item.priceText);
 
}


 
GotProductDetails(listOfProductDetails);
 
}
// Log.d(LOG_TAG, "ProductDetails: " + productId);
 
}

And the event code is

  @SimpleEvent(description = "Got Product Details")
 
public void GotProductDetails(List<String> details){
   
EventDispatcher.dispatchEvent(this, "GotProductDetails", details);
 
}

Pavitra

unread,
Jun 2, 2017, 3:33:49 PM6/2/17
to App Inventor Open Source Development
But this code works

@Override
           
public void onPurchaseHistoryRestored() {
 
List<String> ownedProducts = new ArrayList<String>();
 
List<String> ownedSubscriptions = new ArrayList<String>();
 
               
if (bp.listOwnedProducts() != null) {
 
for(String sku : bp.listOwnedProducts()) {
 ownedProducts
.add(sku);
 
}
 
}
 
 
if (bp.listOwnedSubscriptions() != null) {
               
for(String subs : bp.listOwnedSubscriptions()) {
 ownedSubscriptions
.add(subs);
 
}
 
}
 
 
GotOwnedPurchases(ownedProducts, ownedSubscriptions);
           
}

And its event code

@SimpleEvent(description = "Got Owned Purchases")
 
public void GotOwnedPurchases(List<String> ownedProducts, List<String> ownedSubscriptions){
   
EventDispatcher.dispatchEvent(this, "GotOwnedPurchases", ownedProducts, ownedSubscriptions);
 
}

Hal Abelson

unread,
Jun 2, 2017, 9:45:36 PM6/2/17
to App Inventor Open Source Development
Look at appinventor/components/runtime/util/YailList.java and the MakeList method at line 70.
Reply all
Reply to author
Forward
0 new messages