java - The method done(ParseObject, ParseException) from the type new FindCallback<ParseUser>(){} is never used locally -
below error getting:
the method done(parseobject, parseexception) type new findcallback<parseuser>(){} never used locally
from line
public void done(parseobject object,parseexception e) {
i not sure if section of code wrongly placed in code, have added multiple log messages , realized skips entire section of code. below section:
public void done(parseobject object,parseexception e) { log.d(constants.log, "pardeobject"); parsequery<parseobject> query = parsequery.getquery("user"); query.getfirstinbackground(new getcallback<parseobject>() { public void done(parseobject object, parseexception e) { if (object != null) { log.d(constants.log, "object != null"); parsefile file = (parsefile)object.get("profilepicture"); file.getdatainbackground(new getdatacallback() { public void done(byte[] data, parseexception e) { if (e == null) { bitmap bitmap = bitmapfactory.decodebytearray(data, 0, data.length); //use bitmap want imageview profileimage =(imageview) getview().findviewbyid(r.id.profilepictureresult); // set bitmap // imageview profileimage.setimagebitmap(bitmap); log.d(constants.log, "works"); } else { // went wrong log.d(constants.log, "error else"); } } }); } else { // toast.maketext(getapplicationcontext(), "exception", toast.length_short) .show(); log.e("error 2", e.getmessage()); e.printstacktrace(); } } }); }
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, "after query criteria set"); query.findinbackground(new findcallback<parseuser>() { public void done(parseobject object,parseexception e) { log.d(constants.log, "pardeobject"); parsequery<parseobject> query = parsequery.getquery("user"); query.getfirstinbackground(new getcallback<parseobject>() { public void done(parseobject object, parseexception e) { if (object != null) { log.d(constants.log, "object != null"); parsefile file = (parsefile)object.get("profilepicture"); file.getdatainbackground(new getdatacallback() { public void done(byte[] data, parseexception e) { if (e == null) { bitmap bitmap = bitmapfactory.decodebytearray(data, 0, data.length); //use bitmap want imageview profileimage =(imageview) getview().findviewbyid(r.id.profilepictureresult); // set bitmap // imageview profileimage.setimagebitmap(bitmap); log.d(constants.log, "works"); } else { // went wrong log.d(constants.log, "error else"); } } }); } else { // toast.maketext(getapplicationcontext(), "exception", toast.length_short) .show(); log.e("error 2", e.getmessage()); e.printstacktrace(); } } }); } 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
update
query.findinbackground(new findcallback<parseuser>() { public void done(parseobject object,parseexception e) { log.d(constants.log, "pardeobject"); 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()); } }); }
update
i having issue troubleshooting below: object cannot resolved
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"); query.findinbackground(new findcallback<parseuser>() { @override public void done(list<parseuser> users,parseexception e) { // whatever need extract object "users" 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(); } } }); } }
as below
the method done2(list<parseuser>, parseexception) type new findcallback<parseuser>(){} never used locally
your class anonymous implementation of findcallback
interface, contain following signature :
public abstract void done(list<t> objects, parseexception e)
your method not match signature, not used (and can't used) in program.
if code compiles correctly, mean above method has been defined. check did not mix both methods.
base on update code, here should write (but basic java. if don't understand it, suggest learning langage before trying go further. here tutorial must read , understand : http://docs.oracle.com/javase/tutorial/java/javaoo/anonymousclasses.html)
query.findinbackground(new findcallback<parseuser>() { @override public void done(list<parseuser> users,parseexception e) { // whatever need extract object "users" // ... }
by way, important note won't allowed manipulate ui objects (like parseimageview r.id.profilepictureresult directly in method, because must done in ui thread. must use handler this. separate problem 1 submitted here, next one. when there, read https://developer.android.com/training/multiple-threads/communicate-ui.html
Comments
Post a Comment