-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathViewTask.java
More file actions
123 lines (92 loc) · 3.99 KB
/
ViewTask.java
File metadata and controls
123 lines (92 loc) · 3.99 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
package com.example.lenovo.employeetrackingsystem;
import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;
import com.google.firebase.database.ChildEventListener;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
public class ViewTask extends AppCompatActivity {
private Button btn;
private TextView name, description, location;
private DatabaseReference mDatabase;
private ChildEventListener mChildEventListener;
// UserSessionManager session;
private static final String TAG = "MainActivity";
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_view_task);
btn = (Button) findViewById(R.id.status);
name = (TextView) findViewById(R.id.name);
description = (TextView) findViewById(R.id.description);
location = (TextView) findViewById(R.id.location);
// session = new UserSessionManager(getApplicationContext());
// if(session.checkLogin())
// finish();
FirebaseDatabase database = FirebaseDatabase.getInstance();
final DatabaseReference UnAss_tasks = database.getReference("Task_Details");
final DatabaseReference Emp_reg = database.getReference("Emp_Registration");
final DatabaseReference Duration = database.getReference("Emp_details");
mChildEventListener = new ChildEventListener() {
@Override
public void onChildAdded(DataSnapshot dataSnapshot, String s) {
getTask gt = dataSnapshot.getValue(getTask.class);
name.setText(gt.getTaskname());
description.setText(gt.getTaskdescription());
location.setText(gt.getTasklocation());}
@Override
public void onChildChanged(DataSnapshot dataSnapshot, String s) {
getTask gt = dataSnapshot.getValue(getTask.class);
name.setText(gt.getTaskname());
description.setText(gt.getTaskdescription());
location.setText(gt.getTasklocation());
}
@Override
public void onChildRemoved(DataSnapshot dataSnapshot) {
}
@Override
public void onChildMoved(DataSnapshot dataSnapshot, String s) {
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
};
UnAss_tasks.addChildEventListener(mChildEventListener);
btn.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
btn.setText("ASSIGNED");
Intent mtask = new Intent(ViewTask.this, TaskDetails.class);
startActivity(mtask);
btn.setEnabled(false);
}
});
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);//Menu Resource, Menu
return true;
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.item1:
// session.logoutUser();
return true;
case R.id.item2:
Toast.makeText(getApplicationContext(),"About Us",Toast.LENGTH_LONG).show();
return true;
default:
return super.onOptionsItemSelected(item);
}
}
}