Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.util.Log;
import java.util.ArrayList;
import java.util.Iterator;

public class Main {
    private static final int MIN_PERIOD = 5;
    private static final String TAG = "fetal_move";

    public static ArrayList<Integer> filterPoint(ArrayList<Integer> timePoints) {
        int lastPeriod = -1;
        logInConsole(timePoints);
        Iterator<Integer> it = timePoints.iterator();
        while (it.hasNext()) {
            int tmp = it.next();
            if (lastPeriod != -1 && tmp - lastPeriod < MIN_PERIOD) {
                it.remove();
            } else {
                lastPeriod = tmp;
            }
        }
        logInConsole(timePoints);
        return timePoints;
    }

    private static void logInConsole(ArrayList<Integer> timePoints) {
        StringBuffer sb = new StringBuffer();
        for (int i = 0; i < timePoints.size(); i++) {
            sb.append(timePoints.get(i)).append(" ");
        }
        Log.d(TAG, sb.toString());
    }
}