Я пытаюсь получить изображение, в основном изображение профиля пользователя. У меня уже есть сохранить изображение в таблице пользователей Тогда это мое приложениеParseQuery для возврата файла
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
mToolbar = (Toolbar) findViewById(R.id.toolbar);
setSupportActionBar(mToolbar);
navigationItemsList = new ArrayList<DrawerItem>();
addItemsToNavigationList();
mRecyclerView = (RecyclerView) findViewById(R.id.RecyclerView);
mRecyclerView.setHasFixedSize(true);
ParseUser userName = ParseUser.getCurrentUser();
HEADER_NAME = userName.getUsername();
HEADER_EMAIL = userName.getEmail();
mAdapter = new com.charity.dogood.dogood.adapters.NavDrawerAdapter(navigationItemsList, this, HEADER_NAME, HEADER_EMAIL, HEADER_IMAGE);
mRecyclerView.setAdapter(mAdapter);
//Parse Image and details of the logged in user
// Locate the class table named "ImageUpload" in Parse.com
ParseQuery<ParseObject> query = new ParseQuery("User");
Log.d("Mainactivity", "After query 1");
ParseUser currentUser = ParseUser.getCurrentUser();
Log.d("Mainactivity", "After query 2");
query.whereEqualTo("username", "bro");
Log.d("Mainactivity", "After query 3");
Log.d("Mainactivity", currentUser.getUsername());
// String usernam = (String)currentUser;
if(currentUser != null){
Log.d("Mainactivity", "came to current user check statement");
query.getInBackground("bro", new GetCallback<ParseObject>() {
@Override
public void done(ParseObject object, ParseException e) {
if (e == null) {
ParseFile fileObject = (ParseFile) object.getParseFile("ImageProfile");
fileObject.getDataInBackground(new GetDataCallback() {
@Override
public void done(byte[] bytes, ParseException e) {
if (e == null) {
Toast.makeText(MainActivity.this, "Welcome Back", Toast.LENGTH_LONG).show();
Bitmap bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
// HEADER_IMAGE image = (ImageView) fin
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(e.getMessage());
builder.setTitle("Sorry");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
} else {
AlertDialog.Builder builder = new AlertDialog.Builder(MainActivity.this);
builder.setMessage(e.getMessage());
builder.setTitle("Sorry");
builder.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialogInterface, int i) {
dialogInterface.dismiss();
}
});
AlertDialog dialog = builder.create();
dialog.show();
}
}
});
Log.d("Mainactivity", "After query 4");
}
Я могу получить имя пользователя и адрес электронной почты в моем ящике, как это, но не изображения,
для проверки, что я здесь, чтобы проверить объект null-ivty.
if (e == null) {
Я получаю это сообщение об ошибке
Привет, я уже делаю getInBackground справа? – JackyBoi
Был на моем телефоне при предоставлении ответа, просто сделал редактирование, надеюсь, что он более ясен. – cYrixmorten
Я думаю, что получаю то, что означает u, но каков запрос, чтобы получить изображение из столбца изображения? – JackyBoi