private void setMediaData(final int mediaId, final String type, final String fileName, final String altText, final Supplier<byte[]> dataSupplier) {
        if (mediaId == this.mediaId) {
            return;
        }

        if (StringUtils.isBlank(altText)) {
            binding.mediaTextView.setVisibility(GONE);
        } else {
            binding.mediaTextView.setVisibility(VISIBLE);
            binding.mediaTextView.setText(Engine.removeHtml(altText));
        }

        if (type == null) {
            return;
        }

        final byte[] data = dataSupplier.get();
        if (data == null) {
            return;
        }

        final File cacheDir = WherigoGame.get().getCacheDirectory();
        final File mediaFile = cgeo.geocaching.utils.FileUtils.getOrCreate(cacheDir, "media-" + fileName, type, data);

        this.mediaId = mediaId;

        binding.mediaImageView.setVisibility(GONE);
        binding.mediaVideoView.setVisibility(GONE);
        binding.mediaGifView.setVisibility(GONE);

        switch (type.toLowerCase(Locale.US)) {
            case "mp4":
                //Video
                binding.mediaVideoView.setVideoURI(Uri.fromFile(mediaFile));
                binding.mediaVideoView.setVisibility(VISIBLE);
                break;
            case "gif":
                //gif
                binding.mediaGifView.setImageURI(Uri.fromFile(mediaFile));
                binding.mediaGifView.setVisibility(VISIBLE);
                break;
            case "jpeg":
            case "jpg":
            case "png":
            case "bmp":
                binding.mediaImageView.setImageURI(Uri.fromFile(mediaFile));
                binding.mediaImageView.setVisibility(VISIBLE);
                break;
            default:
                //do nothing
                break;
        }
    }
Allows live-editing of a formula, optionally associated with a Variable List
main/src/main/java/cgeo/geocaching/ui/WherigoMediaView.java