什么可以使Android 4.1.X中的加载速度慢而不是4.2?

ala*_*eri 7 java performance android urlimageviewhelper

我正在使用UrlImageViewHelper来加载适配器视图中的图片.

我的适配器是:


@Override
public View getView(int position, View convertView, ViewGroup parent) {              
    if(convertView==null){
        convertView=new SquaredImageView(getContext());
    }
    SquaredImageView view= (SquaredImageView) convertView;
    final long time=System.currentTimeMillis();
    UrlImageViewHelper.setUrlDrawable(view,getItem(position).getLook_picture(),
           R.drawable.placeholder_bkp, -1,new UrlImageViewCallback() {
                   @Override
                   public void onLoaded(ImageView imageView, Bitmap loadedBitmap, 
                                              String url, boolean loadedFromCache) {
                       Log.d(TAG,"time : "+ (System.currentTimeMillis()-time));
                   }
    });
    return view;
}
Run Code Online (Sandbox Code Playgroud)

我正在下载并在全宽列表中显示大图片(620x620 jpg).它们在第一次下载/显示时速度很慢.升级到android 4.2后不再出现此问题.在HTC上.

我试图分析调用,我相信在很长的调用期间,它会挂起读取套接字输入流.

有没有人知道为什么两个平台之间的性能有这么大差异?


Logcat输出:( 100 ms以下的时间通常是重复的)

android 4.1.2 Galaxy SIII mini

  • 时间:3217
  • 时间:4782
  • 时间:124
  • 时间:56
  • 时间:168
  • 时间:84
  • 时间:102
  • 时间:2819
  • 时间:2703
  • 时间:154
  • 时间:2468
  • 时间:81
  • 时间:40
  • 时间:52
  • 时间:2495
  • 时间:37
  • 时间:2007年
  • 时间:58
  • 时间:38
  • 时间:119
  • 时间:80
  • 时间:44
  • 时间:2419
  • 时间:1651年
  • 时间:40
  • 时间:2766
  • 时间:90
  • 时间:1889年
  • 时间:183
  • 时间:2515
  • 时间:58
  • 时间:3345
  • 时间:2661
  • 时间:81
  • 时间:2434
  • 时间:119

大多在1.5秒以上.用户需要逐个滚动项目才能看到图片

在android 4.3 nexus 4上:

  • 时间:47
  • 时间:1111
  • 时间:154
  • 时间:46
  • 时间:124
  • 时间:115
  • 时间:150
  • 时间:201
  • 时间:332
  • 时间:366
  • 时间:450
  • 时间:82
  • 时间:167
  • 时间:81
  • 时间:150
  • 时间:224
  • 时间:224
  • 时间:143
  • 时间:185
  • 时间:66
  • 时间:183
  • 时间:66
  • 时间:218
  • 时间:98
  • 时间:169
  • 时间:49
  • 时间:148
  • 时间:65
  • 时间:64
  • 时间:60
  • 时间:169
  • 时间:51

始终低于500毫秒,列表可用

Gle*_*des 2

这与手机上运行的操作系统无关。可能的原因也是最可能的原因是设备上其他应用程序正在消耗的 RAM 内存量。出于测试目的,请尝试在没有运行很多应用程序的新设备上运行相同的代码。