Reputation: 392
I'm working on a standalone Wear app. Everything works but the image loading is too slow.
The way I'm doing it is using Firebase Storage as a back-end. I'm getting the URL and using Glide loading it into an ImageView
.
I also try using Picasso with the same result.
I tried to use the DaVinci library but its too old (3 years old). I followed this link: How to load URL image in android wear?
The code that I used is quite simple:
Picasso.get().load(imageUrl).into(iv);
and the Glide version:
Glide.with(iv.getContext()).load(imageUrl).into(iv);
The versions I'm using:
This is the way I'm uploading the image to Firebase-Storage:
String filePath = photoFile.getAbsolutePath();
Bitmap bitmap = BitmapFactory.decodeFile(filePath, options);
mFormActivity.getContentResolver().notifyChange(photoURI, null);
int rotateImage = getCameraPhotoOrientation(filePath);
Matrix matrix = new Matrix();
matrix.postRotate(rotateImage);
Bitmap rotatedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
FileOutputStream fos = null;
try {
fos = new FileOutputStream(photoFile);
rotatedBitmap.compress(Bitmap.CompressFormat.PNG, 25, fos);
fos.close();
} catch (IOException e) {
Log.d(TAG, "fixLandscapeOrientationCamera.error = " + e.toString());
if (fos != null) {
try {
fos.close();
} catch (IOException e1) {
e1.printStackTrace();
}
}
}
Upvotes: 0
Views: 150
Reputation: 392
I found the issue. Thanks Akshay Katariya for your time!!
I feel ashamed because it was a stupid mistake by my side. I was creating a bitmap and setting it into the ImageView before downloading the image. Anyway now its working perfectly so this is my code fully working for anyone that could try to achieve it.
I m using Picasso and Firebase Storage in a Standalone Wear App:
StorageReference imageReference = App.getStorage().getReference().child("images/" + mUser.getPicture());
imageReference.getDownloadUrl()
.addOnSuccessListener(uri -> {
Log.d("Testing", "loadSuggestionFace: setting the image");
Picasso.get().load(uri.toString()).into(mFace1ProfilePicture);
})
.addOnFailureListener(exception -> Log.d(TAG, "getDownloadUrl.addOnFailureListener: error = " + exception.toString()));
App its the class extending Application where I'm initializing Firebase
mUser.getPicture() contains the filename(carlos.png for example)
mFace1ProfilePicture its the ImageView
Upvotes: 0