use of com.hci.carebase.data.interfaces.PhotoSource in project Carebase by robertsimoes.
the class AppointmentsFragment method onActivityResult.
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
if (requestCode == Const.REQUEST_CODE_CAPTURE_IMAGE_ACTIVITY) {
if (resultCode == Activity.RESULT_OK) {
Bitmap bmp = (Bitmap) data.getExtras().get("data");
ByteArrayOutputStream stream = new ByteArrayOutputStream();
bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
byte[] byteArray = stream.toByteArray();
// convert byte array to Bitmap
Bitmap bitmap = BitmapFactory.decodeByteArray(byteArray, 0, byteArray.length);
imgViewPatientAttachment.setImageBitmap(bitmap);
Uri uri = Commons.saveTmpAndGetUri(getContext(), bmp);
PhotoSource s = CollectionsProvider.photos();
ILocalCache cache = new LocalCacheDb(getContext());
String userId = cache.getUserId();
// dlg.setCancelable(true);
// dlg.show(getContext(),"Please wait..","Attaching image..");
s.uploadAppointmentPhoto(userId, uri, currentAppointment.getDateFor(), taskSnapshot -> {
// dlg.dismiss();
currentAppointment.setHasImageAttachment(true);
int indexUpcoming = Commons.getMostUpcomingAppointmentIndex(p);
p.getAppointments().set(indexUpcoming, currentAppointment);
callback.onSave(p);
Toast.makeText(getContext(), "Saved image.", Toast.LENGTH_SHORT).show();
});
}
}
}
use of com.hci.carebase.data.interfaces.PhotoSource in project Carebase by robertsimoes.
the class DebugFragment method onFakeUserImgClick.
@OnClick(R.id.debug_but_patient_fake_user_image)
public void onFakeUserImgClick(View v) {
PhotoSource sr = CollectionsProvider.photos();
sr.getRandomPhoto(true, new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Glide.with(getContext()).load(// the uri you got from Firebase
uri).centerCrop().into(// Your imageView variable
img);
img.invalidate();
}
});
}
use of com.hci.carebase.data.interfaces.PhotoSource in project Carebase by robertsimoes.
the class DebugFragment method onFakeHC.
@OnClick(R.id.debug_but_patient_fake_hc)
public void onFakeHC(View v) {
PhotoSource sr = CollectionsProvider.photos();
sr.getFakeHealthCardPhoto(new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Glide.with(getContext()).load(// the uri you got from Firebase
uri).centerCrop().into(// Your imageView variable
img);
img.invalidate();
}
});
}
use of com.hci.carebase.data.interfaces.PhotoSource in project Carebase by robertsimoes.
the class AppointmentsFragment method refreshUI.
private void refreshUI(Appointment mostUpcomingAppointment) {
SimpleDateFormat f = new SimpleDateFormat("EEE, MMM d, yyyy");
String date = f.format(mostUpcomingAppointment.getDateFor());
String hospital = mostUpcomingAppointment.getHospitalLocation() == "" ? "N/A please contact physician." : mostUpcomingAppointment.getHospitalLocation();
String doctor = mostUpcomingAppointment.getDoctor().getFirstName() + " " + mostUpcomingAppointment.getDoctor().getLastName();
String prep = mostUpcomingAppointment.getPreparations() == "" ? "N/A" : mostUpcomingAppointment.getPreparations();
String comments = mostUpcomingAppointment.getPatientComments() == "" ? "N/A" : mostUpcomingAppointment.getPatientComments();
tvAppointmentDoctor.setText(doctor);
tvAppointmentPrep.setText(prep);
tvAppointmentHospital.setText(hospital);
tvAppointmentTime.setText(date);
tvPatientComments.setText(comments);
if (mostUpcomingAppointment.hasImageAttachment()) {
PhotoSource s = CollectionsProvider.photos();
ILocalCache cache = new LocalCacheDb(getContext());
s.getAppointmentPhoto(cache.getUserId(), mostUpcomingAppointment.getDateFor(), new OnSuccessListener<Uri>() {
@Override
public void onSuccess(Uri uri) {
Glide.with(getContext()).load(uri).into(imgViewPatientAttachment);
}
});
}
}
Aggregations