Android Open Source - geocamMemoAndroid Geo Cam Memo Create Activity






From Project

Back to project page geocamMemoAndroid.

License

The source code is released under:

NASA OPEN SOURCE AGREEMENT VERSION 1.3 THIS OPEN SOURCE AGREEMENT ("AGREEMENT") DEFINES THE RIGHTS OF USE, REPRODUCTION, DISTRIBUTION, MODIFICATION AND REDISTRIBUTION OF CERTAIN COMPUTER SOFTWARE ORI...

If you think the Android project geocamMemoAndroid 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

// __BEGIN_LICENSE__
// Copyright (C) 2008-2010 United States Government as represented by
// the Administrator of the National Aeronautics and Space Administration.
// All Rights Reserved.
// __END_LICENSE__
//from  ww  w. j  a  va2s .c om
package gov.nasa.arc.geocam.memo.activity;

import gov.nasa.arc.geocam.memo.GeoCamMemoRoboApplication;
import gov.nasa.arc.geocam.memo.R;
import gov.nasa.arc.geocam.memo.UIUtils;
import gov.nasa.arc.geocam.memo.bean.GeoCamMemoMessage;
import gov.nasa.arc.geocam.memo.exception.AuthenticationFailedException;
import gov.nasa.arc.geocam.memo.service.DjangoMemoInterface;

import java.util.Date;

import roboguice.activity.RoboActivity;
import roboguice.inject.InjectView;
import android.location.Location;
import android.os.Bundle;
import android.view.View;
import android.widget.EditText;

import com.google.inject.Inject;

/**
 * The Class GeoCamMemoCreateActivity.  This activity gives the 
 * user the opportunity to add a new memo
 */
public class GeoCamMemoCreateActivity extends RoboActivity {

  /** The new memo input. */
  @InjectView(R.id.newMemoInput)
  EditText newMemoInput;
  
  /** The app state. */
  @Inject
  GeoCamMemoRoboApplication appState;
  
  /** The django memo interface. */
  @Inject
  DjangoMemoInterface djangoMemoInterface;

  /**
   * Called when the activity is first created.
   *
   * @param savedInstanceState the saved instance state
   */
  @Override
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.create_memo);
  }

  /**
   * On home click, restart the {@link GeoCamMemoHomeActivity}.
   *
   * @param v the view
   */
  public void onHomeClick(View v) {
    UIUtils.goHome(this);
  }

  /**
   * On send click, create a new {@link GeoCamMemoMessage} using the 
   * text and time stamp from the {@link GeoCamMemoCreateActivity}.  Populate
   * the location if available.  
   *
   * @param v the view
   */
  public void onSendClick(View v) {
    CharSequence text = newMemoInput.getText();

    Location location = appState.getLocation();

    GeoCamMemoMessage message = new GeoCamMemoMessage();
    message.setContent(text.toString());
    message.setContentTimestamp(new Date());

    if (location != null) {
      message.setLatitude(location.getLatitude());
      message.setLongitude(location.getLongitude());
      if (location.hasAccuracy()) {
        message.setAccuracy((int) location.getAccuracy());
      }
    }

    try {
      djangoMemoInterface.createMemo(message);
      UIUtils.goHome(this);
    } catch (AuthenticationFailedException e) {
      UIUtils.displayException(this, e, "Could not authenticate with the server");
    } catch (Exception e) {
      UIUtils.displayException(this, e, "Communication with the server failed");
    }

  }
}




Java Source Code List

gov.nasa.arc.geocam.memo.GeoCamMemoModule.java
gov.nasa.arc.geocam.memo.GeoCamMemoRoboApplication.java
gov.nasa.arc.geocam.memo.UIUtils.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoCreateActivity.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoHomeActivity.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoMapActivity.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoMessageArrayAdapter.java
gov.nasa.arc.geocam.memo.activity.GeoCamMemoSettings.java
gov.nasa.arc.geocam.memo.bean.GeoCamMemoMessage.java
gov.nasa.arc.geocam.memo.exception.AuthenticationFailedException.java
gov.nasa.arc.geocam.memo.service.DjangoMemoImplementation.java
gov.nasa.arc.geocam.memo.service.DjangoMemoInterface.java
gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterImplementation.java
gov.nasa.arc.geocam.memo.service.DjangoMemoJsonConverterInterface.java
gov.nasa.arc.geocam.memo.service.GeoLocationListener.java
gov.nasa.arc.geocam.memo.service.MemoMapOverlay.java
gov.nasa.arc.geocam.memo.service.SiteAuthCookieImplementation.java
gov.nasa.arc.geocam.memo.service.SiteAuthInterface.java