{"action":"created","issue":{"url":"https://api.github.com/repos/mapbox/mapbox-android-demo/issues/558","repository_url":"https://api.github.com/repos/mapbox/mapbox-android-demo","labels_url":"https://api.github.com/repos/mapbox/mapbox-android-demo/issues/558/labels{/name}","comments_url":"https://api.github.com/repos/mapbox/mapbox-android-demo/issues/558/comments","events_url":"https://api.github.com/repos/mapbox/mapbox-android-demo/issues/558/events","html_url":"https://github.com/mapbox/mapbox-android-demo/issues/558","id":277896849,"node_id":"MDU6SXNzdWUyNzc4OTY4NDk=","number":558,"title":"Add animating gif example with ImageSource","user":{"login":"tobrun","id":2151639,"node_id":"MDQ6VXNlcjIxNTE2Mzk=","avatar_url":"https://avatars0.githubusercontent.com/u/2151639?v=4","gravatar_id":"","url":"https://api.github.com/users/tobrun","html_url":"https://github.com/tobrun","followers_url":"https://api.github.com/users/tobrun/followers","following_url":"https://api.github.com/users/tobrun/following{/other_user}","gists_url":"https://api.github.com/users/tobrun/gists{/gist_id}","starred_url":"https://api.github.com/users/tobrun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tobrun/subscriptions","organizations_url":"https://api.github.com/users/tobrun/orgs","repos_url":"https://api.github.com/users/tobrun/repos","events_url":"https://api.github.com/users/tobrun/events{/privacy}","received_events_url":"https://api.github.com/users/tobrun/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":{"login":"langsmith","id":4394910,"node_id":"MDQ6VXNlcjQzOTQ5MTA=","avatar_url":"https://avatars1.githubusercontent.com/u/4394910?v=4","gravatar_id":"","url":"https://api.github.com/users/langsmith","html_url":"https://github.com/langsmith","followers_url":"https://api.github.com/users/langsmith/followers","following_url":"https://api.github.com/users/langsmith/following{/other_user}","gists_url":"https://api.github.com/users/langsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/langsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langsmith/subscriptions","organizations_url":"https://api.github.com/users/langsmith/orgs","repos_url":"https://api.github.com/users/langsmith/repos","events_url":"https://api.github.com/users/langsmith/events{/privacy}","received_events_url":"https://api.github.com/users/langsmith/received_events","type":"User","site_admin":false},"assignees":[{"login":"langsmith","id":4394910,"node_id":"MDQ6VXNlcjQzOTQ5MTA=","avatar_url":"https://avatars1.githubusercontent.com/u/4394910?v=4","gravatar_id":"","url":"https://api.github.com/users/langsmith","html_url":"https://github.com/langsmith","followers_url":"https://api.github.com/users/langsmith/followers","following_url":"https://api.github.com/users/langsmith/following{/other_user}","gists_url":"https://api.github.com/users/langsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/langsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langsmith/subscriptions","organizations_url":"https://api.github.com/users/langsmith/orgs","repos_url":"https://api.github.com/users/langsmith/repos","events_url":"https://api.github.com/users/langsmith/events{/privacy}","received_events_url":"https://api.github.com/users/langsmith/received_events","type":"User","site_admin":false}],"milestone":null,"comments":4,"created_at":"2017-11-29T20:32:22Z","updated_at":"2019-01-02T17:40:43Z","closed_at":"2017-11-30T15:20:50Z","author_association":"MEMBER","body":"Sample code:\r\n\r\n```java\r\npublic class AnimatedImageSourceActivity extends AppCompatActivity implements OnMapReadyCallback {\r\n\r\n  private static final String ID_IMAGE_SOURCE = \"animated_image_source\";\r\n  private static final String ID_IMAGE_LAYER = \"animated_image_layer\";\r\n\r\n  private MapView mapView;\r\n  private Handler handler;\r\n  private Runnable runnable;\r\n\r\n  @Override\r\n  protected void onCreate(Bundle savedInstanceState) {\r\n    super.onCreate(savedInstanceState);\r\n    setContentView(R.layout.activity_animated_image_source);\r\n\r\n    mapView = (MapView) findViewById(R.id.mapView);\r\n    mapView.onCreate(savedInstanceState);\r\n    mapView.getMapAsync(this);\r\n  }\r\n\r\n  @Override\r\n  public void onMapReady(@NonNull final MapboxMap map) {\r\n    LatLngQuad quad = new LatLngQuad(\r\n      new LatLng(46.437, -80.425),\r\n      new LatLng(46.437, -71.516),\r\n      new LatLng(37.936, -71.516),\r\n      new LatLng(37.936, -80.425));\r\n    ImageSource imageSource = new ImageSource(ID_IMAGE_SOURCE, quad, R.raw.giphy);\r\n    map.addSource(imageSource);\r\n\r\n    RasterLayer layer = new RasterLayer(ID_IMAGE_LAYER, ID_IMAGE_SOURCE);\r\n    map.addLayer(layer);\r\n\r\n    InputStream gifInputStream = getResources().openRawResource(R.raw.giphy);\r\n    runnable = new RefreshImageRunnable(imageSource, Movie.decodeStream(gifInputStream), handler = new Handler());\r\n    handler.postDelayed(runnable, 100);\r\n  }\r\n\r\n  @Override\r\n  protected void onStart() {\r\n    super.onStart();\r\n    mapView.onStart();\r\n  }\r\n\r\n  @Override\r\n  public void onResume() {\r\n    super.onResume();\r\n    mapView.onResume();\r\n  }\r\n\r\n  @Override\r\n  public void onPause() {\r\n    super.onPause();\r\n    mapView.onPause();\r\n  }\r\n\r\n  @Override\r\n  protected void onStop() {\r\n    super.onStop();\r\n    mapView.onStop();\r\n    handler.removeCallbacks(runnable);\r\n  }\r\n\r\n  @Override\r\n  protected void onDestroy() {\r\n    super.onDestroy();\r\n    mapView.onDestroy();\r\n  }\r\n\r\n  @Override\r\n  protected void onSaveInstanceState(Bundle outState) {\r\n    super.onSaveInstanceState(outState);\r\n    mapView.onSaveInstanceState(outState);\r\n  }\r\n\r\n  private static class RefreshImageRunnable implements Runnable {\r\n\r\n    private ImageSource imageSource;\r\n    private Movie movie;\r\n    private Handler handler;\r\n    private long movieStart;\r\n    private Bitmap bitmap;\r\n    private Canvas canvas;\r\n\r\n    RefreshImageRunnable(ImageSource imageSource, Movie movie, Handler handler) {\r\n      this.imageSource = imageSource;\r\n      this.movie = movie;\r\n      this.handler = handler;\r\n      bitmap = Bitmap.createBitmap(movie.width(), movie.height(), Bitmap.Config.ARGB_8888);\r\n      canvas = new Canvas(bitmap);\r\n    }\r\n\r\n    @Override\r\n    public void run() {\r\n      long now = android.os.SystemClock.uptimeMillis();\r\n      if (movieStart == 0) {\r\n        movieStart = now;\r\n      }\r\n\r\n      int dur = movie.duration();\r\n      if (dur == 0) {\r\n        dur = 1000;\r\n      }\r\n\r\n      movie.setTime((int) ((now - movieStart) % dur));\r\n      movie.draw(canvas, 0, 0);\r\n\r\n      imageSource.setImage(bitmap);\r\n      handler.postDelayed(this, 50);\r\n    }\r\n  }\r\n}\r\n```\r\n\r\n![ezgif com-video-to-gif 11](https://user-images.githubusercontent.com/2151639/33397695-c1569466-d54c-11e7-8701-c889faadb5ea.gif)\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/mapbox/mapbox-android-demo/issues/comments/450929761","html_url":"https://github.com/mapbox/mapbox-android-demo/issues/558#issuecomment-450929761","issue_url":"https://api.github.com/repos/mapbox/mapbox-android-demo/issues/558","id":450929761,"node_id":"MDEyOklzc3VlQ29tbWVudDQ1MDkyOTc2MQ==","user":{"login":"langsmith","id":4394910,"node_id":"MDQ6VXNlcjQzOTQ5MTA=","avatar_url":"https://avatars1.githubusercontent.com/u/4394910?v=4","gravatar_id":"","url":"https://api.github.com/users/langsmith","html_url":"https://github.com/langsmith","followers_url":"https://api.github.com/users/langsmith/followers","following_url":"https://api.github.com/users/langsmith/following{/other_user}","gists_url":"https://api.github.com/users/langsmith/gists{/gist_id}","starred_url":"https://api.github.com/users/langsmith/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/langsmith/subscriptions","organizations_url":"https://api.github.com/users/langsmith/orgs","repos_url":"https://api.github.com/users/langsmith/repos","events_url":"https://api.github.com/users/langsmith/events{/privacy}","received_events_url":"https://api.github.com/users/langsmith/received_events","type":"User","site_admin":false},"created_at":"2019-01-02T17:40:43Z","updated_at":"2019-01-02T17:40:43Z","author_association":"CONTRIBUTOR","body":"Yes @chitgoks !\r\n\r\n![ezgif com-optimize 3](https://user-images.githubusercontent.com/4394910/50603966-464ca700-0e72-11e9-8ee8-2282934d7946.gif)\r\n"}}
{"actor":{"display_login":"langsmith"}}