Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Set;

import android.content.Context;
import android.graphics.Point;

public class Main {
    private static Context mContext;
    private static String PREFER = "LuxLevel";
    private static String LEVELSET = "levelSet";
    private static Set<String> mLevelSet = null;
    private static Comparator<String> mComparator = new Comparator<String>() {
        @Override
        public int compare(String a, String b) {
            return Integer.valueOf(a) - Integer.valueOf(b);
        }
    };

    public static boolean getBoundaryLevel(Point bound) {
        if (mLevelSet == null)
            mLevelSet = mContext.getSharedPreferences(PREFER, Context.MODE_WORLD_READABLE).getStringSet(LEVELSET,
                    null);
        if (mLevelSet != null) {
            ArrayList<String> array = Collections.list(Collections.enumeration(mLevelSet));
            Collections.sort(array, mComparator);
            bound.x = Integer.valueOf(array.get(0));
            bound.y = Integer.valueOf(array.get(array.size() - 1));
            return true;
        }
        return false;
    }
}