Android examples for java.lang:array
get Biggest Size Idx
//package com.java2s; import android.graphics.Point; import android.os.Build; import android.support.annotation.NonNull; import android.util.Log; public class Main { public static final String TAG = "CameraUtils"; public static int getBiggestSizeIdx(@NonNull Point[] sizes, int width, int height, boolean isSideways) { if (sizes == null || width <= 0 || height <= 0) { return 0; }/*from w ww . j a v a 2 s . c om*/ String model = Build.MODEL; if (model != null && model.equals("Nexus 4")) { width = height = Integer.MAX_VALUE; } if (isSideways) { int temp = width; width = height; height = temp; } int biggestScore = 0; int biggestIdx = 0; for (int i = 0; i < sizes.length; i++) { int score = sizes[i].x * sizes[i].y; if (sizes[i].x <= width && sizes[i].y <= height && score > biggestScore) { biggestScore = score; biggestIdx = i; } } return biggestIdx; } public static void log(String msg) { Log.v(TAG, msg); } }