Android Open Source - geocamMemoAndroid Geo Cam Memo Home 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__
//  w w  w . java2  s. c om
package gov.nasa.arc.geocam.memo.activity;

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.ArrayList;
import java.util.List;

import roboguice.activity.RoboActivity;
import roboguice.inject.InjectView;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ListView;

import com.google.inject.Inject;


/**
 * The Class GeoCamMemoHomeActivity.
 */
public class GeoCamMemoHomeActivity extends RoboActivity {

  /** The django memo. */
  @Inject  DjangoMemoInterface djangoMemo;
  
  /** The memo list view. */
  @InjectView(R.id.MemoListView)ListView memoListView;
  
  /** The adapter. */
  @Inject  GeoCamMemoMessageArrayAdapter adapter;

  /**
   * 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.home);
    
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    
    String username = prefs.getString("webapp_username", null);
    String password = prefs.getString("webapp_password", null);
    
    djangoMemo.setAuth(username, password);
    
    List<GeoCamMemoMessage> memos = new ArrayList<GeoCamMemoMessage>();
    try {
    
      memos = djangoMemo.getMemos();

    } 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.");
    }
 
    adapter.setMemos(memos);
    memoListView.setAdapter(adapter);
    
    memoListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
      @Override
      public void onItemClick(AdapterView<?> parentView, View childView,
                                               int position, long id) {
        GeoCamMemoMessage msg = adapter.getItem(position);
        if (msg.hasGeolocation()) {
          UIUtils.showMapView(parentView.getContext(), msg);
        }
      }
    });

  }
  
  /**
   * On create memo click, start the {@link GeoCamMemoCreateActivity}
   *
   * @param v the v
   */
  public void onCreateMemoClick(View v){
    UIUtils.createMemo(this);
  }
}




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