Get an arraylist from Parse.com in a new Activity - android

I wish to get an array from the Parse cloud. After tapping on an item in a list (which contains the ParseObject reference), the item will open a new activity and from this I want to get the array list stored in the latLngPoints key in Parse. I have googled and only found the following solution but it does not work:
ArrayList<ParseGeoPoint> parseList = (ArrayList<ParseGeoPoint>) getIntent().getExtras().getParcelableArrayList("latLngPoints");
Is it possible to even do it this way, or will I have to create a Parse object and create a request to get the information I need?

ParseObjects are not parcelable. You can pass an array list of longs that represent lat and long

Related

Saving decoded polylines into a firebase database in android

I have already seen the code to store a single point in firebase. But what I want to know is how to store whole polylines in firebase database? A decoded polyline is basiclly List. I want to know how to store many such type of lists in firebase so that I can retrieve later and perform operations on whole polyline.
Firebase use JSON format Database
Pass types that correspond to the available JSON types as follows:
String
Long
Double
Boolean
Map
List
you can pass any of data type a value in setValue() method and Lists and Map ,too.
Example:
Firebase ref = new Firebase("<my-firebase-app>/names"):
String[] names = {"John","Tim","Sam","Ben"};
List nameList = new ArrayList<String>(Arrays.asList(names));
// Now set value with new nameList
ref.setValue(nameList);
you can pass your custome object list,too.

Spinner from json raw file

I have a raw json file like this
{"_id":707860,"name":"Hurzuf","country":"UA","coord":{"lon":34.283333,"lat":44.549999}}
{"_id":519188,"name":"Novinki","country":"RU","coord":{"lon":37.666668,"lat":55.683334}}
{"_id":1283378,"name":"Gorkhā","country":"NP","coord":{"lon":84.633331,"lat":28}}
{"_id":1270260,"name":"State of Haryāna","country":"IN","coord":{"lon":76,"lat":29}}
{"_id":708546,"name":"Holubynka","country":"UA","coord":{"lon":33.900002,"lat":44.599998}}
{"_id":1283710,"name":"Bāgmatī Zone","country":"NP","coord":{"lon":85.416664,"lat":28}}
{"_id":529334,"name":"Mar’ina Roshcha","country":"RU","coord":{"lon":37.611111,"lat":55.796391}}
{"_id":1269750,"name":"Republic of India","country":"IN","coord":{"lon":77,"lat":20}}
{"_id":1283240,"name":"Kathmandu","country":"NP","coord":{"lon":85.316666,"lat":27.716667}}
{"_id":703363,"name":"Laspi","country":"UA","coord":{"lon":33.733334,"lat":44.416668}}
It is NOT an JSON array - it is a huge list of JSON objects. Here Populate the spinner from JSON In Android, here Convert json array to list of json(raw) strings here android how to convert json array to string array or even here https://developer.android.com/guide/topics/ui/controls/spinner.html it is assumed that I have a JSON array or static data. I'd like to have two spinners in which one is for country and second one is for city. Let's assume I have list of countries so it will be a static data. I'd like the second spinner to dynamically load from raw json file all cities that corresponds to selected city in first spinner. I think that I can handle spinners thing but how can I load data from raw json file into spinner? Do I need to modify this raw file so that it will be a json array and then do something like this:
JSONArray jsonArray = new JSONArray(arraytitle);
List<String> list = new ArrayList<String());
for(int i = 0 ; i < jsonArray.length();i++){
list.add(jsonArray.getJSONObject(i));
}
EDIT
I found this answer https://stackoverflow.com/a/26780581/4671908 - if I will succeed I will post an answer
So you have two questions:
How to update the second Spinner dynamically when the first Spinner is updated
Three thing you need to do:
Implement AdapterView.OnItemSelectedListener
Update the backed data set inside the adapter of the second Spinner. In your case it would be a list of city. (To do this you need to create your own adapter extended from ArrayAdapter)
Call adapter.notifyDataSetChanged()
How to use the JSON
There are several solutions there. But it would be hard for others to provide the one that would suit your case the best without knowing any detail of the requirement.
Just remember one thing when you face design problem:
Do the simplest thing first.

