Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sizing the gifs #9

Closed
annaharri89 opened this issue Jul 17, 2019 · 3 comments
Closed

sizing the gifs #9

annaharri89 opened this issue Jul 17, 2019 · 3 comments

Comments

@annaharri89
Copy link

Hi, this is Anna Harrison with Mutual. We're trying to size our GPHMediaViews based on the gif size, but we're having trouble doing it. We were going to try to do something with the media.aspectRatio, but that comes back as nil every time. Is that a bug? Is there any other fields available that would help with sizing the gifs?

@cgmaier
Copy link
Contributor

cgmaier commented Jul 18, 2019

Hi Anna, nice catch! We were able to identify a possible cause of your issue.

Have you been trying to use the setMediaWithID(id) method to set the media on the GPHMediaView?

As fetching the media object is asynchronous, the GPHMediaView's media property will likely still be nil when you attempt to check the aspectRatio property.

We could address this issue by adding a completion block to the setMediaWithID(id) method, but we think the best strategy going forward is for developers to fetch the media object themselves with GiphyCore.shared.gifByID(id) and then populate the GPHMediaView with mediaView.media = media

We updated the docs to explain this approach, and will remove the setMediaWithID(id) method in our next release to avoid confusion.

Please let us know if this resolves your issue, and if we can help with anything else.

Thanks,
Chris

@annaharri89
Copy link
Author

annaharri89 commented Jul 19, 2019

@cgmaier Please do not remove the setMediaWithId method. That would completely break our implementation of the giphy sdk. We are using setMediaWithId in our chat client. We send the gif id in some meta data in our chat message and then use regex to pull out the id and load it into the GPHMediaView using setMediaWithId (so we don't have to store the whole media object on our servers). So please don't remove it.

We figured out how to get the gifs sized correctly.

Thanks,
Anna

@iehsan77
Copy link

iehsan77 commented Apr 7, 2020

getting the following error with

<com.giphy.sdk.ui.views.GPHMediaView
android:id="@+id/gifViewAnimated"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:layout_marginEnd="24dp"
android:elevation="4dp"
android:scaleType="fitCenter"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />

App crash with the following error

Process: com.example.smeschat, PID: 14226
android.view.InflateException: Binary XML file line #33: Binary XML file line #33: Error inflating class com.giphy.sdk.ui.views.GPHMediaView
Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class com.giphy.sdk.ui.views.GPHMediaView
Caused by: java.lang.reflect.InvocationTargetException

djrluna pushed a commit that referenced this issue Apr 21, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants