Android - Storing images downloaded from the web

前端 未结 4 1504
一生所求
一生所求 2020-12-23 02:18

I had a question related to whether or not (and how) I should store images loaded from the web. Let\'s say I am calling a web service from my Android app. In this web serv

4条回答
  •  余生分开走
    2020-12-23 03:01

    In regards to your "side question" -- I think that loading them asynchronously would be the preferred behavior, especially since you need to consider that with network transactions, it might not just be "lock the UI for some time", but "lock the UI permanently" in case it never loads.

    If you consider this behavior ugly, though, you could set a timer (1 or 2 seconds) that gives a few of the images a chance to load, and if they have all loaded or the timer has expired, go ahead and show the UI anyway with placeholder images and let the rest load asynchronously. This would be the way to go to prevent permanent locks anyway.

    As for the first part of your question, I think it is somewhat dependent on the context and type of images you are displaying. With most web assets, though, I think #2 would be the preferred approach, since you certainly don't want to download multiple times in the same session, but you probably don't want to eat up permanent storage either.

提交回复
热议问题