Hello guys,
I am facing this problem for half a day and I don't know the solution,a bit more and I am going crazy.
I am trying to build instegram clone.Everytime I press on a name ,it should show me the images that the user uploaded, but I am facing a weird problem with parse.
So I have 4 activities ,the last one should recieve the image that the user uploaded. However,parse isn't find the image of the user,but it finds the user name just fine.
This is how my data looks like:
https://pasteboard.co/JvBOWAr.png
and this is my code:
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
linearLayout = findViewById(R.id.mLinearLayout);
Intent intent = getIntent();
String username = intent.getStringExtra("username");
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Image");
query.whereEqualTo("username", username);
query.orderByDescending("createdAt");
query.findInBackground(new FindCallback<ParseObject>() {
@override
public void done(List<ParseObject> objects, ParseException e) {
if (e == null && objects.size() > 0) {
for (ParseObject object : objects) {
ParseFile file = (ParseFile) object.get("image");
file.getDataInBackground(new GetDataCallback() {
@override
public void done(byte[] data, ParseException e) {
if (e == null && data != null) {
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0,data.length);
ImageView imageView = new ImageView(getApplicationContext());
imageView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
imageView.setImageBitmap(bitmap);
linearLayout.addView(imageView);
}
}
});
}
}
else{
Log.e("NO OBJECTS FOUND","NO OBJECTS FOUND");
}
}
});
}
I am getting the log "No objects found" and no picture is showing.
However,when I am deleting this line:
query.whereEqualTo("username", username);
I get random picture that the users uploaded,and everyime I press another profile,I get another random picture of a user.
Thanks for all the helpers..
I am facing this problem for half a day and I don't know the solution,a bit more and I am going crazy.
I am trying to build instegram clone.Everytime I press on a name ,it should show me the images that the user uploaded, but I am facing a weird problem with parse.
So I have 4 activities ,the last one should recieve the image that the user uploaded. However,parse isn't find the image of the user,but it finds the user name just fine.
This is how my data looks like:
https://pasteboard.co/JvBOWAr.png
and this is my code:
@override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_user_profile);
linearLayout = findViewById(R.id.mLinearLayout);
Intent intent = getIntent();
String username = intent.getStringExtra("username");
ParseQuery<ParseObject> query = new ParseQuery<ParseObject>("Image");
query.whereEqualTo("username", username);
query.orderByDescending("createdAt");
query.findInBackground(new FindCallback<ParseObject>() {
@override
public void done(List<ParseObject> objects, ParseException e) {
if (e == null && objects.size() > 0) {
for (ParseObject object : objects) {
ParseFile file = (ParseFile) object.get("image");
file.getDataInBackground(new GetDataCallback() {
@override
public void done(byte[] data, ParseException e) {
if (e == null && data != null) {
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0,data.length);
ImageView imageView = new ImageView(getApplicationContext());
imageView.setLayoutParams(new ViewGroup.LayoutParams(
ViewGroup.LayoutParams.MATCH_PARENT,
ViewGroup.LayoutParams.WRAP_CONTENT
));
imageView.setImageBitmap(bitmap);
linearLayout.addView(imageView);
}
}
});
}
}
else{
Log.e("NO OBJECTS FOUND","NO OBJECTS FOUND");
}
}
});
}
I am getting the log "No objects found" and no picture is showing.
However,when I am deleting this line:
query.whereEqualTo("username", username);
I get random picture that the users uploaded,and everyime I press another profile,I get another random picture of a user.
Thanks for all the helpers..