package com.github.rtyley.android.screenshot.paparazzo.processors;

import com.madgag.gif.fmsware.AnimatedGifEncoder;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Map;

public class AnimatedGifCreator implements ScreenshotProcessor {

    private final AnimatedGifEncoder gifEncoder;
    private final File file;

    public AnimatedGifCreator(File file) {
        this.file = file;
        gifEncoder = new AnimatedGifEncoder();
        gifEncoder.setDelay(500);
    }

    @Override
    public void process(BufferedImage image, Map<String, String> requestData) {
        if (!gifEncoder.isStarted()) {
            gifEncoder.start(file.getAbsolutePath());
        }
        gifEncoder.addFrame(image);
    }

    @Override
    public void finish() {
        gifEncoder.finish();
    }

}

@@ -487,16 +487,49 @@
 y(500);%0A
+        gifEncoder.setRepeat(0);%0A
     %7D%0A%0A 

Set Animated GIFs to repeat