-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFoundItemPageMETHOD
63 lines (54 loc) · 2.68 KB
/
FoundItemPageMETHOD
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
ArrayList<String> names, description, keys ;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_found_items_page);
//Intent intent = getIntent();
//item = (Item)intent.getSerializableExtra("item");
searchView = findViewById(R.id.searchBar); // inititate a search view
//get the string from search view TODO
initialize();
list = findViewById(R.id.itemsList);
//make items clickable
//TODO pass to chat or the item edit page
list.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
Log.i(TAG, "IT WORKSSS!!!!");
Contacts uploaderUser = new Contacts("elif.kurtay");
Intent chatIntent = new Intent( FoundItemsPage.this, ChatActivity.class);
chatIntent.putExtra("visit_user_id", "5l93A3K0QjV6gw93uxirnFTH5AE3");
chatIntent.putExtra("visit_user_name", "elif.kurtay");
startActivity( chatIntent);
}
});
}
private void initialize() {
names = new ArrayList<>();
description = new ArrayList<>();
keys = new ArrayList<>();
FirebaseDatabase.getInstance().getReference().child("LostPost")
.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
//lostPosts = new ArrayList<>();
for (DataSnapshot snapshot : dataSnapshot.getChildren()) {
if( snapshot.hasChild("name") ) {
names.add( snapshot.child("name").getValue().toString() );
keys.add(snapshot.getKey() );
Log.i("list", names.toString());
Log.i("keys:",keys.toString());
}
if( snapshot.hasChild("tags") ) {
description.add( snapshot.child("tags").getValue().toString() );
Log.i("list", description.toString());
}
custom = new Custom(FoundItemsPage.this, names, description);
list.setAdapter(custom);
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}