Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: LGPL 

import android.hardware.Camera;

import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class Main {
    static Comparator<Camera.Size> _ascSize = new Comparator<Camera.Size>() {
        @Override
        public int compare(Camera.Size arg0, Camera.Size arg1) {
            return (arg1.width + arg1.height) < (arg0.width + arg0.height) ? 1 : -1;
        }
    };
    static Comparator<Camera.Size> _descSize = new Comparator<Camera.Size>() {
        @Override
        public int compare(Camera.Size arg0, Camera.Size arg1) {
            return (arg1.width + arg1.height) > (arg0.width + arg0.height) ? 1 : -1;
        }
    };

    public static void sortCameraSize(List<Camera.Size> list, boolean desc) {
        if (desc) {
            Collections.sort(list, _descSize);
        } else {
            Collections.sort(list, _ascSize);
        }
    }
}