- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
下面是我遇到的错误:
The method done(ParseObject, ParseException) from the type new FindCallback<ParseUser>(){} is never used locally
来自行
public void done(ParseObject object,ParseException e) {
我不确定这部分代码是否被错误地放置在代码中,但我添加了多条日志消息,然后我意识到它跳过了这整段代码。以下是部分:
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 this bitmap as you want
ImageView profileimage =(ImageView) getView().findViewById(R.id.profilePictureResult);
// Set the Bitmap into the
// ImageView
profileimage.setImageBitmap(bitmap);
Log.d(Constants.LOG, "works");
} else {
// something 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 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 with Gender = currentUser.Looking_Gender
query.whereEqualTo("Gender", userLookingGender);
// users with 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 this bitmap as you want
ImageView profileimage =(ImageView) getView().findViewById(R.id.profilePictureResult);
// Set the Bitmap into the
// ImageView
profileimage.setImageBitmap(bitmap);
Log.d(Constants.LOG, "works");
} else {
// something 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) {
for (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 that user",
Toast.LENGTH_SHORT).show();
}
}
});
}
}
提前致谢
更新
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);
// The placeholder will be used before and during the fetch, to be replaced by the 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());
}
});
}
更新
我在解决以下问题时遇到问题:无法解析对象
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 with Gender = currentUser.Looking_Gender
query.whereEqualTo("Gender", userLookingGender);
// users with 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 with Gender = currentUser.Looking_Gender
queryo.whereEqualTo("Gender", userLookingGender);
// users with 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) {
// Do whatever you need to extract object from "users"
ParseFile image = object.getParseFile("ProfilePicture");
ParseImageView imageView = (ParseImageView) getView().findViewById(R.id.profilePictureResult);
// The placeholder will be used before and during the fetch, to be replaced by the 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) {
for (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 done1(List<ParseUser> userlistheadline, ParseException e) {
if (e == null) {
for (int i = 0; i < 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) {
for (int i = 0; i < 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) {
for (int i = 0; i < 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 that user", Toast.LENGTH_SHORT)
.show();
}
}
});
}
}
以及以下内容
The method done2(List<ParseUser>, ParseException) from the type new FindCallback<ParseUser>(){} is never used locally
最佳答案
您的类是 FindCallback
接口(interface)的匿名实现,它包含以下签名:
public abstract void done(List<T> objects,
ParseException e)
您的方法与此签名不匹配,因此未在您的程序中使用(也不能使用)。
如果你的代码编译正确,也说明上面的方法已经定义好了。检查您是否没有混合使用这两种方法。
根据您的更新代码,这是您应该编写的内容(但这是基本的 Java。如果您不理解它,我建议您在尝试进一步学习之前学习该语言。这是您必须阅读的教程并理解:http://docs.oracle.com/javase/tutorial/java/javaOO/anonymousclasses.html )
query.findInBackground(new FindCallback<ParseUser>() {
@Override
public void done(List<ParseUser> users,ParseException e) {
// Do whatever you need to extract object from "users"
// ...
}
顺便说一下,一个重要的注意事项是您将不允许直接在此方法中操作 UI 对象(例如您的 ParseImageView R.id.profilePictureResult,因为这必须在 UI 线程中完成。因此您必须使用这个处理程序。这是一个与您在此处提交的问题不同的问题,但这将是您的下一个问题。当您在那里时,只需阅读 https://developer.android.com/training/multiple-threads/communicate-ui.html
关于java - 来自类型 new FindCallback<ParseUser>(){} 的方法 done(ParseObject, ParseException) 从不在本地使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25354253/
关闭。这个问题需要details or clarity .它目前不接受答案。 想改进这个问题吗? 通过 editing this post 添加细节并澄清问题. 关闭 6 年前。 Improve t
notificationCenterPublisher = NotificationCenter.default .publisher(for: .NSManagedObjec
我有以下 Rust 代码: #[inline(never)] fn x() -> i32 { 21 } pub fn main() -> i32 { x() } 如果没有优化 (-C
notificationCenterPublisher = NotificationCenter.default .publisher(for: .NSManagedObjec
我有以下 Rust 代码: #[inline(never)] fn x() -> i32 { 21 } pub fn main() -> i32 { x() } 如果没有优化 (-C
假设我的 ASPX 页面没有内联 C# 代码块。 所以,我可以安全地设置 ...在我的 web.config 文件中,不用担心编译错误。 就性能而言,使用以下设置是否会有任何损失? 即“自动”检测
应用程序.js var win1 = Titanium.UI.createWindow({ title:'Tab 1', backgroundColor: 'black', l
基本上,我正在为实现多级优先级队列的 xv6 内核实现一个调度程序。我有一个严重的问题,我不明白,我类(class)的助教不明白,我已经错过了这个项目的最后期限,所以现在帮助我不会给我任何加分 - 但
我想避免 git 自动 merge 我的 composer.json。这样我就可以在 develop 分支中有一个使用 dev-develop 包的 composer.json,而 master 中的
当比较两种不同的算法实现时(因此,不关心它们的绝对性能,而只关心相对性能)我是否最好强制 Java 只运行解释代码? 也就是说,打开 -Xint 标志会更好吗? 最佳答案 我不认为禁用 JIT 会更好
class A{ const size_t number; public: A(size_t number): number(number) {} void f(){
问题 寻找在以下之间切换的方法: 总是 从不 仅在静默模式下 仅当不处于静默模式时 这些选项在手机上的路径---菜单>>设置>>声音>>振动---找到。 通过手机导航很容易更改(顺便说一句,我的手机是
如何设置电源设置关闭:从不(关闭显示器=从不,让计算机进入休眠状态=从不),通过c#代码 最佳答案 这个问题中给出的链接可以告诉你一个方法。 Programmatically change Windo
我是一名优秀的程序员,十分优秀!