// Path: app/src/main/java/com/bedrock/padder/helper/WindowHelper.java
// public static int getId(String id) {
//     try {
//         Class res = R.id.class;
//         Field field = res.getField(id);
//         return field.getInt(null);
//     } catch (Exception e) {
//         Log.e("getId", "Failure to get id.", e);
//         return -1;
//     }
//     //from : https://daniel-codes.blogspot.com/2009/12/dynamically-retrieving-resources-in.html
// }
// 
// Path: app/src/main/java/com/bedrock/padder/model/tutorial/TimingListener.java
// public static ArrayList<Timing> timings = new ArrayList<>();


import android.app.Activity;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.util.Log;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import com.google.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import static com.bedrock.padder.helper.WindowHelper.getId;
import static com.bedrock.padder.model.tutorial.TimingListener.timings;

                boolean hasSamePad = sync.hasSamePad(syncs.get(currentSyncIndex));

                for (Sync.Item item : sync.items) {
                    if (hasSamePad && delay < 400) {
                        // Set duration as 50ms less than next interval
                        if (delay > 50) {
                            show(item.deck, item.pad, item.gesture, delay - 50);
                        } else {
                            Log.e("Sync", "TUTORIAL SKIPPED: bad tutorial composition (same pad under 50ms)");
                        }
                    } else {
                        show(item.deck, item.pad, item.gesture);
                    }
                }

                if (delay == 0) {
                    handler.post(this);
                } else {
                    handler.postDelayed(this, delay);
                }
            } else {
                for (Sync.Item item : sync.items) {
                    show(item.deck, item.pad, item.gesture);
                }
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Log.i("TUTORIAL", "ended");
                        listener.onFinish(getTutorial());
// Path: app/src/main/java/com/bedrock/padder/helper/WindowHelper.java
// public static int getId(String id) {
//     try {
//         Class res = R.id.class;
//         Field field = res.getField(id);
//         return field.getInt(null);
//     } catch (Exception e) {
//         Log.e("getId", "Failure to get id.", e);
//         return -1;
//     }
//     //from : https://daniel-codes.blogspot.com/2009/12/dynamically-retrieving-resources-in.html
// }
// 
// Path: app/src/main/java/com/bedrock/padder/model/tutorial/TimingListener.java
// public static ArrayList<Timing> timings = new ArrayList<>();


// Path: app/src/main/java/com/bedrock/padder/model/tutorial/Tutorial.java
import android.app.Activity;
import android.os.AsyncTask;
import android.os.Handler;
import android.os.Looper;
import android.support.v4.view.animation.LinearOutSlowInInterpolator;
import android.util.Log;
import android.view.View;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.ScaleAnimation;
import com.google.gson.GsonBuilder;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import static com.bedrock.padder.helper.WindowHelper.getId;
import static com.bedrock.padder.model.tutorial.TimingListener.timings;


                boolean hasSamePad = sync.hasSamePad(syncs.get(currentSyncIndex));

                for (Sync.Item item : sync.items) {
                    if (hasSamePad && delay < 400) {
                        // Set duration as 50ms less than next interval
                        if (delay > 50) {
                            show(item.deck, item.pad, item.gesture, delay - 50);
                        } else {
                            Log.e("Sync", "TUTORIAL SKIPPED: bad tutorial composition (same pad under 50ms)");
                        }
                    } else {
                        show(item.deck, item.pad, item.gesture);
                    }
                }

                if (delay == 0) {
                    handler.post(this);
                } else {
                    handler.postDelayed(this, delay);
                }
            } else {
                for (Sync.Item item : sync.items) {
                    show(item.deck, item.pad, item.gesture);
                }
                handler.postDelayed(new Runnable() {
                    @Override
                    public void run() {
                        Log.i("TUTORIAL", "ended");
                        listener.onFinish(getTutorial());
                        timings.clear();