Get objects with certain value(objectId) in array with Parse for Android

I have a Place object, containing an array with objectIds for Tag objects.
An example of an array:
[[{"__type":"Pointer","className":"FavoriteTag","objectId":"Toc5sVlzVd"},{"__type":"Pointer","className":"FavoriteTag","objectId":"cUxcl0IFFv"}]]
My first workflow way too slow:
query each Place object, get the array and parse it to find each objectId
get the corresponding Place with the objectId
The workflow I'm trying:
Find the objectId of each matching Tag object
Put these objectIds in a ArrayList
Get each Place object that contains a matching objectId from the arraylist
I don't know how to do step 3.
I'm trying:
parseQueryFavoritePlaces.whereEqualTo("tags", arrayListTagsObjectIds);
and
parseQueryFavoritePlaces.whereContainedIn("tags", arrayListTagsObjectIds);
but no luck so far.
Am I on the right track here?
Try giving this a shot:
query.whereContainedIn(String key, Collection<? extends Object> values)
According to the Parse documentation this adds a constraint to the query that requires a particular key's value to be contained in the provided list of values.
Here's the ParseQuery documentation if you think that might be useful!

ArrayList with Multiple data

I have a small issue with ArrayList. I have to fetch the document from the server.
The document contains 7 fields of data. I have to show the document names in the list view.
For this I have added different fields data to the different ArrayList. So when I click on the document name, based on the position of the document, I fetched the all fields data from the different Arraylist based on the position.
But Have a small issue using by using the above procedure. Is there any procedure that is not depend on the position, what I want is irrespective of position if I click on the Document,based on the keyword document data to be extract.
Any Help Appreciated.
Thanks in Advance.
I got your point. If you try to manage different ArrayLists then it would be difficult to manage it. I mean if you delete item from particular position from particular ArrayList then you will have to delete items from same position from other ArrayList, if you forgot to do so then it will be unbalanced.
Solution:
Instead feasible solution is to create ArrayList<Object> or ArrayList<HashMap<String,String>>, so your every item is the type of particular object, and every object contains detail and everything of particular items.
For example: ArrayList<Documents>, here ArrayList will contains list of Documents objects, and every objects contains values of 7 fields.
Its simply easy to define Documents class with getter/setter attributes.

How to get item value from ArrayList in an Object

I am trying to process XML plist data from an API, but am hitting lots of walls!
The data is Apple plist format, which I am parsing using Akos' code from this link which seems to work perfectly. It is parsing as String, Object into a HashMap. I am able to get the value of a given key ie.
Object childItems = items.mPlistHashMap.get("childItems");
System.out.println(childItems.getClass());
System.out.println(childItems);
childItems.getClass() shows as - class java.util.ArrayList
The LogCat output for childItems shows -
[{remoteFilePath=/Picture.png, host=www.host.com, ratingCount=1, targetId=82, commentCount=1, externalId=/demo.host.com/Private/Picture.png, fileSize=23738, entity_name=Item, memberAccessLevel=0, leaderAccessLevel=0, name=Picture.png, target=SystemUser, ownerAccessLevel=3, tagCount=1}, {lastName=Test, entity_name=User, username=Test, host=www.host.com, userId=82, firstName=Test, password=TestPwd, loginName=Test}, {typeId=0, entity_name=UserType, name=UserType_Teacher}]
I presume that I can then work with this ArrayList, but this is where I am coming undone. For instance I want to get the remoteFilePath value, and display this in a ListView (already working for local files).
The example childItems list above only contain one file (Picture.png), but this list could contain any number of files, so I would need to iterate the list and get any values for remoteFilePath to display.
Any help appreciated, I just don't know how to "bore down" into this list, or if the childItems object needs to be cast to a new Array or so on.
If I'm missing any vital information, ask and I shall provide :)
ArrayList<?> childItems = (ArrayList<?>) elockeritems.mPlistHashMap.get("childItems");
I can now work with this. I need to get my head around the fundamentals!

Categories

Resources