use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class CreateConstraintsWizard method saveZonesAndConstraintInGraph.
public void saveZonesAndConstraintInGraph() {
Graph<Zone, DefaultEdge> zones = new SimpleDirectedGraph<>(DefaultEdge.class);
for (String nameZone : zone_list) {
Zone zone = new Zone(nameZone);
zones.addVertex(zone);
}
/*for (List list : all_link_lists){
for (String : list){
zones.addEdge( , );
}
}*/
Place place = new Place("NewTopMuseum", "Bari", "Museo", "1");
Log.i("Luogo creato:", place.toString());
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class CreateConstraintsWizard method saveZones.
private void saveZones(ArrayList<String> zone_list) {
for (i = 0; i < zone_list.size(); i++) {
Zone zone = new Zone(zone_list.get(i), 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) {
saveConstraints();
flag1 = true;
}
success = true;
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(@NonNull Exception e) {
Toast.makeText(getContext(), "Salvataggio Zone non riuscito", Toast.LENGTH_LONG).show();
}
});
}
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class FileReceiverActivity method saveObjects.
private void saveObjects(List<Element> elmlist) {
db.collection("Zones").get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
for (int i = 0; i < elmlist.size(); i++) {
for (QueryDocumentSnapshot document : task.getResult()) {
Element newElement = elmlist.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", newElement.getPhoto().toString());
elm.put("qrCode", null);
elm.put("idPhotoAndQrCode", Long.parseLong(newElement.getIdPhotoAndQrCodeString()));
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();
}
});
saveQrCode(newElement.getQrData(), newElement, i, id);
}
}
}
}
}
}).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();
}
});
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class FileReceiverActivity method readCsv.
private void readCsv(Intent data) {
if (data == null) {
return;
} else {
Uri uri = data.getParcelableExtra(Intent.EXTRA_STREAM);
Toast.makeText(FileReceiverActivity.this, uri.getPath(), Toast.LENGTH_SHORT).show();
String path = uri.getPath();
String filename = URLUtil.guessFileName(path, null, null);
String downloadPath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getAbsolutePath();
path = path.substring(path.lastIndexOf('/') + 1);
File file = new File(downloadPath, filename);
try {
BufferedReader read = new BufferedReader(new FileReader(file));
String line = "";
Boolean isEmpty = true;
while ((line = read.readLine()) != null) {
isEmpty = false;
String[] token = line.split(",");
ReadCsv readCsv = new ReadCsv();
boolean flag = false;
for (int i = 0; i < token.length; i++) {
if (token[i] == null) {
flag = true;
}
}
if (!flag) {
if (!token[0].matches("namePlace")) {
Element elm = new Element();
Place place = new Place();
Zone zone = new Zone();
Constraint constraint = new Constraint();
if (listLineCsv.size() > 0) {
setDataToken(token, readCsv);
if (!token[0].isEmpty()) {
for (int i = 0; i < listPlace.size(); i++) {
if (!listPlace.get(i).getName().matches(token[0]) && !listPlace.get(i).getCity().matches(token[1]) && !listPlace.get(i).getTypology().matches(token[2])) {
idP++;
place.setIdPlace(idP);
place.setName(token[0]);
place.setCity(token[1]);
place.setTypology(token[2]);
listPlace.add(place);
}
}
for (int j = 0; j < listPlace.size(); j++) {
if (!listZone.get(i).getName().matches(token[3])) {
zone.setIdPl(idP);
zone.setName(token[3]);
idZ++;
listZone.add(zone);
}
}
elm.setIdZon(idZ);
elm.setTitle(readCsv.getTitleObject());
elm.setDescription(readCsv.getDescriptionObject());
elm.setQrData(readCsv.getQrDataObject());
elm.setPhoto(Uri.parse(readCsv.getLinkImageObject()));
String[] str = readCsv.getLinkImageObject().split("Objects_");
String[] st = str[1].split("\\?");
String idPh = st[0];
elm.setIdPhotoAndQrCodeString(idPh);
elm.setZoneRif(token[3]);
if (!token[8].isEmpty() && !!token[9].isEmpty()) {
constraint.setFromZone(token[8]);
constraint.setInZone(token[9]);
}
listElement.add(elm);
if (!token[8].isEmpty() && !token[9].isEmpty()) {
constraint.setFromZone(token[8]);
constraint.setInZone(token[9]);
listConstranints.add(constraint);
}
}
} else {
setDataToken(token, readCsv);
if (!token[0].isEmpty()) {
elm.setTitle(readCsv.getTitleObject());
elm.setDescription(readCsv.getDescriptionObject());
elm.setQrData(readCsv.getQrDataObject());
elm.setPhoto(Uri.parse(readCsv.getLinkImageObject()));
String[] str = readCsv.getLinkImageObject().split("Objects_");
String[] st = str[1].split("\\?");
String idPh = st[0];
elm.setIdPhotoAndQrCodeString(idPh);
elm.setZoneRif(token[3]);
place.setName(token[0]);
place.setCity(token[1]);
place.setTypology(token[2]);
place.setIdPlace(idP);
zone.setIdPl(idP);
zone.setName(token[3]);
elm.setIdZon(idZ);
listPlace.add(place);
listZone.add(zone);
listElement.add(elm);
}
if (!token[8].isEmpty() && !token[9].isEmpty()) {
constraint.setFromZone(token[8]);
constraint.setInZone(token[9]);
listConstranints.add(constraint);
}
}
}
} else {
Toast.makeText(FileReceiverActivity.this, "Errore duratnte l'importazione del file, alcuni" + "campi potrebbero essere vuoti", Toast.LENGTH_LONG).show();
line = null;
}
}
if (isEmpty) {
Toast.makeText(FileReceiverActivity.this, "Errore duratnte l'importazione del file, alcuni" + "campi potrebbero essere vuoti", Toast.LENGTH_LONG).show();
} else {
savePlace();
saveConstraints();
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
if (success) {
Intent intent = new Intent(FileReceiverActivity.this, DashboardActivity.class);
startActivity(intent);
progressBar.setVisibility(View.GONE);
} else {
Toast.makeText(FileReceiverActivity.this, "Salvataggio Luogo non riuscito", Toast.LENGTH_LONG).show();
progressBar.setVisibility(View.GONE);
}
}
}, 2000L);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
use of com.example.alphatour.oggetti.Zone in project AlphaTour by Frank99DG.
the class DashboardActivity method inputSearchClick.
private void inputSearchClick() {
inputSearch.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TourItem clickedItem = (TourItem) parent.getItemAtPosition(position);
String clickedTourText = clickedItem.getTourText();
db.collection("Elements").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if (!queryDocumentSnapshots.isEmpty()) {
// lista elementi
List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : listDocument) {
ElementString element = d.toObject(ElementString.class);
if (clickedTourText.equals(element.getTitle())) {
Intent intent = new Intent(DashboardActivity.this, ModifyObjectActivity.class);
intent.putExtra("data", element.getQrData());
String dashboardFlag = "1";
intent.putExtra("dashboardFlag", dashboardFlag);
startActivity(intent);
inputSearch.setText(null);
break;
}
}
}
}
});
db.collection("Zones").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) {
Zone zone = d.toObject(Zone.class);
if (clickedTourText.equals(zone.getName())) {
Intent intent = new Intent(DashboardActivity.this, ModifyZoneActivity.class);
intent.putExtra("idPlace", zone.getIdPlace());
intent.putExtra("Zone", zone.getName());
String dashboardFlag = "1";
intent.putExtra("dashboardFlag", dashboardFlag);
startActivity(intent);
inputSearch.setText(null);
break;
}
}
}
}
});
db.collection("Places").get().addOnSuccessListener(new OnSuccessListener<QuerySnapshot>() {
@Override
public void onSuccess(QuerySnapshot queryDocumentSnapshots) {
if (!queryDocumentSnapshots.isEmpty()) {
// lista luoghi
List<DocumentSnapshot> listDocument = queryDocumentSnapshots.getDocuments();
for (DocumentSnapshot d : listDocument) {
Place place = d.toObject(Place.class);
if (clickedTourText.equals(place.getName())) {
Intent intent = new Intent(DashboardActivity.this, ModifyPlaceActivity.class);
intent.putExtra("Place", place.getName());
String dashboardFlag = "1";
intent.putExtra("dashboardFlag", dashboardFlag);
startActivity(intent);
inputSearch.setText(null);
break;
}
}
}
}
});
}
});
}
Aggregations