我正在开发一个独立的 Wear 应用程序。一切正常,但图像加载太慢。
我这样做的方式是使用 Firebase Storage 作为后端。我正在获取 URL 并使用 Glide 将其加载到ImageView
.
我也尝试使用 Picasso 获得相同的结果。
我尝试使用 DaVinci 库,但它太旧了(3 岁)。我点击了这个链接:How to load URL image in android wear?
我使用的代码非常简单:
Picasso.get().load(imageUrl).into(iv);
和滑翔版本:
Glide.with(iv.getContext()).load(imageUrl).into(iv);
我正在使用的版本:
- 摇篮:3.0.1
- 谷歌服务:3.2.0/ 11.8.0 用于依赖
- 滑翔:4.3.1
- 毕加索:2.71828
这是我将图像上传到 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();
}
}
}