savenick_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
if (checker.equals("clicked")) {
ValidateControlers();
} else {
ValidateAndSaveOnlyInfo();
}
}
});
plusphoto.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
checker = "clicked";
CropImage.activity().setAspectRatio(1, 1).start(SettingaccActivity.this);
}
});
getUserInfo();
}
@Override
protected void onActivityResult(int requestCode, int resultCode, @Nullable Intent data) {
super.onActivityResult(requestCode, resultCode, data);
if (requestCode == CropImage.CROP_IMAGE_ACTIVITY_REQUEST_CODE && resultCode == RESULT_OK && data != null) {
CropImage.ActivityResult result = CropImage.getActivityResult(data);
imageUri = result.getUri();
imageprof.setImageURI(imageUri);
} else {
Toast.makeText(this, "Произошла ошибка", Toast.LENGTH_SHORT).show();
}
}
private void ValidateControlers() {
if (TextUtils.isEmpty(nick_edit.getText().toString()))
Toast.makeText(this, "Введите ние", Toast.LENGTH_SHORT).show();
}
else if( checker.equals("clicked"))
{
uploadProfilImage();
}
private void uploadProfilImage() {
final ProgressDialog progressDialog=new ProgressDialog(this);
progressDialog.setTitle("Идет загрузка");
progressDialog.setMessage("Пожалуйста подождите");
progressDialog.show();
if (imageUri !=null){
final StorageReference fileRef= storageprofilpicsRef.child(mAuth.getCurrentUser().getUid()+"jpg");
uploadTask=fileRef.putFile(imageUri);
uploadTask.continueWithTask(new Continuation() {
@Override
public Object then(@NonNull Task task) throws Exception {
if (!task.isSuccessful()){
throw task.getException();
}
return fileRef.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task <Uri>task) {
if (task.isSuccessful()){
Uri downloadUri=task.getResult();
myUri=downloadUri.toString();
HashMap<String,Object> userMap=new HashMap<>();
userMap.put("uid",mAuth.getCurrentUser().getUid());
userMap.put("name",nick_edit.getText().toString());
userMap.put("image",myUri);
databaseReference.child(mAuth.getCurrentUser().getUid()).updateChildren(userMap);
progressDialog.dismiss();
startActivity(new Intent(SettingaccActivity.this,HomeActivity.class));
}
}
});
}
else {
Toast.makeText(this, "Изображение не выбрано", Toast.LENGTH_SHORT).show();
}
}
private void ValidateAndSaveOnlyInfo() {
if (TextUtils.isEmpty(nick_edit.getText().toString()))
Toast.makeText(this, "Введите ние", Toast.LENGTH_SHORT).show();
}
else{
HashMap<String,Object> userMap=new HashMap<>();
userMap.put("uid",mAuth.getCurrentUser().getUid());
userMap.put("name",nick_edit.getText().toString());
databaseReference.child(mAuth.getCurrentUser().getUid()).updateChildren(userMap);
startActivity(new Intent(SettingaccActivity.this,HomeActivity.class));
}
private void getUserInfo() {
databaseReference.child(mAuth.getCurrentUser().getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot snapshot) {
if (snapshot.exists()&&snapshot.getChildrenCount()>0)
{
String name=snapshot.child("name").getValue().toString();
nick_edit.setText(name);
if (snapshot.hasChild("image")) {
String image = snapshot.child("image").getValue().toString();
Picasso.get().load(image).into(imageprof);
}
}
}
@Override
public void onCancelled(@NonNull DatabaseError error) {
}
});
}
Здесь ошибка в else if(checker.equals("clicked"))
Cannot resolve symbol equals
И с последним else unexpected token