【发布时间】:2018-03-27 11:12:00
【问题描述】:
我正在开发一个独立的 Wear 应用。一切正常,但图像加载太慢。
我这样做的方式是使用 Firebase 存储作为后端。我正在获取 URL 并使用 Glide 将其加载到 ImageView。
我也尝试使用 Picasso 获得相同的结果。
我尝试使用 DaVinci 库,但它太旧了(3 岁)。我点击了这个链接:How to load URL image in android wear?
我使用的代码很简单:
Picasso.get().load(imageUrl).into(iv);
和 Glide 版本:
Glide.with(iv.getContext()).load(imageUrl).into(iv);
我正在使用的版本:
- 分级:3.0.1
- Google-services: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();
}
}
}
【问题讨论】:
-
您的图像在分辨率和 MB / KB 大小方面有多大,这对于 Android 可穿戴设备显然很重要。
-
嗨!图片大小为 80-90Kb....它们是个人资料图片。我正在使用相机意图
-
相机意图用于??
-
不不...对不起!!你是对的......相机拍摄的是4Mb!我会马上改变它,但模拟用户有 80-90Mb 的图像,它仍然很慢
-
你需要实现一些优化和压缩技术developer.android.com/topic/performance/graphics/…
标签: android performance picasso android-glide android-wear-2.0