Search in sources :

Example 1 with PhotoSource

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();
            });
        }
    }
}
Also used : LocalCacheDb(com.hci.carebase.data.datasource.LocalCacheDb) Bitmap(android.graphics.Bitmap) PhotoSource(com.hci.carebase.data.interfaces.PhotoSource) ILocalCache(com.hci.carebase.data.interfaces.ILocalCache) ByteArrayOutputStream(java.io.ByteArrayOutputStream) Uri(android.net.Uri)

Example 2 with PhotoSource

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();
        }
    });
}
Also used : PhotoSource(com.hci.carebase.data.interfaces.PhotoSource) Uri(android.net.Uri) OnClick(butterknife.OnClick)

Example 3 with PhotoSource

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();
        }
    });
}
Also used : PhotoSource(com.hci.carebase.data.interfaces.PhotoSource) Uri(android.net.Uri) OnClick(butterknife.OnClick)

Example 4 with PhotoSource

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);
            }
        });
    }
}
Also used : LocalCacheDb(com.hci.carebase.data.datasource.LocalCacheDb) PhotoSource(com.hci.carebase.data.interfaces.PhotoSource) ILocalCache(com.hci.carebase.data.interfaces.ILocalCache) SimpleDateFormat(java.text.SimpleDateFormat) Uri(android.net.Uri)

Aggregations

Uri (android.net.Uri)4 PhotoSource (com.hci.carebase.data.interfaces.PhotoSource)4 OnClick (butterknife.OnClick)2 LocalCacheDb (com.hci.carebase.data.datasource.LocalCacheDb)2 ILocalCache (com.hci.carebase.data.interfaces.ILocalCache)2 Bitmap (android.graphics.Bitmap)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 SimpleDateFormat (java.text.SimpleDateFormat)1