-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcomplaint_visible.java
More file actions
65 lines (48 loc) · 2.34 KB
/
Copy pathcomplaint_visible.java
File metadata and controls
65 lines (48 loc) · 2.34 KB
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
64
65
public void setVisible(final String complaintId, final String authority) {
//lastVisible ++
//assuming category,lastVisible,authority,mDatabase,mRoot is fetched gloabally and assuming complaints to be public
mRoot = FirebaseDatabase.getInstance().getReference().child("app");
mDatabase = mRoot.child("users").child("auth").child("post").child(authority).child("vcomplaint");
mDatabase.setValue(complaintId).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful())
Toast.makeText(getApplicationContext(), "Complaint forwarded", Toast.LENGTH_LONG).show();
else
Toast.makeText(getApplicationContext(), task.getException().getMessage(), Toast.LENGTH_LONG).show();
}
});
if (authority != null) {
mDatabase = mRoot;
mDatabase.child("post").child("public").child(complaintId).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
lastVisible = dataSnapshot.child("lastvisible").getValue().toString();
category = dataSnapshot.child("category").getValue().toString();
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
mRoot.child("data").child("pcategories").child(category).child(lastVisible);
mRoot.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
authority = dataSnapshot.child("name").getValue().toString();
mDatabase = mRoot.child("users").child("auth").child("post").child(authority).child("vcomplaint");
mDatabase.setValue(complaintId).addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task) {
if (task.isSuccessful())
Toast.makeText(getApplicationContext(), "Complaint forwarded", Toast.LENGTH_LONG).show();
else
Toast.makeText(getApplicationContext(), task.getException().getMessage(), Toast.LENGTH_LONG).show();
}
});
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}