Monday, 15 June 2015

java - JSON Object to generic ParseFile Object, issue -



java - JSON Object to generic ParseFile Object, issue -

i have run in issue, while converting ios app android.

the database structured such there "stations", these stations can have multiple images attached, in parse database, images array of imagepointers.

when wanted images out in ios here did:

stations = object in case

// single image if ([[object objectforkey:@"imagepointers"] objectatindex:0] != [nsnull null]) { pffile *imagefile = [[[object objectforkey:@"imagepointers"] objectatindex:0] objectforkey:@"image"]; cell.coverimageview.file = imagefile; [cell.coverimageview loadinbackground]; }

its pretty simple, lift imagepointers array , objectatindex0, cast parse file.

but can't in android, here have atm:

jsonarray imagepointers = thisstation.getjsonarray("imagepointers"); seek { jsonobject indeximage = imagepointers.getjsonobject(0); } grab ( exception e ) { jsonobject indeximage = null; }

here object @ index 0 jsonobject, cannot utilize in parsefile object, since need cast generic type parsefile.

how do this? or approach incorrect?

fixed avoiding casting json, apparently there getlist method

// parse image index image parseobject thisstation = stationitems.get(position); list<parseobject>imagepointers = thisstation.getlist("imagepointers"); parsefile image = imagepointers.get(0).getparsefile("image"); thumbnail.setparsefile(image); thumbnail.loadinbackground();

java android parse.com

No comments:

Post a Comment