use of com.example.alphatour.oggetti.ElementString in project AlphaTour by Frank99DG.
the class CreateConstraintsWizard method savePhoto.
private void savePhoto(Uri photo, Element element, int i, long id) {
final StorageReference fileRef = storegeProfilePick.child("PhotoObjects").child("Photo_Objects" + "_" + id);
uploadTask = fileRef.putFile(photo);
Task<Uri> urlTask = uploadTask.continueWithTask(new Continuation<UploadTask.TaskSnapshot, Task<Uri>>() {
@Override
public Task<Uri> then(@NonNull Task<UploadTask.TaskSnapshot> task) throws Exception {
if (!task.isSuccessful()) {
throw task.getException();
}
// Continue with the task to get the download URL
return fileRef.getDownloadUrl();
}
}).addOnCompleteListener(new OnCompleteListener<Uri>() {
@Override
public void onComplete(@NonNull Task<Uri> task) {
if (task.isSuccessful()) {
Uri downloadUrl = task.getResult();
uriUploadPhoto.add(downloadUrl.toString());
// elm.put("Photo", uriUploadPhoto);
db.collection("Elements").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if (!queryDocumentSnapshots.isEmpty()) {
// lista zone
List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : listDocument) {
ElementString elme = d.toObject(ElementString.class);
if (elme.getTitle().matches(element.getTitle())) {
HashMap<String, Object> userMap = new HashMap<>();
userMap.put("photo", uriUploadPhoto.get(i));
db.collection("Elements").document(d.getId()).update("photo", uriUploadPhoto.get(i)).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
success = true;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
success = false;
Toast.makeText(getContext(), "Non è stato possibile salvare le zone e gli oggetti creati!!!", Toast.LENGTH_LONG).show();
loadingBar.setVisibility(View.GONE);
}
});
}
}
}
}
});
} else {
// Handle failures
// ...
}
}
});
}
use of com.example.alphatour.oggetti.ElementString in project AlphaTour by Frank99DG.
the class Step3 method setUserVisibleHint.
@Override
public void setUserVisibleHint(boolean isVisibleToUser) {
super.setUserVisibleHint(isVisibleToUser);
if (isVisibleToUser) {
zone_selected.setText(DashboardActivity.getZona_scelta());
String scelta = DashboardActivity.getZona_scelta();
db.collection("Zones").whereEqualTo("name", scelta).get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
String idZone = document.getId();
db.collection("Elements").whereEqualTo("idZone", idZone).get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot document : task.getResult()) {
ElementString element = document.toObject(ElementString.class);
View object = getLayoutInflater().inflate(R.layout.row_selection_zones_elements, null, false);
CheckableTextView textZone1 = (CheckableTextView) object.findViewById(R.id.textObjectss);
textZone1.setText(element.getTitle());
arrayStringElement.add(element.getTitle());
// arrayObjectElement.add(element);
arrayMonumenti.add(textZone1);
delete_view.add(object);
list_object.addView(object);
}
} else {
Toast.makeText(getContext(), "Non è stato possibile caricare le zone !!!", Toast.LENGTH_LONG).show();
}
}
});
}
} else {
Toast.makeText(getContext(), "Non è stato possibile caricare le zone !!!", Toast.LENGTH_LONG).show();
}
}
});
} else {
}
}
use of com.example.alphatour.oggetti.ElementString in project AlphaTour by Frank99DG.
the class FileReceiverActivity method saveQrCode.
private void saveQrCode(String dataQr, Element element, int i, long id) {
GenerateQrCodeClass generateQrCodeClass = new GenerateQrCodeClass(FileReceiverActivity.this);
Bitmap qrCode = generateQrCodeClass.generateQrCode(dataQr);
final StorageReference fileRef = storegeProfilePick.child("QrCodeObjects").child("QrCode_Objects" + "_" + id);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
qrCode.compress(Bitmap.CompressFormat.JPEG, 100, baos);
byte[] data = baos.toByteArray();
UploadTask uploadTask = fileRef.putBytes(data);
uploadTask.addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception exception) {
// Handle unsuccessful uploads
}
}).addOnSuccessListener(new OnSuccessListener<UploadTask.TaskSnapshot>() {
@Override
public void onSuccess(UploadTask.TaskSnapshot taskSnapshot) {
// taskSnapshot.getMetadata() contains file metadata such as size, content-type, and download URL.
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() {
@Override
public void onComplete(@NonNull Task task) {
if (task.isSuccessful()) {
// scarico il link di Storage dell'immagine
Uri downloadUrl = (Uri) task.getResult();
uriUploadQrCode.add(downloadUrl.toString());
db.collection("Elements").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if (!queryDocumentSnapshots.isEmpty()) {
// lista zone
List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : listDocument) {
ElementString elme = d.toObject(ElementString.class);
if (elme.getTitle().matches(element.getTitle())) {
HashMap<String, Object> userMap = new HashMap<>();
userMap.put("qrCode", uriUploadQrCode.get(i));
db.collection("Elements").document(d.getId()).update("qrCode", uriUploadQrCode.get(i)).addOnSuccessListener(new OnSuccessListener<Void>() {
@Override
public void onSuccess(Void unused) {
success = true;
Toast.makeText(FileReceiverActivity.this, "Zone e Oggetti creati con successo", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
success = false;
Toast.makeText(FileReceiverActivity.this, "Non è stato possibile salvare le zone e gli oggetti creati!!!", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
}
});
}
}
}
}
});
}
}
});
}
});
}
Aggregations