java - how to associate users to a location android -


i parsequery on parseclass called useractivity try pull of user's location , go through each of locations. however, keep failing on constructing proper user list:

i understand if there's nothing in list, should create , add new item. point, should check if each user within 50 feet of item's location.

else if list has @ least 1 item, should check if user there already, if not add user.

i keep doing until reach end of user list.

my code below taking approach: can't seem right results.

ideas?

parsequery<parseobject> cp = new parsequery<>("useractivity"); cp.whereequalto("currenthotspot","none"); cp.whereequalto("venueid","empty"); cp.wherewithinmiles("userlocation",mypoint,10.0); details hpitem; try{ list<parseobject> qreply = cp.find(); if(qreply.size()>0){     for(int = 0; i<qreply.size();i++){         string user = qreply.get(i).getstring("userid");         parsegeopoint userloc = qreply.get(i).getparsegeopoint("userlocation");         double distance = mypoint.distanceinmilesto(userloc);         if(houselist.size()>0){             //for loop through non-empty list             boolean added = false;             for(int j = 0; j < houselist.size();j++){                 if(userloc.distanceinmilesto(houselist.get(j).anchorpt)<0.00568182 && !user.equals(parseuser.getcurrentuser().getusername())){                     houselist.get(j).users.add(user);                     added = true;                 }                 else {                     added = false;                 }             }             if(!added){                 parsegeopoint point1 = qreply.get(i).getparsegeopoint("userlocation");                 list<string> curusershere = new arraylist<>();                 distance = mypoint.distanceinmilesto(userloc);                 curusershere.add(user);                 hpitem= new details();                 hpitem.setlist(curusershere);                 hpitem.setpoint(point1);                 houselist.add(hpitem);             }          }         else if (houselist.size()==0) {             //create new 1             parsegeopoint point1 = qreply.get(i).getparsegeopoint("userlocation");             list<string> curusershere = new arraylist<>();             curusershere.add(qreply.get(i).getstring("userid"));             hpitem = new details();             hpitem.setlist(curusershere);             hpitem.setpoint(point1);             houselist.add(hpitem);         }     }     //remove excess & check if private party     for(int = 0; i<houselist.size();i++){         if(houselist.get(i).users.size()<5 || houselist.get(i).users.size()>35){             log.i("appinfo",houselist.get(i).count+houselist.get(i).users.tostring());             houselist.remove(i);         }     } }   }  catch(exception e){      e.printstacktrace();   } 


Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -