use of com.google.firebase.firestore.QueryDocumentSnapshot in project QRHunt by CMPUT301W22T00.
the class QrLibrary method update.
/**
* Updates the QRLibrary of the player (aligning to the their QR database)
*/
public void update() {
qrCodesList = new ArrayList<>();
Query qrList = db.collection("users").document(playerId).collection("qrCodes");
qrList.get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot doc : task.getResult()) {
if (doc.exists()) {
PlayableQrCode qrCode = doc.toObject(PlayableQrCode.class);
qrCodesList.add(qrCode);
}
}
qrCodesList.sort(compareByScore);
}
});
scoreSorted = 1;
}
use of com.google.firebase.firestore.QueryDocumentSnapshot in project House-Organizer by House-Organizer.
the class MainScreenActivity method refreshCalendar.
@SuppressLint("NotifyDataSetChanged")
public void refreshCalendar(View v) {
db.collection("events").whereEqualTo("household", currentHouse).whereGreaterThan("start", LocalDateTime.now().toEpochSecond(ZoneOffset.UTC)).get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
ArrayList<Event> newEvents = new ArrayList<>();
for (QueryDocumentSnapshot document : task.getResult()) {
// We assume the stored data is well behaved since it got added in a well behaved manner.
Event event = new Event(document.getString("title"), document.getString("description"), LocalDateTime.ofEpochSecond(document.getLong("start"), 0, ZoneOffset.UTC), document.getLong("duration") == null ? 0 : document.getLong("duration"), document.getId());
newEvents.add(event);
}
calendarAdapter.notifyDataSetChanged();
calendar.setEvents(newEvents);
} else {
Toast.makeText(v.getContext(), v.getContext().getString(R.string.refresh_calendar_fail), Toast.LENGTH_SHORT).show();
}
});
}
use of com.google.firebase.firestore.QueryDocumentSnapshot in project maintananceManagement by riesjulianna.
the class MainActivity method onClick.
public void onClick(View view) {
switch(view.getId()) {
case R.id.buttonLord:
who = "lord";
break;
case R.id.buttonHazvezetono:
who = "hazvezetono";
break;
case R.id.buttonSzolga:
who = "szolga";
break;
}
db.collection("users").whereEqualTo("beosztas", who).whereEqualTo("felhasznalonev", fnev.getText().toString().trim()).whereEqualTo("jelszo", jelszo.getText().toString().trim()).get().addOnCompleteListener(task -> {
for (QueryDocumentSnapshot document : task.getResult()) {
beosztas = document.getString("beosztas");
fhnv = document.getString("felhasznalonev");
jlsz = document.getString("jelszo");
}
if (!(beosztas == null)) {
// itt mindegyik null ha nem stimmel, ezért csak egyet ellenőrzök
switch(who) {
case "lord":
Intent lord = new Intent(MainActivity.this, LordMainActivity.class);
startActivity(lord);
break;
case "hazvezetono":
Intent hazvezetono = new Intent(MainActivity.this, HnoMainActivity.class);
startActivity(hazvezetono);
break;
case "szolga":
Intent szolga = new Intent(MainActivity.this, SzolgaMainActivity.class);
startActivity(szolga);
break;
}
} else {
Toast.makeText(MainActivity.this, "Helytelen valami.", Toast.LENGTH_SHORT).show();
}
});
}
use of com.google.firebase.firestore.QueryDocumentSnapshot in project SE_TermProject by IMDongH.
the class UserSearchActivity method onCreate.
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_search_);
ActionBar ac = getSupportActionBar();
ac.setTitle("검색");
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
Intent intent = getIntent();
String region = intent.getStringExtra("region");
Log.d(TAG, region);
FirebaseFirestore db = FirebaseFirestore.getInstance();
db.collectionGroup(region).get().addOnCompleteListener(task -> {
if (task.isSuccessful()) {
for (QueryDocumentSnapshot documentSnapshot : task.getResult()) {
HashMap = (HashMap<String, Object>) documentSnapshot.getData();
String name = (String) HashMap.get("자동차정비업체명");
String Location = (String) HashMap.get("소재지도로명주소");
SearchTitleClass stc = new SearchTitleClass(name, Location);
arraylist.add(stc);
Log.d(TAG, name + Location);
}
list = findViewById(R.id.listview);
adapter = new SearchListViewAdapter(this, arraylist);
list.setAdapter(adapter);
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> adapterView, View view, int i, long l) {
Log.d(TAG, arraylist.get(i).toString());
Log.d(TAG, ((TextView) view.findViewById(R.id.Location_name)).getText().toString());
Intent resultIntent = new Intent();
resultIntent.putExtra("address", ((TextView) view.findViewById(R.id.Location_name)).getText().toString());
setResult(RESULT_OK, resultIntent);
finish();
}
});
// Locate the EditText in listview_main.xml
editsearch = findViewById(R.id.search);
editsearch.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return false;
}
@Override
public boolean onQueryTextChange(String s) {
adapter.filter(s);
return false;
}
});
} else {
Log.d(TAG, "FAIL");
}
});
}
use of com.google.firebase.firestore.QueryDocumentSnapshot in project SE_TermProject by IMDongH.
the class UserMainActivity method selectRegion.
public void selectRegion(MenuItem item) {
AlertDialog.Builder ad = new AlertDialog.Builder(this);
ad.setTitle("지역을 선택하세요").setItems(selectOption, new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int i) {
String RG = selectOption[i].toString();
item.setTitle(RG);
// flag=1;
region = RG;
// regMap = new HashMap<>();
regList = new ArrayList<>();
regTable = new HashMap<>();
mMap.clear();
db.collection(RG).get().addOnCompleteListener(new OnCompleteListener<QuerySnapshot>() {
@Override
public void onComplete(@NonNull Task<QuerySnapshot> task) {
if (task.isSuccessful()) {
double cameraLat = 0.0;
double camreaLon = 0.0;
for (QueryDocumentSnapshot document : task.getResult()) {
if (document.exists()) {
String address = (String) document.getData().get("소재지도로명주소");
double latitude = (double) document.getData().get("위도");
double longitude = (double) document.getData().get("경도");
if (cameraLat == 0)
cameraLat = latitude;
if (camreaLon == 0)
camreaLon = longitude;
LatLng location = new LatLng(latitude, longitude);
MarkerOptions markerOptions = new MarkerOptions();
markerOptions.position(location);
String centerName = (String) document.getData().get("자동차정비업체명");
String phone;
phone = (String) document.getData().get("phone");
if (phone == null) {
phone = "미등록업체";
} else {
cameraLat = latitude;
camreaLon = longitude;
regList.add(centerName);
regTable.put(centerName, phone);
}
// regMap.put(centerName, phone);
markerOptions.title(centerName);
markerOptions.snippet(address);
mMap.addMarker(markerOptions);
Log.d(TAG, "DocumentSnapshot data: " + document.getData() + "phone : " + phone);
}
}
LatLng cameraLoc = new LatLng(cameraLat, camreaLon);
mMap.moveCamera(CameraUpdateFactory.newLatLngZoom(cameraLoc, 15));
mMap.setOnInfoWindowClickListener(new GoogleMap.OnInfoWindowClickListener() {
@Override
public void onInfoWindowClick(@NonNull Marker marker) {
Log.d(TAG, "Info window click :" + marker.getTitle());
if (regList.contains(marker.getTitle())) {
Bundle data = new Bundle();
data.putString("centerName", marker.getTitle());
data.putString("centerAddress", marker.getSnippet());
data.putString("phone", regTable.get(marker.getTitle()));
Intent intent = new Intent(UserMainActivity.this, PopUpCenterInfo.class);
intent.putExtras(data);
startActivity(intent);
} else {
StartToast("미등록업체입니다. ");
}
}
});
}
}
});
}
}).setCancelable(true).show();
}
Aggregations