Jasonette / JASONETTE-Android

📡 Native App over HTTP, on Android
https://www.jasonette.com
Other
1.6k stars 270 forks source link

Fix #104: Crop background #119

Closed realitix closed 7 years ago

realitix commented 7 years ago

When you put a background image to your view, it is streched to fit screen dimension. With this patch, image is cropped to keep the aspect ratio.

Please @gliechtenstein, can you check the behavior on IPhone to be sure it's the same.

It's my first contribution to Jasonette, so don't hesitate to tell me if I do it wrong.

realitix commented 7 years ago

This pull request fix #104

gliechtenstein commented 7 years ago

@realitix Thanks for the PR! It works like a charm, but trying a gif image ends up with a blank. Do you think you could get it to work? thanks!

realitix commented 7 years ago

Indeed I didn't try with a gif, my bad! I will take a look tomorrow.

gliechtenstein commented 7 years ago

thanks!

realitix commented 7 years ago

After few tries. I noticed that it works but it's very long. I think that glide resizes the gif for each frame which explains why it's so long. When I restart the APP, it's very fast, so glide must have a cache. When the gif is in background, animation is not played, I will check with a single frame gif but it should be fast. It's useless to put a multi-frame gif to the body background. (Unless animation plays for you ?) Can you retry and wait 1 minute (it depends on the gif size and frame number) ?

I wait for your comment @gliechtenstein

gliechtenstein commented 7 years ago

Yes I think Glide does something like that.

That said, if you try switching to develop branch and try to render the same gif, it does display the gif (although we still have a problem of it only displaying the first frame)

I have played around with various configurations, and looks like it works if you use the default suggested approach of using asGif(), which JasonImageComponent but not when you try to run any sort of manipulation on it and then try to render.

Fortunately most images on Jasonette are rendered through JasonImageComponent so I think the only places we have problem are:

  1. body.background
  2. using data-uri to render gif

Maybe we should really try out Glide4?

realitix commented 7 years ago

I will try updating to Glide4 but I'm not sure that API is compatible. We'll see!

realitix commented 7 years ago

@gliechtenstein It this pull request working for you ?

From my point of view. Glide migration is another subject.

gliechtenstein commented 7 years ago

@realitix I agree we can separate out glide migration but this fix still breaks what wasn't broken before.

Is Gif working at all for you? At least in my case, the previous version used to show the gif even if it was freeze frame, but this fix doesn't show a gif at all. it's just a blank white screen.

gliechtenstein commented 7 years ago

You can try this https://jasonbase.com/things/o2Kw

It's just a simple view with background:

{
  "$jason": {
    "head": {
      "title": "background test"
    },
    "body": {
      "style": {
        "background": "https://lumiere-a.akamaihd.net/v1/images/smile_-_pooh_b9b622d6.gif"
      }
    }
  }
}
realitix commented 7 years ago

Ok @gliechtenstein.

Can you describe me the behavior of a gif background on IPhone ? Is it freezed or is it moving ? Is it cropped or streched ?

realitix commented 7 years ago

I just borrowed an Iphone and with IOs it works like expected... Gif plays and image is cropped.

I'm looking for a solution.

realitix commented 7 years ago

@gliechtenstein Can you try again ?

It's now fully working with animation support. Background image is now displayed inside an ImageView.

gliechtenstein commented 7 years ago

@realitix I just tried this but still getting the problem. In fact it's both stretched and non-animated :(

screenshot_20170704-120306

gliechtenstein commented 7 years ago

👏👏👏👏👏👏👏👏👏👏👏👏👏👏👏

It works! Thanks so much for this! 🙌

pooh

realitix commented 7 years ago

Nice !