Android应用程序崩溃没有错误和太多的图片正在下载?

时间:2016-11-25 02:59:02

标签: android heap

我的应用程序下载了很多图片。每个型号2张照片。大约有20个型号。其中一些图片是非常大的svg,其中一些是png的。

我通过另一个文件获取图片网址,然后我检查网址是否以svg或png结尾,如果网址以“.png”结尾,我使用picasso,如果以“.svg”结尾,我使用滑行。< / p>

我正在使用Recyclerview。我在列表中显示模型。

这里是适配器 onBindViewHolder 方法(我通过毕加索或滑行下载和设置imageview中的图像):

    @Override
public void onBindViewHolder(CustomViewHolder customViewHolder, int i) {
    final Object object= objectList.get(i);

    requestBuilder = Glide.with(customViewHolder.imageViewHomeTeam.getContext())
            .using(Glide.buildStreamModelLoader(Uri.class, customViewHolder.imageViewHomeTeam.getContext()), InputStream.class)
            .from(Uri.class)
            .as(SVG.class)
            .transcode(new SvgDrawableTranscoder(), PictureDrawable.class)
            .sourceEncoder(new StreamEncoder())
            .cacheDecoder(new FileToStreamDecoder<SVG>(new SvgDecoder()))
            .decoder(new SvgDecoder())
            .placeholder(R.drawable.placeholder)
            .error(R.drawable.placeholdererror)
            .animate(android.R.anim.fade_in)
            .listener(new SvgSoftwareLayerSetter<Uri>());

        if (object.getImageUrl().isEmpty() || object.getImageUrl().equals("null"))
        {
            customViewHolder.imageView.setImageResource(R.drawable.placeholder);
        }
        else
        {

            if (object.getImageUrl().endsWith(".svg"))
            {
                Uri uri = Uri.parse(object.getImageUrl());
                requestBuilder
                        .diskCacheStrategy(DiskCacheStrategy.SOURCE)
                        .load(uri)
                        .into(customViewHolder.imageView);
            }
            else {
                Picasso.with(customViewHolder.imageView.getContext())
                        .load(object.getImageUrl())
                        .resize(300, 300) // because some images are very big
                        .onlyScaleDown()
                        .skipMemoryCache()
                        .error(R.drawable.placeholdererror)
                        .into(customViewHolder.imageView);
            }

        }
    customViewHolder.textView.setText(Html.fromHtml(object.getTitle))); // .fromHtml because i am getting the string from another file through json like the images // (AsyncTask)

}

现在我的问题:我认为应用程序低调被图像数量和大小所淹没,因为应用程序只是崩溃而没有任何错误,我想我在logcat中发现了什么有什么东西这样做:

11-25 03:42:04.114 1204-1204/? I/dalvikvm-heap: Grow heap (frag case) to     13.726MB for 3072012-byte allocation
11-25 03:42:04.470 1204-1204/? I/dalvikvm-heap: Grow heap (frag case) to 19.971MB for 6553612-byte allocation
11-25 03:42:05.066 14886-14886/? I/dalvikvm-heap: Grow heap (frag case) to 16.590MB for 8294412-byte allocation
11-25 03:42:06.166 14886-14886/? I/dalvikvm-heap: Grow heap (frag case) to 48.230MB for 33177612-byte allocation
11-25 03:42:14.166 14886-14886/? I/dalvikvm-heap: Grow heap (frag case) to 45.887MB for 1205580-byte allocation
11-25 03:42:15.314 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 48.114MB for 2295784-byte allocation
11-25 03:42:15.618 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 50.036MB for 2295784-byte allocation
11-25 03:42:15.770 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 52.223MB for 2295784-byte allocation
11-25 03:42:15.826 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 50.034MB for 2295784-byte allocation
11-25 03:42:15.918 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 48.945MB for 1147875-byte allocation
11-25 03:42:16.002 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 49.751MB for 860909-byte allocation
11-25 03:42:16.106 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 50.562MB for 849728-byte allocation
11-25 03:42:16.518 14886-14924/? I/dalvikvm-heap: Grow heap (frag case) to 63.914MB for 16009616-byte allocation
11-25 03:42:18.914 154-154/? I/DEBUG:          bf9f25a4  b7eed17c  [heap]
11-25 03:42:18.914 154-154/? I/DEBUG:     a6a0b000-a94b3000 /dev/ashmem/dalvik-heap (deleted)
11-25 03:42:18.914 154-154/? I/DEBUG:     a94b3000-aa8e5000 /dev/ashmem/dalvik-heap (deleted)
11-25 03:42:18.914 154-154/? I/DEBUG:     aa8e5000-b6169000 /dev/ashmem/dalvik-heap (deleted)
11-25 03:42:19.354 1204-1204/? I/dalvikvm-heap: Grow heap (frag case) to 13.722MB for 3072012-byte allocation
11-25 03:42:19.506 1413-1413/? I/dalvikvm-heap: Grow heap (frag case) to 34.462MB for 91212-byte allocation
11-25 03:42:19.542 1204-1204/? I/dalvikvm-heap: Grow heap (frag case) to 19.972MB for 6553612-byte allocation
11-25 03:42:20.374 619-1479/? W/InputMethodManagerService: Got RemoteException sending setActive(false) notification to pid 14886 uid 10037

第一个对象正在获取他们的图像,但随后一切都变得太多,应用程序崩溃而没有任何错误消息。

这是因为图像,因为我测试了没有图像的应用程序,它工作正常。

抱歉我的英文。

0 个答案:

没有答案