-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathComplaintDetailsActivity.java
More file actions
55 lines (49 loc) · 2.33 KB
/
Copy pathComplaintDetailsActivity.java
File metadata and controls
55 lines (49 loc) · 2.33 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
package com.jiet.androidclub;
import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
//This Activity will show details of complaint
public class ComplaintDetailsActivity extends AppCompatActivity {
private TextView mTitle,mDate,mDescription,mStatus;
private Button mNoOfUpvotes;
private ImageView mUpVoteIcon;
private DatabaseReference mDatabase;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_complaint_details);
mTitle = findViewById(R.id.Title);
mDate = findViewById(R.id.Date);
mDescription = findViewById(R.id.Description);
mNoOfUpvotes = findViewById(R.id.NoOfUpvotes);
mStatus = findViewById(R.id.Status);
mUpVoteIcon = findViewById(R.id.UpVoteIcon);
String problem = getIntent().getStringExtra("problem");
String complaintId = getIntent().getStringExtra("complaintId");
mDatabase = FirebaseDatabase.getInstance().getReference().child("app").child("complaints").child(problem).child(complaintId);
mDatabase.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot) {
ComplaintData complaintData = dataSnapshot.getValue(ComplaintData.class);
mTitle.setText(complaintData.getTitle());
mDate.setText(complaintData.getDate());
mDescription.setText(complaintData.getDescription());
mNoOfUpvotes.setText(complaintData.getUpVote());
mStatus.setText(complaintData.getStatus());
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
Toast.makeText(ComplaintDetailsActivity.this, "Something went wrong", Toast.LENGTH_SHORT).show();
}
});
}
}