java - Syntax error on tokens, AnnotationName expected instead - error on query -
i have received syntax error on tokens, annotationname expected instead occured on following line:
query.findinbackground(new findcallback<parseuser>() {
i have been trying troubleshoot since while, still having difficulties.
below complete code
public class fragment1 extends fragment { public interface constants { string log = "com.dooba.beta"; } private string currentuserid; private arrayadapter<string> namesarrayadapter; private arraylist<string> names; private arraylist<images> alprofilepicture; private listview userslistview; private button logoutbutton; string usergender = parseuser.getcurrentuser().getstring("gender"); string activityname = parseuser.getcurrentuser().getstring("activityname"); number maxdistance = parseuser.getcurrentuser().getnumber("maximum_distance"); string userlookinggender = parseuser.getcurrentuser().getstring("looking_gender"); number minimumage = parseuser.getcurrentuser().getnumber("minimum_age"); number maximumage = parseuser.getcurrentuser().getnumber("maximum_age"); number userage = parseuser.getcurrentuser().getnumber("age"); @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); setconversationslist(); } @override public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment1_layout, container, false); return view; } private void setconversationslist() { currentuserid = parseuser.getcurrentuser().getobjectid(); names = new arraylist<string>(); alprofilepicture = new arraylist<images>(); // string useractivityselectionname = null; parsequery<parseuser> query = parseuser.getquery(); // query.whereequalto("activityname",useractivityselectionname); query.wherenotequalto("objectid", parseuser.getcurrentuser().getobjectid()); // users gender = currentuser.looking_gender query.whereequalto("gender", userlookinggender); // users looking_gender = currentuser.gender query.whereequalto("looking_gender", usergender); query.setlimit(1); query.whereequalto("activityname", activityname); //query.wheregreaterthanorequalto("age", minimumage); //query.wherelessthanorequalto("age", maximumage); query.orderbydescending("name"); log.d(constants.log, ""); query.findinbackground(new findcallback() { @override public void done(java.util.list<parseobject> objects, parseexception e) { parsequery<parseobject> query = parsequery.getquery("user"); parsefile image = object.getparsefile("profilepicture"); parseimageview imageview = (parseimageview) getview().findviewbyid(r.id.profilepictureresult); // placeholder used before , during fetch, replaced fetched image // data. imageview.setplaceholder(getresources().getdrawable(r.drawable.profile_pict)); imageview.setparsefile(image); imageview.loadinbackground(new getdatacallback() { @override public void done(byte[] data, parseexception e) { log.i("parseimageview", "fetched! data length: " + data.length + ", or exception: " + e.getmessage()); } }); } query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistname, parseexception e) { if (e == null) { (int i=0; i<userlistname.size(); i++) { names.add(userlistname.get(i).get("name").tostring()); // names.add(userlist.get(i).getparseobject("profilepicture").; } userslistview = (listview)getactivity().findviewbyid(r.id.userlistname); namesarrayadapter = new arrayadapter<string>(getactivity().getapplicationcontext(), r.layout.user_list_item, names); userslistview.setadapter(namesarrayadapter); userslistview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long).show(); } } }); } public void openconversation(arraylist<string> names, int pos) { parsequery<parseuser> query = parseuser.getquery(); query.whereequalto("name", names.get(pos)); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> user, parseexception e) { if (e == null) { intent intent = new intent(getactivity().getapplicationcontext(), messagingactivity.class); intent.putextra("recipient_id", user.get(0).getobjectid()); startactivity(intent); } else { toast.maketext(getactivity().getapplicationcontext(), "error finding user", toast.length_short).show(); } } }); } }
thanks in advance, , best.
update in response rod_algonquin
in response haresh
update 2 code
public class fragment1 extends fragment { public interface constants { string log = "com.dooba.beta"; } private string currentuserid; private arrayadapter<string> namesarrayadapter; private arraylist<string> names; private arraylist<images> alprofilepicture; private listview userslistview; private button logoutbutton; string usergender = parseuser.getcurrentuser().getstring("gender"); string activityname = parseuser.getcurrentuser().getstring("activityname"); number maxdistance = parseuser.getcurrentuser().getnumber("maximum_distance"); string userlookinggender = parseuser.getcurrentuser().getstring("looking_gender"); number minimumage = parseuser.getcurrentuser().getnumber("minimum_age"); number maximumage = parseuser.getcurrentuser().getnumber("maximum_age"); number userage = parseuser.getcurrentuser().getnumber("age"); @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); setconversationslist(); } @override public view oncreateview(layoutinflater inflater, viewgroup container,bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment1_layout, container, false); return view; } private void setconversationslist() { currentuserid = parseuser.getcurrentuser().getobjectid(); names = new arraylist<string>(); alprofilepicture = new arraylist<images>(); // string useractivityselectionname = null; parsequery<parseuser> query = parseuser.getquery(); // query.whereequalto("activityname",useractivityselectionname); query.wherenotequalto("objectid", parseuser.getcurrentuser().getobjectid()); // users gender = currentuser.looking_gender query.whereequalto("gender", userlookinggender); // users looking_gender = currentuser.gender query.whereequalto("looking_gender", usergender); query.setlimit(1); query.whereequalto("activityname", activityname); //query.wheregreaterthanorequalto("age", minimumage); //query.wherelessthanorequalto("age", maximumage); query.orderbydescending("name"); log.d(constants.log, ""); query.findinbackground(new findcallback<parseobject>() { public void done(parseobject object,parseexception e) { parsequery<parseobject> query = parsequery.getquery("user"); parsefile image = object.getparsefile("profilepicture"); parseimageview imageview = (parseimageview) getview().findviewbyid(r.id.profilepictureresult); // placeholder used before , during fetch, replaced fetched image // data. imageview.setplaceholder(getresources().getdrawable(r.drawable.profile_pict)); imageview.setparsefile(image); imageview.loadinbackground(new getdatacallback() { @override public void done(byte[] data, parseexception e) { log.i("parseimageview", "fetched! data length: " + data.length + ", or exception: " + e.getmessage()); } }); } @override public void done(list<parseobject> objects, parseexception e) { // todo auto-generated method stub }}); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistname, parseexception e) { if (e == null) { (int i=0; i<userlistname.size(); i++) { names.add(userlistname.get(i).get("name").tostring()); } userslistview = (listview)getactivity().findviewbyid(r.id.userlistname); namesarrayadapter = new arrayadapter<string>(getactivity().getapplicationcontext(), r.layout.user_list_item, names); userslistview.setadapter(namesarrayadapter); userslistview.setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long).show(); } } }); } public void openconversation(arraylist<string> names, int pos) { parsequery<parseuser> query = parseuser.getquery(); query.whereequalto("name", names.get(pos)); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> user, parseexception e) { if (e == null) { intent intent = new intent(getactivity().getapplicationcontext(), messagingactivity.class); intent.putextra("recipient_id", user.get(0).getobjectid()); startactivity(intent); } else { toast.maketext(getactivity().getapplicationcontext(), "error finding user", toast.length_short).show(); } } }); } }
update:
updated code 4
i encountering 2 problems: 1) object cannot resolved
2) below error underline in yellow, not render when activity loads the method done1(list<parseuser>, parseexception) type new findcallback<parseuser>(){} never used locally
update 5
public class fragment1 extends fragment { public interface constants { string log = "com.dooba.beta"; } private string currentuserid; private arrayadapter<string> namesarrayadapter; private arraylist<string> names; private arraylist<string> age; private arraylist<string> headline; private arraylist<string> activityname; private arraylist<images> alprofilepicture; private listview userslistview; private button logoutbutton; string usergender = parseuser.getcurrentuser().getstring("gender"); string activityname = parseuser.getcurrentuser().getstring("activityname"); number maxdistance = parseuser.getcurrentuser().getnumber( "maximum_distance"); string userlookinggender = parseuser.getcurrentuser().getstring( "looking_gender"); number minimumage = parseuser.getcurrentuser().getnumber("minimum_age"); number maximumage = parseuser.getcurrentuser().getnumber("maximum_age"); number userage = parseuser.getcurrentuser().getnumber("age"); @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); setconversationslist(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment1_layout, container, false); return view; } private void setconversationslist() { currentuserid = parseuser.getcurrentuser().getobjectid(); names = new arraylist<string>(); age = new arraylist<string>(); headline = new arraylist<string>(); activityname = new arraylist<string>(); alprofilepicture = new arraylist<images>(); // string useractivityselectionname = null; parsequery<parseuser> query = parseuser.getquery(); // query.whereequalto("activityname",useractivityselectionname); query.wherenotequalto("objectid", parseuser.getcurrentuser() .getobjectid()); // users gender = currentuser.looking_gender query.whereequalto("gender", userlookinggender); // users looking_gender = currentuser.gender query.whereequalto("looking_gender", usergender); query.setlimit(1); query.whereequalto("activityname", activityname); // query.wheregreaterthanorequalto("age", minimumage); // query.wherelessthanorequalto("age", maximumage); query.orderbydescending("name"); log.d(constants.log, ""); query.findinbackground(new findcallback<parseuser>() { @override public void done(list<parseuser> users,parseexception e) { // whatever need extract object "users" parsequery<parseobject> query = parsequery.getquery("user"); parsefile image = object.getparsefile("profilepicture"); parseimageview imageview = (parseimageview) getview().findviewbyid(r.id.profilepictureresult); // placeholder used before , during fetch, replaced fetched image // data. imageview.setplaceholder(getresources().getdrawable(r.drawable.profile_pict)); imageview.setparsefile(image); imageview.loadinbackground(new getdatacallback() { @override public void done(byte[] data, parseexception e) { log.i("parseimageview", "fetched! data length: " + data.length + ", or exception: " + e.getmessage()); } }); } }); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistname, parseexception e) { if (e == null) { (int = 0; < userlistname.size(); i++) { names.add(userlistname.get(i).get("name").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistname); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, names); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); } query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistheadline, parseexception e) { if (e == null) { (int = 0; < userlistheadline.size(); i++) { headline.add(userlistheadline.get(i).get("headline") .tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistheadline); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_all, headline); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); } query.findinbackground(new findcallback<parseuser>() { public void done2(list<parseuser> userlistage, parseexception e) { if (e == null) { (int = 0; < userlistage.size(); i++) { age.add(userlistage.get(i).get("age").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistage); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, age); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); } query.findinbackground(new findcallback<parseuser>() { public void done3(list<parseuser> userlistactivity, parseexception e) { if (e == null) { (int = 0; < userlistactivity.size(); i++) { activityname.add(userlistactivity.get(i) .get("activityname").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistactivityname); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, activityname); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); } public void openconversation(arraylist<string> names, int pos) { parsequery<parseuser> query = parseuser.getquery(); query.whereequalto("name", names.get(pos)); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> user, parseexception e) { if (e == null) { intent intent = new intent(getactivity() .getapplicationcontext(), messagingactivity.class); intent.putextra("recipient_id", user.get(0).getobjectid()); startactivity(intent); } else { toast.maketext(getactivity().getapplicationcontext(), "error finding user", toast.length_short) .show(); } } }); } }
any app
try replace code,hope solve problem.
public class fragment1 extends fragment { public interface constants { string log = "com.dooba.beta"; } private string currentuserid; private arrayadapter<string> namesarrayadapter; private arraylist<string> names; private arraylist<string> age; private arraylist<string> headline; private arraylist<string> activityname; private arraylist<images> alprofilepicture; private listview userslistview; private button logoutbutton; string usergender = parseuser.getcurrentuser().getstring("gender"); string activityname = parseuser.getcurrentuser().getstring("activityname"); number maxdistance = parseuser.getcurrentuser().getnumber( "maximum_distance"); string userlookinggender = parseuser.getcurrentuser().getstring( "looking_gender"); number minimumage = parseuser.getcurrentuser().getnumber("minimum_age"); number maximumage = parseuser.getcurrentuser().getnumber("maximum_age"); number userage = parseuser.getcurrentuser().getnumber("age"); @override public void onactivitycreated(bundle savedinstancestate) { super.onactivitycreated(savedinstancestate); setconversationslist(); } @override public view oncreateview(layoutinflater inflater, viewgroup container, bundle savedinstancestate) { view view = inflater.inflate(r.layout.fragment1_layout, container, false); return view; } private void setconversationslist() { currentuserid = parseuser.getcurrentuser().getobjectid(); names = new arraylist<string>(); age = new arraylist<string>(); headline = new arraylist<string>(); activityname = new arraylist<string>(); alprofilepicture = new arraylist<images>(); // string useractivityselectionname = null; parsequery<parseuser> query = parseuser.getquery(); // query.whereequalto("activityname",useractivityselectionname); query.wherenotequalto("objectid", parseuser.getcurrentuser() .getobjectid()); // users gender = currentuser.looking_gender query.whereequalto("gender", userlookinggender); // users looking_gender = currentuser.gender query.whereequalto("looking_gender", usergender); query.setlimit(1); query.whereequalto("activityname", activityname); // query.wheregreaterthanorequalto("age", minimumage); // query.wherelessthanorequalto("age", maximumage); query.orderbydescending("name"); log.d(constants.log, ""); parsequery<parseobject> queryo = parsequery.getquery("user"); queryo.wherenotequalto("objectid", parseuser.getcurrentuser() .getobjectid()); // users gender = currentuser.looking_gender queryo.whereequalto("gender", userlookinggender); // users looking_gender = currentuser.gender queryo.whereequalto("looking_gender", usergender); queryo.setlimit(1); queryo.whereequalto("activityname", activityname); // query.wheregreaterthanorequalto("age", minimumage); // query.wherelessthanorequalto("age", maximumage); queryo.orderbydescending("name"); queryo.findinbackground(new findcallback<parseobject>() { @override public void done(list<parseobject> object, parseexception e) { // todo auto-generated method stub parsefile image = object.getparsefile("profilepicture"); parseimageview imageview = (parseimageview) getview() .findviewbyid(r.id.profilepictureresult); // placeholder used before , during fetch, // replaced fetched image // data. imageview.setplaceholder(getresources().getdrawable( r.drawable.profile_pict)); imageview.setparsefile(image); imageview.loadinbackground(new getdatacallback() { @override public void done(byte[] data, parseexception e) { log.i("parseimageview", "fetched! data length: " + data.length + ", or exception: " + e.getmessage()); } }); } }); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> userlistname, parseexception e) { if (e == null) { (int = 0; < userlistname.size(); i++) { names.add(userlistname.get(i).get("name").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistname); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, names); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } public void done1(list<parseuser> userlistheadline, parseexception e) { if (e == null) { (int = 0; < userlistheadline.size(); i++) { headline.add(userlistheadline.get(i).get("headline") .tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistheadline); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_all, headline); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } public void done2(list<parseuser> userlistage, parseexception e) { if (e == null) { (int = 0; < userlistage.size(); i++) { age.add(userlistage.get(i).get("age").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistage); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, age); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } public void done3(list<parseuser> userlistactivity, parseexception e) { if (e == null) { (int = 0; < userlistactivity.size(); i++) { activityname.add(userlistactivity.get(i) .get("activityname").tostring()); } userslistview = (listview) getactivity().findviewbyid( r.id.userlistactivityname); namesarrayadapter = new arrayadapter<string>(getactivity() .getapplicationcontext(), r.layout.user_list_item, activityname); userslistview.setadapter(namesarrayadapter); userslistview .setonitemclicklistener(new adapterview.onitemclicklistener() { @override public void onitemclick(adapterview<?> a, view v, int i, long l) { openconversation(names, i); } }); } else { toast.maketext(getactivity().getapplicationcontext(), "error loading user list", toast.length_long) .show(); } } }); } public void openconversation(arraylist<string> names, int pos) { parsequery<parseuser> query = parseuser.getquery(); query.whereequalto("name", names.get(pos)); query.findinbackground(new findcallback<parseuser>() { public void done(list<parseuser> user, parseexception e) { if (e == null) { intent intent = new intent(getactivity() .getapplicationcontext(), messagingactivity.class); intent.putextra("recipient_id", user.get(0).getobjectid()); startactivity(intent); } else { toast.maketext(getactivity().getapplicationcontext(), "error finding user", toast.length_short) .show(); } } }); } }
Comments
Post a Comment