Android Open Source - MarsImagesAndroid Utils






From Project

Back to project page MarsImagesAndroid.

License

The source code is released under:

Apache License

If you think the Android project MarsImagesAndroid listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package gov.nasa.jpl.hi.marsimages;
//from   w  w w .j  a  va 2 s  .c o  m
import android.annotation.TargetApi;
import android.os.Build;
import android.os.Build.VERSION_CODES;
import android.os.StrictMode;

import gov.nasa.jpl.hi.marsimages.ui.ImageViewActivity;

/**
 * Created by mpowell on 5/6/14.
 */
public class Utils {

    private Utils() {
    }


    @TargetApi(Build.VERSION_CODES.HONEYCOMB)
    public static void enableStrictMode() {
        if (Utils.hasGingerbread()) {
            StrictMode.ThreadPolicy.Builder threadPolicyBuilder =
                    new StrictMode.ThreadPolicy.Builder()
                            .detectAll()
                            .penaltyLog();
            StrictMode.VmPolicy.Builder vmPolicyBuilder =
                    new StrictMode.VmPolicy.Builder()
                            .detectAll()
                            .penaltyLog();

            if (Utils.hasHoneycomb()) {
                threadPolicyBuilder.penaltyFlashScreen();
                vmPolicyBuilder
                        .setClassInstanceLimit(ImageViewActivity.class, 1);
            }
            StrictMode.setThreadPolicy(threadPolicyBuilder.build());
            StrictMode.setVmPolicy(vmPolicyBuilder.build());
        }
    }

    public static boolean hasFroyo() {
        // Can use static final constants like FROYO, declared in later versions
        // of the OS since they are inlined at compile time. This is guaranteed behavior.
        return Build.VERSION.SDK_INT >= VERSION_CODES.FROYO;
    }

    public static boolean hasGingerbread() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.GINGERBREAD;
    }

    public static boolean hasHoneycomb() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB;
    }

    public static boolean hasHoneycombMR1() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.HONEYCOMB_MR1;
    }

    public static boolean hasIceCreamSandwich() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.ICE_CREAM_SANDWICH;
    }

    public static boolean hasJellyBean() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN;
    }

    public static boolean hasJellyBeanMR2() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.JELLY_BEAN_MR2;
    }

    public static boolean hasKitKat() {
        return Build.VERSION.SDK_INT >= VERSION_CODES.KITKAT;
    }
}




Java Source Code List

gov.nasa.jpl.hi.marsimages.EvernoteMars.java
gov.nasa.jpl.hi.marsimages.MarsImagesApp.java
gov.nasa.jpl.hi.marsimages.Utils.java
gov.nasa.jpl.hi.marsimages.rovers.Curiosity.java
gov.nasa.jpl.hi.marsimages.rovers.MERTitle.java
gov.nasa.jpl.hi.marsimages.rovers.MarsTime.java
gov.nasa.jpl.hi.marsimages.rovers.Opportunity.java
gov.nasa.jpl.hi.marsimages.rovers.Rover.java
gov.nasa.jpl.hi.marsimages.rovers.Spirit.java
gov.nasa.jpl.hi.marsimages.rovers.Title.java
gov.nasa.jpl.hi.marsimages.ui.AboutThisAppActivity.java
gov.nasa.jpl.hi.marsimages.ui.HackyDrawerLayout.java
gov.nasa.jpl.hi.marsimages.ui.HackyViewPager.java
gov.nasa.jpl.hi.marsimages.ui.ImageListFragment.java
gov.nasa.jpl.hi.marsimages.ui.ImageViewActivity.java
gov.nasa.jpl.hi.marsimages.ui.ImageViewFragment.java
gov.nasa.jpl.hi.marsimages.ui.MarsClockActivity.java