Android Open Source - MarsImagesAndroid Mars Images App






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;
//  ww w.  jav  a2  s .c  o  m
import android.app.Application;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v4.content.LocalBroadcastManager;

import com.google.common.collect.Maps;
import com.nostra13.universalimageloader.core.DisplayImageOptions;
import com.nostra13.universalimageloader.core.ImageLoader;
import com.nostra13.universalimageloader.core.ImageLoaderConfiguration;

import java.util.Map;

import gov.nasa.jpl.hi.marsimages.rovers.Curiosity;
import gov.nasa.jpl.hi.marsimages.rovers.Opportunity;
import gov.nasa.jpl.hi.marsimages.rovers.Rover;
import gov.nasa.jpl.hi.marsimages.rovers.Spirit;

/**
 * Created by mpowell on 5/21/14.
 */
public class MarsImagesApp extends Application {

    public static final String NOTES_CLEARED = "notesCleared";
    public static final String MISSION_CHANGED = "missionChanged";
    public static final String IMAGE_SELECTED = "imageSelected";
    public static final String IMAGE_INDEX = "imageIndex";
    public static final String SELECTION_SOURCE = "selectionSource";
    public static final String VIEW_PAGER_SOURCE = "viewPagerSource";
    public static final String LIST_SOURCE = "listSource";
    public static final String MARS_IMAGES_PREFERENCES_KEY = "com.powellware.marsimages.MARS_IMAGES";
    public static final String MISSION_NAME_PREFERENCE = "mission_name_preference";
    private static final String CURIOSITY_MISSION_NAME = "Curiosity";
    public static MarsImagesApp MARS_IMAGES;
    private String missionName;
    private Map<String, Rover> missions = Maps.newHashMap();
    private long pauseTimestamp;

    public MarsImagesApp() {
        MARS_IMAGES = this;
        missions.put(Rover.CURIOSITY, new Curiosity());
        missions.put(Rover.OPPORTUNITY, new Opportunity());
        missions.put(Rover.SPIRIT, new Spirit());
    }

    @Override
    public void onCreate() {
        super.onCreate();

        SharedPreferences sharedPreferences = getSharedPreferences(MARS_IMAGES_PREFERENCES_KEY, MODE_PRIVATE);
        missionName = sharedPreferences.getString(MISSION_NAME_PREFERENCE, CURIOSITY_MISSION_NAME);
        // Create global configuration and initialize ImageLoader with this configuration
        DisplayImageOptions defaultOptions = new DisplayImageOptions.Builder()
                .cacheInMemory(true)
                .cacheOnDisk(true)
                .build();
        ImageLoaderConfiguration config =
                new ImageLoaderConfiguration.Builder(getApplicationContext())
                        .defaultDisplayImageOptions(defaultOptions)
                        .build();
        ImageLoader.getInstance().init(config);
    }

    @Override
    public void onLowMemory() {
        ImageLoader.getInstance().clearMemoryCache();
        super.onLowMemory();
    }

    @Override
    public void onTerminate() {
        ImageLoader.getInstance().destroy();
        super.onTerminate();
    }

    public Rover getMission() {
        return missions.get(missionName);
    }

    public String getMissionName() {
        return missionName;
    }

    public void setMission(String newMissionName, Context context) {
        String newMission = newMissionName;
        if (!this.missionName.equals(newMission)) {
            this.missionName = newMission;
            Intent intent = new Intent(MISSION_CHANGED);
            LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
        }
    }

    public void setPauseTimestamp(long pauseTimestamp) {
        this.pauseTimestamp = pauseTimestamp;
    }

    public long getPauseTimestamp() {
        return pauseTimestamp;
    }
}




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