Example usage for java.lang Integer MAX_VALUE

List of usage examples for java.lang Integer MAX_VALUE

Introduction

In this page you can find the example usage for java.lang Integer MAX_VALUE.

Prototype

int MAX_VALUE

To view the source code for java.lang Integer MAX_VALUE.

Click Source Link

Document

A constant holding the maximum value an int can have, 231-1.

Usage

From source file:Main.java

public static <T> List<T> sublist(List<T> result, long startIndex, long size) {
    long endIndex = result.size();
    if (size < endIndex - startIndex) {
        endIndex = startIndex + size;/*from w w  w  . j  a  v a2  s. com*/
    }
    if (startIndex > Integer.MAX_VALUE) {
        throw new RuntimeException("StartIndex " + startIndex
                + " is bigger than maxInt. You shouldn't use a InMemoryRawMessagingDao.");
    }
    if (endIndex > Integer.MAX_VALUE) {
        throw new RuntimeException("EndIndex " + endIndex
                + " is bigger than maxInt. You shouldn't use a InMemoryRawMessagingDao.");
    }
    return result.subList(Ints.checkedCast(startIndex), Ints.checkedCast(endIndex));
}

From source file:Main.java

public static Size determineTargetPictureSize(Camera.Parameters params, int desiredResolution) {
    List<Size> sizes = params.getSupportedPictureSizes();
    Size targetSize = sizes.get(0);/*from   ww  w .j a v  a  2 s . c  om*/
    int delta = Integer.MAX_VALUE;

    for (Size size : sizes) {
        int diff = Math.abs(desiredResolution - pixelCount(size));
        if (diff < delta) {
            targetSize = size;
            delta = diff;
        }
    }
    return targetSize;
}

From source file:Main.java

public static boolean isServiceRunning(Class<?> serviceClass, Context context) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }// ww  w.  j a v a  2s .  co  m
    }
    return false;
}

From source file:Main.java

public static boolean isMyServiceRunning(Context context, Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName()))
            return true;
    }//w w  w  . j a  va 2 s  .co m
    return false;
}

From source file:Main.java

public static boolean isServiceRunning(Context context, Class<?> serviceClass) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }/*w ww  .  j a v  a 2 s. c o m*/
    }
    return false;
}

From source file:Main.java

static int copy(InputStream input, OutputStream output) throws IOException {
    long count = copyLarge(input, output);
    if (count > Integer.MAX_VALUE) {
        return -1;
    }/*www  .j  av  a 2s  .c  o  m*/
    return (int) count;
}

From source file:Main.java

public static void calcViewMeasure(View view) {
    int width = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
    int expandSpec = View.MeasureSpec.makeMeasureSpec(Integer.MAX_VALUE >> 2, View.MeasureSpec.AT_MOST);
    view.measure(width, expandSpec);// w w w . j a va  2 s  .  c om
}

From source file:Main.java

public static boolean isApplicationForeground(Context context) {
    ActivityManager activityManager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    List<ActivityManager.RunningTaskInfo> services = activityManager.getRunningTasks(Integer.MAX_VALUE);
    for (ActivityManager.RunningTaskInfo info : services) {
        if (info.topActivity.getPackageName().equalsIgnoreCase(context.getPackageName())) {
            return true;
        }/*from  w w w.  j  a v a2 s .  c  o  m*/
    }
    return false;
}

From source file:Main.java

public static int mulAndCheck(int x, int y) {
    long m = ((long) x) * ((long) y);
    if (m < Integer.MIN_VALUE || m > Integer.MAX_VALUE) {
        throw new ArithmeticException("overflow: mul");
    }//from w w w . ja  va 2  s  . com
    return (int) m;
}

From source file:Main.java

public static boolean isMyServiceRunning(Context context, Class<?> clz) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (clz.getName().equals(service.service.getClassName())) {
            return true;
        }/*from  ww  w  .  j  ava  2  s.co m*/
    }
    return false;
}