use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class ModifyZoneActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_modify_zone);
db = FirebaseFirestore.getInstance();
auth = FirebaseAuth.getInstance();
user = auth.getCurrentUser();
idUser = user.getUid();
Intent intent = getIntent();
Place = intent.getStringExtra("Place");
idPlace = intent.getStringExtra("idPlace");
Zone = intent.getStringExtra("Zone");
getIdZone(Zone);
dashboardFlag = intent.getStringExtra("dashboardFlag");
// settaggio Place se si arriva da dashboard
if (dashboardFlag.equals("1")) {
getPlace(idPlace);
}
zoneText = findViewById(R.id.myZoneText);
nameZone = findViewById(R.id.updateNameZone);
loadingBar = findViewById(R.id.modifyZoneLoadingBar);
db.collection("Zones").whereEqualTo("idPlace", idPlace).get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if (!queryDocumentSnapshots.isEmpty()) {
List<DocumentSnapshot> listDocuments = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : listDocuments) {
Zone zone = d.toObject(Zone.class);
if (Zone.equals(zone.getName())) {
zoneText.setText(zone.getName());
nameZone.setText(zone.getName());
break;
}
}
}
}
});
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class CreateConstraintsWizard method saveObjects.
/*public boolean inputControl(String Prova){
Boolean errorFlag = false;
if (Prova.isEmpty()) {
prova.setError(getString(R.string.campo_obbligatorio));
prova.requestFocus();
errorFlag = true;
}
return errorFlag;
}*/
private void saveObjects(List<Element> elementlist) {
db.collection("Zones").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (int i = 0; i < elementlist.size(); i++) {
for (QueryDocumentSnapshot document : task.getResult()) {
Element newElement = elementlist.get(i);
Zone zon = document.toObject(Zone.class);
if (zon.getName().matches(newElement.getZoneRif())) {
newElement.setIdZone(document.getId());
id = generateidPhotoAndQrCode();
elm.put("idZone", newElement.getIdZone());
elm.put("title", newElement.getTitle());
elm.put("description", newElement.getDescription());
elm.put("photo", null);
elm.put("qrCode", null);
elm.put("idPhotoAndQrCode", id);
elm.put("idUser", user.getUid());
elm.put("qrData", newElement.getQrData());
db.collection("Elements").add(elm).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
success = true;
// String id=documentReference.getId();
}
});
savePhoto(newElement.getPhoto(), newElement, i, id);
saveQrCode(newElement.getQrCode(), newElement, i, id);
}
}
}
}
}
}).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();
}
});
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class Step2 method getZones.
public void getZones() {
loadingbar.setVisibility(View.VISIBLE);
if (!receiver.isConnected()) {
}
db.collection("Zones").whereEqualTo("idUser", user.getUid()).get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if (!queryDocumentSnapshots.isEmpty()) {
// lista zone
List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
if (!DashboardActivity.isFirstZoneChosen()) {
for (DocumentSnapshot d : listDocument) {
Zone zone = d.toObject(Zone.class);
if (idPlace.matches(zone.getIdPlace())) {
View zoneView = getLayoutInflater().inflate(R.layout.row_selection_zones_elements, null, false);
CheckableTextView textZone1 = (CheckableTextView) zoneView.findViewById(R.id.textObjectss);
textZone1.setText(zone.getName());
array_database.add(zone.getName());
arrayZone.add(textZone1);
list_zone.addView(zoneView);
deleteView.add(zoneView);
}
}
for (i = 0; i < arrayZone.size(); i++) {
arrayZone.get(i).setOnCheckChangeListener(new CheckedListener() {
@Override
public void onCheckChange(@NonNull View view, boolean b) {
// contatore per capire quando ne seleziona 2
int c = 0;
for (int a = 0; a < arrayZone.size(); a++) {
// ciclo per contare quanti sono checkati
if (arrayZone.get(a).isChecked()) {
c++;
}
}
for (int j = 0; j < arrayZone.size(); j++) {
// se è checkato più di uno, il precedente che è checkato viene impostato a false
if (c > 1) {
if (n == j) {
arrayZone.get(j).setChecked(false, false);
}
}
}
for (int k = 0; k < arrayZone.size(); k++) {
// serve per tenere la posizione dell'ultimo checkato
if (arrayZone.get(k).isChecked()) {
n = k;
continue;
}
}
}
});
}
} else {
db.collection("Constraints").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
List<DocumentSnapshot> listConstraint = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : listConstraint) {
Constraint constraint = d.toObject(Constraint.class);
String zona;
if (PercorsoWizard.isZonePassFromReview()) {
zona = PercorsoWizard.getZone();
DashboardActivity.setZona_vecchia(zona);
DashboardActivity.setZona_scelta(zona);
} else {
zona = DashboardActivity.getZona_scelta();
DashboardActivity.setZona_vecchia(zona);
}
if (constraint.getFromZone().matches(zona)) {
View zone = getLayoutInflater().inflate(R.layout.row_selection_zones_elements, null, false);
CheckableTextView textZone1 = (CheckableTextView) zone.findViewById(R.id.textObjectss);
textZone1.setText(constraint.getInZone());
array_database.add(constraint.getInZone());
arrayZone.add(textZone1);
list_zone.addView(zone);
deleteView.add(zone);
}
}
PercorsoWizard.setZonePassFromReview(false);
for (i = 0; i < arrayZone.size(); i++) {
arrayZone.get(i).setOnCheckChangeListener(new CheckedListener() {
@Override
public void onCheckChange(@NonNull View view, boolean b) {
// contatore per capire quando ne seleziona 2
int c = 0;
for (int a = 0; a < arrayZone.size(); a++) {
// ciclo per contare quanti sono checkati
if (arrayZone.get(a).isChecked()) {
c++;
}
}
for (int j = 0; j < arrayZone.size(); j++) {
// se è checkato più di uno, il precedente che è checkato viene impostato a false
if (c > 1) {
if (n == j) {
arrayZone.get(j).setChecked(false, false);
}
}
}
for (int k = 0; k < arrayZone.size(); k++) {
// serve per tenere la posizione dell'ultimo checkato
if (arrayZone.get(k).isChecked()) {
n = k;
continue;
}
}
}
});
}
}
});
}
loadingbar.setVisibility(View.GONE);
}
}
});
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class FileReceiverActivity method saveZones.
private void saveZones(List<Zone> zone_list, int idPlac) {
for (i = 0; i < zone_list.size(); i++) {
if (listZone.get(i).getIdPl() == idPlac) {
Zone zone = new Zone(zone_list.get(i).getName(), this.idPlace, null, user.getUid());
db.collection("Zones").add(zone).addOnSuccessListener(new OnSuccessListener<DocumentReference>() {
@Override
public void onSuccess(DocumentReference documentReference) {
if (i == zone_list.size() && flag1 == false) {
flag1 = true;
saveObjects(listElement);
}
success = true;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(FileReceiverActivity.this, "Salvataggio Zone non riuscito", Toast.LENGTH_LONG).show();
}
});
}
}
}
Aggregations