// Path: app/src/main/java/de/lukasniemeier/gamecenterlivesender/model/publishpoint/PublishPointResult.java
// public class PublishPointResult extends Entity {
// 
//     @XML(tag = "result" + XML.SUB + "path")
//     public String path;
// 
//     public static PublishPointResult parse(String body, Context ctx) throws Exception {
//         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//         DocumentBuilder builder = factory.newDocumentBuilder();
//         Document xml = builder.parse(new InputSource(new StringReader(body)));
// 
//         XMLSerializer<PublishPointResult> serializer =
//                 new XMLSerializer<PublishPointResult>(PublishPointResult.class, ctx);
// 
//         return serializer.deserialize(xml);
//     }
// }
// 
// Path: app/src/main/java/de/lukasniemeier/gamecenterlivesender/utils/Functional.java
// public class Functional {
// 
//     public interface Procedure {
//         void execute();
//     }
// 
//     public interface Consumer<T> {
//         void accept(T t);
//     }
// 
//     public interface BiConsumer<R, S> {
//         void accept(R r, S s);
//     }
// 
//     public interface Supplier<T> {
//         T get();
//     }
// 
//     public interface Function<T, R> {
//         R apply(T t);
//     }
// 
//     public interface Predicate<T> {
//         boolean test(T t);
//     }
// }


import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.TextView;
import android.widget.Toast;
import org.droidparts.contract.HTTP;
import org.droidparts.net.http.HTTPException;
import org.droidparts.net.http.RESTClient2;
import java.util.HashMap;
import java.util.Map;
import de.lukasniemeier.gamecenterlivesender.R;
import de.lukasniemeier.gamecenterlivesender.model.publishpoint.PublishPointResult;
import de.lukasniemeier.gamecenterlivesender.utils.Functional;

        this.fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
        fadeOutAnimation.setDuration(2000);
        fadeOutAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                statusView.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationStart(Animation animation) { }

            @Override
            public void onAnimationRepeat(Animation animation) { }
        });
    }

    public HttpTask createPublishTask(String url, Functional.Consumer<String> castConsumer) {
        return createPublish(url, castConsumer,
                exception -> {
                    String message = context.getString(R.string.error_cast_generic);
                    if (exception instanceof HTTPException) {
                        HTTPException httpException = (HTTPException) exception;
                        if (httpException.getResponseCode() == 400) {
                            message = context.getString(R.string.error_missing_feed);
                        }
                    }
                    showErrorToast(message, exception);
                });
    }


// Path: app/src/main/java/de/lukasniemeier/gamecenterlivesender/model/publishpoint/PublishPointResult.java
// public class PublishPointResult extends Entity {
// 
//     @XML(tag = "result" + XML.SUB + "path")
//     public String path;
// 
//     public static PublishPointResult parse(String body, Context ctx) throws Exception {
//         DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
//         DocumentBuilder builder = factory.newDocumentBuilder();
//         Document xml = builder.parse(new InputSource(new StringReader(body)));
// 
//         XMLSerializer<PublishPointResult> serializer =
//                 new XMLSerializer<PublishPointResult>(PublishPointResult.class, ctx);
// 
//         return serializer.deserialize(xml);
//     }
// }
// 
// Path: app/src/main/java/de/lukasniemeier/gamecenterlivesender/utils/Functional.java
// public class Functional {
// 
//     public interface Procedure {
//         void execute();
//     }
// 
//     public interface Consumer<T> {
//         void accept(T t);
//     }
// 
//     public interface BiConsumer<R, S> {
//         void accept(R r, S s);
//     }
// 
//     public interface Supplier<T> {
//         T get();
//     }
// 
//     public interface Function<T, R> {
//         R apply(T t);
//     }
// 
//     public interface Predicate<T> {
//         boolean test(T t);
//     }
// }


// Path: app/src/main/java/de/lukasniemeier/gamecenterlivesender/http/TaskFactory.java
import android.content.Context;
import android.util.Log;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.widget.TextView;
import android.widget.Toast;
import org.droidparts.contract.HTTP;
import org.droidparts.net.http.HTTPException;
import org.droidparts.net.http.RESTClient2;
import java.util.HashMap;
import java.util.Map;
import de.lukasniemeier.gamecenterlivesender.R;
import de.lukasniemeier.gamecenterlivesender.model.publishpoint.PublishPointResult;
import de.lukasniemeier.gamecenterlivesender.utils.Functional;

        this.fadeOutAnimation = new AlphaAnimation(1.0f, 0.0f);
        fadeOutAnimation.setDuration(2000);
        fadeOutAnimation.setAnimationListener(new Animation.AnimationListener() {
            @Override
            public void onAnimationEnd(Animation animation) {
                statusView.setVisibility(View.GONE);
            }

            @Override
            public void onAnimationStart(Animation animation) { }

            @Override
            public void onAnimationRepeat(Animation animation) { }
        });
    }

    public HttpTask createPublishTask(String url, Functional.Consumer<String> castConsumer) {
        return createPublish(url, castConsumer,
                exception -> {
                    String message = context.getString(R.string.error_cast_generic);
                    if (exception instanceof HTTPException) {
                        HTTPException httpException = (HTTPException) exception;
                        if (httpException.getResponseCode() == 400) {
                            message = context.getString(R.string.error_missing_feed);
                        }
                    }
                    showErrorToast(message, exception);
                });
    }


    public HttpTask createPublishTaskWithFallback(final Task fallbackTask, String url, Functional.Consumer<String> castConsumer) {
