use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class AppointmentsFragment method onCreateView.
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
View rootView = (View) inflater.inflate(R.layout.fragment_appointments, container, false);
db = FirebaseDatabase.getInstance().getReference().child("appointments");
appointments = new ArrayList<Appointment>();
keys = new ArrayList<String>();
fetchData();
numAppointments = (TextView) rootView.findViewById(R.id.num_appointments);
mRecyclerView = (RecyclerView) rootView.findViewById(R.id.appointment_list_recycler_view);
mRecyclerView.setHasFixedSize(true);
mLayoutManager = new LinearLayoutManager(getActivity());
mRecyclerView.setLayoutManager(mLayoutManager);
mRecyclerView.setItemAnimator(new DefaultItemAnimator());
mRecyclerView.addItemDecoration(new RecycleMarginDecoration(getActivity()));
mAdapter = new MyAppointmentDataAdapter(appointments, keys);
mRecyclerView.setAdapter(mAdapter);
return rootView;
}
use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class MyAppointmentDataAdapter method onBindViewHolder.
// Replace the contents of a view (invoked by the layout manager)
@Override
public void onBindViewHolder(final ViewHolder holder, int position) {
Appointment appointment = appointments.get(position);
holder.cv.setTag(keys.get(position));
if (appointment.transport) {
holder.mTransport.setText("Yes");
} else {
holder.mTransport.setText("No");
}
if (appointment.confirmed.equals(false)) {
holder.mStatus.setText("Pending confirmation");
} else {
holder.mStatus.setText("Confirmed");
}
holder.mDate.setText(DateFormat.getDateInstance().format(new Date(appointment.date)));
holder.mTime.setText(DateFormat.getTimeInstance(DateFormat.SHORT).format(new Date(appointment.date)));
FirebaseDatabase.getInstance().getReference().child("users").child(appointment.orgid).addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
User usr = dataSnapshot.getValue(User.class);
holder.mName.setText(usr.username);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
}
use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class AddAppointmentActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_appointment);
setTitle("Add Appointment");
mAuth = FirebaseAuth.getInstance();
user = mAuth.getCurrentUser();
spinner = (Spinner) findViewById(R.id.spin1);
set = (EditText) findViewById(R.id.editText);
set1 = (EditText) findViewById(R.id.editText2);
radioGroup = (RadioGroup) findViewById(R.id.radio);
hospitals = new ArrayList<String>();
keys = new ArrayList<String>();
FirebaseDatabase.getInstance().getReference().child("users").orderByChild("account_type").equalTo("organization").addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot child : dataSnapshot.getChildren()) {
User user = child.getValue(User.class);
hospitals.add(user.username);
keys.add(child.getKey());
}
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getApplicationContext(), android.R.layout.simple_spinner_dropdown_item, hospitals);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
spinner.setAdapter(adapter);
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
set.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new Dialog(AddAppointmentActivity.this);
dialog.setTitle("Set Date");
dialog.setContentView(R.layout.set_date);
dialog.show();
final Button setDate = (Button) dialog.findViewById(R.id.set_date);
final DatePicker datePicker = (DatePicker) dialog.findViewById(R.id.datePicker);
datePicker.setMinDate(System.currentTimeMillis() - 1000);
setDate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
day = datePicker.getDayOfMonth();
month = datePicker.getMonth();
year = datePicker.getYear();
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, day);
pdate = calendar.getTime();
date = DateFormat.getDateInstance().format(pdate);
set.setText(date);
dialog.cancel();
}
});
}
});
set1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
dialog = new Dialog(AddAppointmentActivity.this);
dialog.setTitle("Set Time");
dialog.setContentView(R.layout.set_time);
dialog.show();
final Button setTime = (Button) dialog.findViewById(R.id.set_time);
final TimePicker timePicker = (TimePicker) dialog.findViewById(R.id.timePicker);
setTime.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
hour = timePicker.getCurrentHour();
minute = timePicker.getCurrentMinute();
if (hour >= 12) {
time = "PM";
} else {
time = "AM";
}
if (hour > 12) {
hour = hour - 12;
}
if (minute > 10) {
time = minute + " " + time;
} else {
time = "0" + minute + " " + time;
}
if (hour > 10) {
time = hour + ":" + time;
} else {
time = "0" + hour + ":" + time;
}
set1.setText(time);
dialog.cancel();
}
});
}
});
Button submit = (Button) findViewById(R.id.submit_button1);
submit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
radioButton = (RadioButton) findViewById(radioGroup.getCheckedRadioButtonId());
String transport_text = (String) radioButton.getText();
if (transport_text.equals("Yes")) {
transport = true;
} else {
transport = false;
}
Appointment appointment = new Appointment(user.getUid(), keys.get(spinner.getSelectedItemPosition()), date, time, transport);
FirebaseDatabase.getInstance().getReference().child("appointments").push().setValue(appointment);
dialog = new Dialog(AddAppointmentActivity.this);
dialog.setTitle("Submit Request");
dialog.setContentView(R.layout.popup_appointment_submit);
dialog.show();
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
final Button request = (Button) dialog.findViewById(R.id.button_ok);
request.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = new Intent(AddAppointmentActivity.this, MainActivity.class);
startActivity(intent);
}
});
}
});
}
use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class AppointmentsFragment method fetchData.
// Getting data from database
public void fetchData() {
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser user = mAuth.getCurrentUser();
db.orderByChild("userid").equalTo(user.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
appointments.clear();
keys.clear();
for (DataSnapshot child : dataSnapshot.getChildren()) {
Appointment appointment = child.getValue(Appointment.class);
appointments.add(appointment);
keys.add(child.getKey());
}
numAppointments.setText("Appointments: " + appointments.size());
mAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return;
}
use of com.jexapps.bloodhub.m_Model.Appointment in project BloodHub by kazijehangir.
the class AppointmentsOrgFragment method fetchData.
// Getting data from database
public void fetchData() {
FirebaseAuth mAuth = FirebaseAuth.getInstance();
FirebaseUser user = mAuth.getCurrentUser();
db.orderByChild("orgid").equalTo(user.getUid()).addValueEventListener(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
appointments.clear();
keys.clear();
for (DataSnapshot child : dataSnapshot.getChildren()) {
Appointment appointment = child.getValue(Appointment.class);
appointments.add(appointment);
keys.add(child.getKey());
}
numAppointments.setText("Appointments: " + appointments.size());
mAdapter.notifyDataSetChanged();
}
@Override
public void onCancelled(DatabaseError databaseError) {
}
});
return;
}
Aggregations