use of com.example.alphatour.oggetti.ZoneChoosed in project AlphaTour by Frank99DG.
the class CreateJsonActivity method bottomAppBarPathClick.
public void bottomAppBarPathClick() {
home_path_button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
moveToDashboard();
finishAffinity();
overridePendingTransition(0, 0);
}
});
bottomAppBarPath.setOnMenuItemClickListener(new Toolbar.OnMenuItemClickListener() {
@Override
public boolean onMenuItemClick(MenuItem item) {
switch(item.getItemId()) {
case R.id.download_path:
Graph<ZoneChoosed, DefaultEdge> graph = Step4.getGraph();
JSONExporter<ZoneChoosed, DefaultEdge> exporter = new JSONExporter<>(v -> String.valueOf(v));
exporter.setEdgeIdProvider(new IntegerIdProvider<>(1));
// ByteArrayOutputStream os = new ByteArrayOutputStream();
File file = null;
try {
File fil = new File(Environment.getExternalStorageDirectory().getAbsolutePath(), "Percorso.json");
FileOutputStream fos = new FileOutputStream(fil);
// file = File.createTempFile("Percorso",".json");
exporter.exportGraph(graph, fos);
fos.close();
Toast.makeText(CreateJsonActivity.this, "Saved to " + getFilesDir() + "/" + "Percorso.json", Toast.LENGTH_LONG).show();
} catch (IOException e) {
e.printStackTrace();
}
return true;
case R.id.share_path:
Context context = CreateJsonActivity.this;
String str = "{ \"zona\": \"medioevo\",\n" + " \"oggetto\": \"oggetto1\",\n" + " \"oggetto\": \"oggetto 2\",\n" + " \"zona1\": \"zona2\", \n" + " \"oggetto\": \"oggetto1\", \n" + " \"oggettto\": \"oggetto2\" }";
try {
Graph<ZoneChoosed, DefaultEdge> graphh = Step4.getGraph();
/*Zone zone=new Zone();
Zone zone1=new Zone();
Zone zone2=new Zone();
ElementString elm=new ElementString();
ElementString elm1=new ElementString();
zone.setName("Medioevo");
zone1.setName("Assiri");
zone2.setName("Sumeri");
elm.setIdZone("Medioevo"); elm.setTitle("Oggetto1"); elm.setDescription("descrizione");
elm.setPhoto("link foto"); elm.setQrCode("qr code");
elm1.setIdZone("Assiri"); elm1.setTitle("Oggetto2"); elm1.setDescription("descr");
elm1.setPhoto("link foto oggetto 2"); elm1.setQrCode("qr code oggetto 2");
graph.addVertex(zone);
graph.addVertex(zone1);
graph.addVertex(zone2);
graph.addEdge(zone,zone1);
graph.addEdge(zone,zone2);
graph.addEdge(zone1,zone2);
graph.addEdge(zone2,zone1);*/
JSONExporter<ZoneChoosed, DefaultEdge> exporterr = new JSONExporter<>(v -> String.valueOf(v));
exporterr.setEdgeIdProvider(new IntegerIdProvider<>(1));
// ByteArrayOutputStream os = new ByteArrayOutputStream();
File filee = File.createTempFile("Percorso", ".json");
exporterr.exportGraph(graphh, filee);
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("application/json");
Uri uri = FileProvider.getUriForFile(Objects.requireNonNull(getApplicationContext()), BuildConfig.APPLICATION_ID + ".provider", filee);
intent.putExtra(Intent.EXTRA_STREAM, uri);
startActivity(intent);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return true;
}
return false;
}
});
}
use of com.example.alphatour.oggetti.ZoneChoosed in project AlphaTour by Frank99DG.
the class Step4 method savePathLocal.
public long savePathLocal(Path path) {
long newRowId = -1;
AlphaTourDbHelper dbAlpha = new AlphaTourDbHelper(getContext());
SQLiteDatabase db = dbAlpha.getWritableDatabase();
ContentValues values = new ContentValues();
values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_NAME, path.getName());
values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_DESCRIPTION, path.getDescription());
values.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_LOAD, "false");
newRowId = db.insert(AlphaTourContract.AlphaTourEntry.NAME_TABLE_PATH, AlphaTourContract.AlphaTourEntry.COLUMN_NAME_NULLABLE, values);
SQLiteDatabase db1 = dbAlpha.getWritableDatabase();
ContentValues values1 = new ContentValues();
for (i = 0; i < path.getZonePath().size(); i++) {
ZoneChoosed zoneChoosed = path.getZonePath().get(i);
for (int j = 0; j < zoneChoosed.getObjectChoosed().size(); j++) {
values1.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_CONTAINS_ID_PATH, getIdPath(path.getName()));
values1.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_CONTAINS_ZONE, zoneChoosed.getName());
values1.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_CONTAINS_OBJECT, zoneChoosed.getObjectChoosed().get(j));
values1.put(AlphaTourContract.AlphaTourEntry.NAME_COLUMN_PATH_CONTAINS_LOAD, "false");
newRowId = db1.insert(AlphaTourContract.AlphaTourEntry.NAME_TABLE_PATH_CONTAINS, AlphaTourContract.AlphaTourEntry.COLUMN_NAME_NULLABLE, values1);
}
}
return newRowId;
}
use of com.example.alphatour.oggetti.ZoneChoosed in project AlphaTour by Frank99DG.
the class Step4 method savePath.
private void savePath() {
progressBar.setVisibility(View.VISIBLE);
List<MapZoneAndObject> zoneAndObjectList = zoneAndObjectList_;
MapZoneAndObject mapZoneAndOb = zoneAndObjectList.get(0);
Path path = new Path();
path.setName(mapZoneAndOb.getName());
path.setDescription(mapZoneAndOb.getDescription());
path.setIdUser(user.getUid());
for (int i = 0; i < zoneAndObjectList_.size(); i++) {
MapZoneAndObject mapZoneAndObject = zoneAndObjectList.get(i);
// String delete = "delete";
// if(!mapZoneAndObject.getZone().matches(delete)) {
ZoneChoosed zoneChoosed = new ZoneChoosed();
zoneChoosed.setName(mapZoneAndObject.getZone());
List<String> obj = mapZoneAndObject.getListObj();
for (int j = 0; j < obj.size(); j++) {
zoneChoosed.setObjectChoosed(obj.get(j));
}
graph.addVertex(zoneChoosed);
zoneChooseds.add(zoneChoosed);
if (i >= 1) {
graph.addEdge(zoneChooseds.get(i - 1), zoneChooseds.get(i));
}
path.setZonePath(zoneChoosed);
// }
}
if (receiver.isConnected()) {
savePathRemote(path);
savePathLocal(path);
} else {
savePathRemote(path);
savePathLocal(path);
moveToCreateJsonActivity();
progressBar.setVisibility(View.GONE);
}
}
use of com.example.alphatour.oggetti.ZoneChoosed in project AlphaTour by Frank99DG.
the class Step5 method savePath.
private void savePath() {
progressBar.setVisibility(View.VISIBLE);
List<MapZoneAndObject> zoneAndObjectList = zoneAndObjectList_;
MapZoneAndObject mapZoneAndOb = zoneAndObjectList.get(0);
Path path = new Path();
path.setName(mapZoneAndOb.getName());
path.setDescription(mapZoneAndOb.getDescription());
path.setIdUser(user.getUid());
for (int i = 0; i < zoneAndObjectList_.size(); i++) {
MapZoneAndObject mapZoneAndObject = zoneAndObjectList.get(i);
// String delete = "delete";
// if(!mapZoneAndObject.getZone().matches(delete)) {
ZoneChoosed zoneChoosed = new ZoneChoosed();
zoneChoosed.setName(mapZoneAndObject.getZone());
List<String> obj = mapZoneAndObject.getListObj();
for (int j = 0; j < obj.size(); j++) {
zoneChoosed.setObjectChoosed(obj.get(j));
}
graph.addVertex(zoneChoosed);
zoneChooseds.add(zoneChoosed);
if (i >= 1) {
graph.addEdge(zoneChooseds.get(i - 1), zoneChooseds.get(i));
}
path.setZonePath(zoneChoosed);
// }
}
}
Aggregations